cancel
Showing results for 
Search instead for 
Did you mean: 

STM32C031C6: Determine the wakeup source from shutdown mode

ouss_mans
Associate II

Hello, 

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 : 
 
ouss_mans_0-1719304400733.png

 

 

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 :
 
 ouss_mans_1-1719304400736.png

 

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

Hello,
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

ouss_mans
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.