PRIVATE void readbattery_adc()
{ uint16 u16batv;
uint16 u16adc;
vAHI_ApConfigure(E_AHI_AP_REGULATOR_ENABLE,//使能转换
E_AHI_AP_INT_DISABLE,//使能中断
E_AHI_AP_SAMPLE_2,//采样周期倍数2x
E_AHI_AP_CLOCKDIV_500KHZ,//时钟分比
E_AHI_AP_INTREF//内部参考电压
);
bAHI_APRegulatorEnabled();
vAHI_AdcEnable(E_AHI_ADC_CONTINUOUS,
E_AHI_AP_INPUT_RANGE_2,
E_AHI_ADC_SRC_VOLT
);
vAHI_AdcStartSample();
while( bAHI_AdcPoll()!=0x00)
{
u16batv=u16AHI_AdcRead();
}
u16adc=((uint32)(uint32)(u16batv*234))/1000;
vAHI_AdcDisable();
}
湖上湖
相关分类