问题:我想使用P0_4作为电压检测引脚,检测2530芯片自身的供电电压,请问我以下的步骤是否正确?
#define HAL_ADC TRUE
void read_voltage( void ) { uint16 voltage = 0; P0SEL |= BV(4); P0DIR &= ~BV(4); HalAdcInit(); //adcRef = HAL_ADC_REF_VOLT; voltage = HalAdcRead( HAL_ADC_CHANNEL_4, HAL_ADC_RESOLUTION_14 ); printf( "voltage is %d %d\r\n", HI_UINT16[voltage], LO_UINT16[voltage]); }
得出的打印值为 0x0F,0xFF;用万用表测出的电压值为2.9v。请问是哪里出了问题?