根据测量。发现用1.25V测量1/3VDD大概有40mV的偏差。
uchar Channels[] = {0x3F,0xb5,0xb4,0xb3,0xb2,0xb1,0xb0};//用于保存赋给ADCCON3
uchar adcl, adch;
UINT32 adc;
double temp_res,Vt;;
float voltage;
ADCH &= 0X00;
ADCCON2 = Channels[channel];
// STSEL = 11 => Start a conversion when ST = 1
ADCCON1 = 0x33;
// SREF = Internal 1.25V
// SDIV = 12 bits resolution
// SCH = AIN0
// ADCCON2 = 0x30;
// Start a conversion (ST = 1)
ADCCON1 |= 0x40;
while (!(ADCCON1 & 0x80));
adcl = ADCL;
adch = ADCH;
adc = ((uint)(adch << 8) | ((uint)adcl)); // adc[15:0] = adc[11]:adc[10]:adc[9]...adc[0]:x:x:x:x
adc = (uint)adc/16; // The adc value needs to be shifted 4 bits to the left (divide on 2^4)
请问这是芯片本身原因还是说程序有问题。用VDD做参考精度是可以的。用1.25V做参考偏差有点大。能否給出具体数据!