cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L476 Shutdown issue

anthony23
Associate
Posted on October 04, 2017 at 10:59

Hi,

I am working on a battery powered unit that I want to shutdown when I press the off button and wake-up when I press the on button. Having never done this before I have been following the Cube example code for the Nucleo board. The shutdown appears to work but it automatically starts up again. If I remove the HAL_PWR_EnableWakeUpPin() line in my shutdown routine then it remains in the shutdown state but of course I am unable to wake it up. Can anyone provide an explanation as to why the unit is automatically waking-up?

3 REPLIES 3
Posted on October 04, 2017 at 15:19

Hello !

0690X00000608ToQAI.png

Just before you put device in shutdown mode there are some bits must cleared in Power status clear register (PWR_SCR) from all wakeup sources.

Relevant HAL functions do not clear theese bits automaticaly

You can clear theese bits by calling __HAL_PWR_CLEAR_FLAG(..) macro

Regards

vf

Posted on October 04, 2017 at 15:59

Hi,

Thanks for the response. I tried clearing down all the flags and I checked the Power status register and there are no flags set but it still automatically starts up after calling HAL_PWREx_EnterSHUTDOWNMode(). Do I need to stop all peripherals running e.g. ADC, System tick, etc?

Regards,

Tony

Posted on May 02, 2018 at 17:40

The PWR_SR1 doesn't work in shutdown mode, this means that it's always 0. I suggest you to debug your code using the Standby mode in order to look at the SR1 and try to understand which sources is wakeing up your device.

To solve a problem similiar to yours, I cleared the WUP source in both standby and shutdown mode writing 0x11F in the PWR_SCR register as the last instruction before entering the shutdown state.

I think that after setting up the PWR register to wake on some source the processor starts detecting them immediatly, it doesn't wait for the WFE/WFI instruction. For this reason if something happen between your set up and the WFI/WFE call, the processor wakes up immediatly. I haven't find this behaviour described in the reference manual, is just some guess I made.