阅读:1406回复:2
三星2440的AD转换如何设置?
我要用AN1脚做AD转换,但是IC资料上只对触摸屏进行了详细说明,没有说明用做普通AD转换寄存器该如何设置,哪为大哥有这方面的经验,可否指点一下,能否举个例子
|
|
沙发#
发布于:2007-04-05 13:40
//ADC special function register
#define rADCCON (*(volatile unsigned *)0x58000000) //ADC control #define rADCTSC (*(volatile unsigned *)0x58000004) //ADC touch screen control #define rADCDLY (*(volatile unsigned *)0x58000008) //ADC start or Interval Delay #define rADCDAT0 (*(volatile unsigned *)0x5800000c) //ADC conversion data 0 #define rADCDAT1 (*(volatile unsigned *)0x58000010) //ADC conversion data 1 #define rADCUPDN (*(volatile unsigned *)0x58000014) //Stylus Up/Down interrupt statu #define ADC_FREQ 1000000 #define LOOP 10000 int ReadAdc(void) { U32 preScaler; U32 rADCCON_save = rADCCON; U8 ch = 1; preScaler = 50000000/ADC_FREQ -1; //A/D converter freq = PCLK/(prescaler+1),这个值是根据你采样频率来设置。 rADCCON = (1<<14)|(preScaler<<6)|(ch<<3); //enable prescaler,set channel} for(i = 0;i<LOOP;i++); //delay to set up the channel rADCCON|=0x1; //start ADC while(rADCCON & 0x1); //check if Enable_start is low while(!(rADCCON&0x8000)); //check if EC(End of Conversion) flag is high return ( (int)rADCDAT0 & 0x3ff ); } 基本的用法就是这样了,具体的寄存器设置,可以看看datasheet。 |
|
板凳#
发布于:2007-04-06 16:46
呵呵,谢谢高手的指点,现在可以了
|
|