本帖最后由 Sam131208 于 2024-4-10 12:02 编辑
HC32L136使用ADC时,测量AVCC电压,选择AdcAVccdiv3Input 通道, 睡眠电流为11uA. 改为AdcExInputCH10 通道测试,睡眠电流为3uA. 请问使用AdcAVccdiv3Input 通道时,如何正确进入睡眠?
void adc_start(void){
stc_adc_cfg_t stcAdcCfg;
///< 开启ADC/BGR 外设时钟
Sysctrl_SetPeripheralGate(SysctrlPeripheralAdcBgr, TRUE);
Bgr_BgrEnable(); ///< 开启BGR
DDL_ZERO_STRUCT(stcAdcCfg);
///< ADC 初始化配置
stcAdcCfg.enAdcMode = AdcSglMode; ///<采样模式-单次
stcAdcCfg.enAdcClkDiv = AdcMskClkDiv2; ///<采样分频-1
stcAdcCfg.enAdcSampCycleSel = AdcMskSampCycle12Clk; ///<采样周期数-12
stcAdcCfg.enAdcRefVolSel = AdcMskRefVolSelInBgr2p5; ///<参考电压选择-内部2.5V
stcAdcCfg.enAdcOpBuf = AdcMskBufDisable; ///<OP BUF配置-关
stcAdcCfg.enInRef = AdcMskInRefEnable; ///<内部参考电压使能-开
stcAdcCfg.enAdcAlign = AdcAlignRight; ///<转换结果对齐方式-右
Adc_Init(&stcAdcCfg);
///< ADC 中断使能
Adc_EnableIrq();
EnableNvic(ADC_IRQn, IrqLevel3, TRUE);
///< ADC 采样通道配置
Adc_CfgSglChannel(AdcAVccdiv3Input); //AdcExInputCH10, AdcAVccdiv3Input
///< 启动单次转换采样
Adc_SGL_Start();
}
void Adc_IRQHandler(void)
{
if(TRUE == Adc_GetIrqStatus(AdcMskIrqSgl))
{
Adc_ClrIrqStatus(AdcMskIrqSgl); ///< 清除中断标志位
mSensor.value = Adc_GetSglResult(); ///< 获取采样值
Adc_SGL_Stop(); ///< ADC 单次转换停止
Adc_Disable();
Bgr_BgrDisable();
Sysctrl_SetPeripheralGate(SysctrlPeripheralAdcBgr, FALSE);
}
}
|