Skip to main content
Graduate
November 22, 2024
Question

ADC generates power consumption after stm32L4 enters stop mode

  • November 22, 2024
  • 1 reply
  • 1146 views

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;
}

 

    This topic has been closed for replies.

    1 reply

    ST Employee
    November 25, 2024

    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

    AlfRomeoAuthor
    Graduate
    November 26, 2024

    I did not use the HAL_ADC_MspInit() function, I directly used HAL_ADC_DeInit (&hadc1);

    ST Employee
    November 26, 2024

    Hello @AlfRomeo,

    Could you try to Implement the HAL_ADC_MspDeInit() function: it frees the hardware resources used:

    • Disable the Peripheral's clock
    • Revert GPIO to their default state

    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