FR801XH的内部电池电压直接获取
-
{
struct adc_cfg_t cfg; uint16_t result, ref_vol,vbat_vol; memset((void*)&cfg, 0, sizeof(cfg)); cfg.src = ADC_TRANS_SOURCE_VBAT; cfg.ref_sel = ADC_REFERENCE_INTERNAL; cfg.int_ref_cfg = ADC_INTERNAL_REF_1_2; cfg.clk_sel = ADC_SAMPLE_CLK_24M_DIV13; cfg.clk_div = 0x3f; adc_init(&cfg); adc_enable(NULL, NULL, 0); adc_get_result(ADC_TRANS_SOURCE_VBAT, 0, &result); ref_vol = adc_get_ref_voltage(ADC_REFERENCE_INTERNAL); vbat_vol = (result * 4 * ref_vol) / 1024; sprintf((char *)LCD_ShowStringBuff,"Batt_V = %d mV",vbat_vol); LCD_ShowString(20,200,LCD_ShowStringBuff,BRRED);
}