2024-11-21 10:57 PM
I use STM32L431 to enter STOP1 mode, the original power consumption is 53uA. Before entering stop mode, I call HAL_ADC_DeInit(&hadc1) to disable ADC, and call MX_ADC1_Init() to re-enable ADC after exiting STOP1 mode. The measured power consumption is 66uA, which is about 10uA more. Why? If I do not call MX_ADC1_Init() after exiting STOP1 mode, the power consumption is still 53uA. Is it because ADC will generate power consumption?
Below is my code to enter and exit STOP1:
void EnterStop2ModeRTC(void)
{
HAL_RCCEx_WakeUpStopCLKConfig(RCC_STOP_WAKEUPCLOCK_MSI);
__HAL_RCC_PWR_CLK_ENABLE();
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
__HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(&hrtc, RTC_FLAG_WUTF);
__HAL_RTC_WAKEUPTIMER_EXTI_CLEAR_FLAG();
__HAL_RTC_TIMESTAMP_CLEAR_FLAG(&hrtc, RTC_FLAG_TSF);
__HAL_RTC_TAMPER_TIMESTAMP_EXTI_CLEAR_FLAG();
HAL_ADC_DeInit(&hadc1);
HAL_SuspendTick();
// __HAL_RCC_DMA1_CLK_DISABLE();
cpuStopFlg = true;
SCB->SCR |= SCB_SCR_SLEEPONEXIT_Msk;
__HAL_RCC_PWR_CLK_ENABLE();
HAL_PWREx_EnterSTOP1Mode(PWR_STOPENTRY_WFI);
}
void ExitStop2ModeRTC(void)
{
SystemClock_Config();
HAL_ResumeTick();
MX_ADC1_Init();
cpuStopFlg = false;
}
2024-11-25 02:00 AM
Hello @AlfRomeo,
HAL_ADC_MspInit() calls typically bus clock activation: __HAL_RCC_ADC_CLK_ENABLE().
Can you check whether you have implemented HAL_ADC_MspDeInit() in your application ?
If yes, does it contain bus clock deactivation: __HAL_RCC_ADC_CLK_DISABLE(); __HAL_RCC_ADC_FORCE_RESET(); __HAL_RCC_ADC_RELEASE_RESET() ?
I hope my answer has helped you. When your question is answered, please select this topic as solution that answered you, it will help others find that answer faster.
Thanks for your contribution.
Dor_RH
2024-11-25 04:05 PM
I did not use the HAL_ADC_MspInit() function, I directly used HAL_ADC_DeInit (&hadc1);
2024-11-26 02:06 AM
Hello @AlfRomeo,
Could you try to Implement the HAL_ADC_MspDeInit() function: it frees the hardware resources used:
I hope my answer has helped you. When your question is answered, please select this topic as solution that answered you, it will help others find that answer faster.
Thanks for your contribution.
Dor_RH
2024-11-26 05:28 PM
I tried it and the ADC works fine, but the power consumption is higher
2024-11-27 01:11 AM - edited 2024-11-27 01:11 AM
Hello @AlfRomeo,
Could you confirm if the HAL_ADC_MspDeInit() function you are using includes the following bus clock deactivation and reset instructions: __HAL_RCC_ADC_CLK_DISABLE(), __HAL_RCC_ADC_FORCE_RESET(), and __HAL_RCC_ADC_RELEASE_RESET()?
Additionally, it might be helpful to review the ADC examples available in the STM32CubeL4 package, as they can provide useful guidance.
I hope my answer has helped you. When your question is answered, please select this topic as solution that answered you, it will help others find that answer faster.
Thanks for your contribution.
Dor_RH