Showing results for 
Search instead for 
Did you mean: 

STM32C031C6: Determine the wakeup source from shutdown mode

Associate II


I'm trying to determine the source of the wakeup flag, whether it's the power being turned on or the trigger of wakeup pin 2.

So this is my shutdown function:

After i changed my shutdown function : 



when I try to determine the reason for the wakeup, the register `PWR->SR1` is always 0 when I turn the power on and when I trigger wakeup pin 2.
 Is the `PWR->SR1` register reset after waking up from shutdown mode ?
I tried something just for testing : 
I enabled the wakeup pin in low polarity before checking the register. So, when I trigger the wakeup pin, the `PWR->SR1` is 0, and when I power on the device, it is 2. With this, I can determine the wakeup source, but I don't think it's a good solution :


Can you please give us some feedback about this issue ?
Thank you in advance.
ST Employee

Please find attached the example PWR_STANDBY on NUCLEO-C031C6 can help you, this example works on wake-up the system in pressing the User push-button which is connected to the wake-up pin PWR_WAKEUP_PIN2

Associate II

Hello @Elhem_ZAY ,

in this example, they check the register for standby mode first, but it's not the same case for shutdown.

For me, the wakeup flag is always zero when I press the button (When the debug is disabled), whereas in debug mode, I receive pwr->SR1 = 258 when I press the button.