Skip to main content
Associate
May 28, 2025
Question

STM32L4S5VIT6 STOP2 Mode Wake-Up Issue in Release

  • May 28, 2025
  • 1 reply
  • 336 views

Hello STM32 Community,

I'm working with the STM32L4S5VIT6 microcontroller and implementing low power functionality using STOP2 mode.

 Setup Summary:

  • I use a GPIO button (external interrupt) to enter STOP2 mode on the first press.

  • On the second press, I attempt to wake up the MCU and call low_power_off() to reinitialize peripherals and resume operation.

  • I’m using MSI as the system clock (no PLL), and STOP2 mode is entered with HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);.

Behavior in Debug Mode:

  • Everything works as expected:

    • First button press → enters STOP2 via low_power_on().

    • Second press → wakes up and executes low_power_off() successfully.

 Problem in Release Mode:

  • First button press → MCU enters STOP2 mode.

  • Second button press does not wake up the MCU as expected.

  • It seems the EXTI interrupt is not firing in release mode, or the wakeup source isn't triggering properly.

 What I've Checked:

  • EXTI configuration seems correct.

  • Wakeup pin is properly pulled up, and configured for falling edge.

  • SystemClock_Config() runs correctly on wakeup and reinitializes MSI.

  • __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU); and __HAL_GPIO_EXTI_CLEAR_IT() are used before STOP2.

  • Wakeup_Button_Init() is called both before entering STOP2 and after wakeup.

Please review my attached main.c code (which includes low_power_on() and low_power_off() logic).
Is there anything I might be missing or doing incorrectly that's causing this issue in Release Mode only?

Any suggestions to improve reliability or correctness of wakeup logic are very welcome.

Thank you!

1 reply

ST Employee
May 28, 2025

Hello @Gohil

Could you check the compiler optimizations, as the issue might be related to how the code is optimized in release mode compared to debug mode.

Check this related thread