/************************************************************/
unsigned int cewen()
{
unsigned int cewen_a1;
GO =1;
NOP();
NOP();
while(nDONE){NOP();NOP();}
NOP();NOP();NOP();
NOP();NOP();NOP();
NOP();NOP();NOP();
cewen_a1 =ADRESH;
cewen_a1 <<=8;
cewen_a1 |=ADRESL;
return cewen_a1;
}
/************************************************************/
void cewen_chushihua()
{
TRISA7 =1; //PA7输入模式
ANSELA =1<<4; //第四路
//ADRESL //ADC 转换结果低有效位 (LSB)
//ADRESH //ADC 转换结果高有效位 (MSB)
ADCEN =1; //ADC 模块时钟
CHS2 =1; //100 = AN4
CHS1 =0;
CHS0 =0;
ADEX =0; //由指令置位 GO/DONE (软件触发)
//GO/DONE //启动 A/D 转换
ADON =1; //ADC 使能
ADFM =1; //右对齐
ADCS2 =1; //100 = SysClk/4
ADCS1 =0;
ADCS0 =0;
ADNREF1 =0; //负参考电压01 = GND
ADNREF0 =1;
/*
ADPREF1 =0; //正参考电01 = VDD
ADPREF0 =1;
*/
ADPREF1 =0; //正参考电压00 = 内部 V ADC-REF
ADPREF0 =0;
ADINTREF1 =1; //10 = 3.0V
ADINTREF0 =0;
}
/************************************************************/
/************************************************************/
|