Skip to main content
Graduate II
July 15, 2025
Solved

Nucleo-L433RC-P wake up from shutdown - wakes even though the switch is not pressed

  • July 15, 2025
  • 2 replies
  • 345 views

I am trying to get shutdown and wakeup working using the blue top switch on the Nucleo-L433RC-P board.

I have set GPIO pin PC13 to SYS_WKUP2...

freeflyer_0-1752604348820.png

Below is my code...

HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN2);

while (1) {
status = HAL_GPIO_ReadPin(GPIOC, PWR_SWITCH_Pin);

if(status)
{
HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN2);
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN2);
HAL_Delay(1000);
HAL_PWREx_EnterSHUTDOWNMode();
}
}

 

When I press the button, it goes into shutdown correctly.

However, as soon as its shutdown it wakes back up again (even though the button has not been pressed).

Why is this happening and how do I resolve it ?

    This topic has been closed for replies.
    Best answer by TDK

    Probably should put the delay before you clear the flag. If not debounced, the flag is certainly getting set immediately after you clear it and/or when button is released.

    2 replies

    Super User
    July 15, 2025

    Did you suspend the SysTick? Here are some tips: Tips for using STM32 low-power modes - STMicroelectronics Community

    hth

    KnarfB

    freeflyerAuthor
    Graduate II
    July 15, 2025

    No I dont suspend the SysTick.

    In the link you sent, it only mentions suspending the SysTick for sleep and stop modes, not for shutdown which I am using....

    "For sleep and stop modes, you want to suspend the SysTick system timer before entering the low power mode"

    Super User
    July 15, 2025
    TDKAnswer
    Super User
    July 16, 2025

    Probably should put the delay before you clear the flag. If not debounced, the flag is certainly getting set immediately after you clear it and/or when button is released.