📄 adc-s3c44b0.c
字号:
#include "..\startup\44b.h"
#include "..\startup\Bitops.h"
#include "ADC-S3C44B0.h"
#include <string.h>
void init_ADdevice()
{
rADCPSR=20;
rADCCON=ADCCON_SLEEP;
}
//void __irq BDMA1_Done(void);
int GetADresult(int ch)
{
int i;
static int prevCh=-1;
if(prevCh!=ch){
rADCCON=0x0|(ch<<2); //setup channel.
for(i=0;i<150;i++); //min. 15us
}
rADCCON=ADCCON_ENABLE_START|(ch<<2); //Start A/D conversion
Delay(10); //To avoid The first FLAG error case,(The START bit is cleared in one ADC clock.)
while(!(rADCCON & 0x40)); //Conversion end.
for(i=0;i<rADCPSR;i++); //To avoid The second FLAG error case,The FLAG will be 1 one ADC clock time ago than the ADC conversion is completed. This is not correct.
return rADCDAT;
}
void ADTest_Loop()
{
static int count=0;
int i;
count++;
if(count<50000)
return;
count=0;
Uart_Printf("\r");
for(i=0;i<7;i++){
Uart_Printf("%8AD%d=%4.4d",i,GetADresult(i));
Delay(100);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -