cancel
Showing results for 
Search instead for 
Did you mean: 

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

freeflyer
Senior

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 ?

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Super User

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.

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

4 REPLIES 4
KnarfB
Super User

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

hth

KnarfB

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"

TDK
Super User

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.

If you feel a post has answered your question, please click "Accept as Solution".