unsigned int initADC()
{
unsigned int adval;
float advalf;
ADC_TRIS=1;//设置为输入
//ADC=0;
//TRISE=0x00;
TRISA2=TRISA3=1;
//TRISA=0x01;//RA0为模拟输入
ADCON1=0x8f;//设置RA0为AD口Vref为参考电压
ADCON0=0x41;//通道0,频率为fosc/8,启用ADC
nop(1);
GO=1;
while(GO);
adval=ADRESH;//00000000 00000011
adval=adval<<8|ADRESL;//00000011 11111111
advalf=adval/1023.0*5.0;//==2.3843
adval=(unsigned int)(advalf*1000);
return (adval);
}
有哪位高手能帮我看看这AADC初始化是哪里出问题了吗? |