This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

监测CC2530电压值

Other Parts Discussed in Thread: CC2530

我现在需要读取CC2530的电压,我直接读取VDD/3那通道的值,但是读到的值变化好大,不知道是不是配置有问题,请各位帮忙看下,还有就用这个监测当前电压不知道准不准,我这个目的主要是监测给CC2530供电的电池电压,当电压低到一定值就提醒更换电池。监测电池电压的转换公式是:VDD/3=Value *1.15V/256

#define HAL_ADC_REF_115V 0x00
#define HAL_ADC_DEC_256 0x20
#define HAL_ADC_CHN_TEMP 0x0e
#define HAL_ADC_DEC_064 0x00
#define HAL_ADC_CHN_VDD3 0x0f

uint16 Get_Vdd_Value(void)
{
uint16 value;
uint8 tmpADDCON3 = ADCCON3;
ADCIF = 0;
ADCCON3 = (HAL_ADC_REF_115V | HAL_ADC_DEC_064 | HAL_ADC_CHN_VDD3);
while(!ADCIF);
ADCIF = 0;
value = ADCH;
value = (value<<8)|ADCL;
ADCCON3 = tmpADDCON3;
return (value);
}