现在用cc2530F256开发产品发现一个问题,就是通过下面函数获得芯片的工作电压,但是发现,随着温度的降低,监测的电压也随着变小,实际的供电电压是没有改变的,
static uint8 readVoltage(void)
{
uint16 value;
// Clear ADC interrupt flag
ADCIF = 0;
ADCCON3 = (0x00 | 0x10 | 0x0f);
// Wait for the conversion to finish
while ( !ADCIF );
// Get the result
value = ADCL;
value |= ((uint16) ADCH) << 8;
// value now contains measurement of Vdd/3
// 0 indicates 0V and 32767 indicates 1.25V
// voltage = (value*3*1.25)/32767 volts
// we will multiply by this by 10 to allow units of 0.1 volts
value = value >> 6; // divide first by 2^6
value = (uint16)(value * 34.5);
value = value >> 9; // ...and later by 2^9...to prevent overflow during multiplication
return value;
}
