AD初始化程序如下(采用轮询的方式获得ADC值):
void ini_adc()
{
/*------ADDR----*/
REGCON = 0X01; //TURN ON ADDR Vaddr=2.7V
/*------ADC-----*/
ADCON = 0X01; //单端输入AN0,参考电压选择:ADDR分压
ADT = 0XFB; //ADC CLOCK =100K ADC转换频率:25Hz
ADCH = 0Xe6; //ADCVERF=0.4*VDDR P1^3 ADC INPUT
ADCDS = 0X01; //ADC单极性输出
/*......OP ......*/
OPCON = 0X00; // OP DISABLE / P2.1~P2.3 USE I/O PORT
/*------PGA------*/
PGAM = 0X04; //PGA=4 开启削波控制器
ADCON |= 1<<7; //ENABLE ADC
}
当差分输入电压为:0.22V时,通过ADC=524288*(V+-V-)/Vref,计算得到ADC=0x1A9DC,但实际测量为:0xEEC0.
|