cancel
Showing results for 
Search instead for 
Did you mean: 

Detecting exit from shutdown mode on stm32l432

Geoffrey1
Associate III
Posted on August 23, 2017 at 23:50

Is there a way to detect when an stm32l432 has been woken from shutdown mode ?  For standby mode there's a bit in PWR_SR1, but I don't see anything equivalent for Shutdown mode.

Geoffrey

5 REPLIES 5
Geoffrey1
Associate III
Posted on August 27, 2017 at 01:55

ok.  No answer from the group.  The reference manual is particularly vague about what happens to the following key registers when returning from shutdown (via a wakeup source and not NRST):

RCC->CSR

PWR->SR1

It appears, from an actual experiment,  that for the case when wakeup is driven by one of the wakeup pins, RCC->CSR does not have one of the reset sources set.  Further, it appears that PWR_SR1_SBF is set, although the reference manual states that only occurs for standby.    If anybody has experiential knowledge about this, I would really like to hear.

Szymon PANECKI
Senior III
Posted on August 27, 2017 at 10:57

Hello Geoffrey,

For shutdown mode, when wake up source is a wake up pin, you can simply check wake up pin flag to detect that MCU has been woken up, for example like this:

if(__HAL_PWR_GET_FLAG(PWR_FLAG_WUF1) != RESET)

{

//if we are here, it means that MCU woke up from shutdown

__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WUF1);

}

Some flags, which can help you to work with waking up from low-power modes you can find in stm32l4xx_hal_pwr_ex.h file:

0690X000006080rQAA.png

I know it is not a direct answer to your question, but maybe this hint can help in your case.

Regards

Szymon
Uwe Bonnes
Principal III
Posted on August 27, 2017 at 14:31

So the real question is: Is PWR_SR1 reset with exit of shutdown mode?

Posted on August 27, 2017 at 13:33

Thanks for the input, but unfortunately your suggestion only tells one that the wakeup source is active, not that the processor awoke because of it or how it awoke.  

Perhaps I should have been clearer.   I have 'working' code and I use all of the various flags available through RCC->CSR and PWR->SR1.  However, from my message above, it's clear that the reference manual is both ambiguous and even possibly a bit misleading about the conditions under which those flags are set.   I'd really like a clearer specification of their behavior.   Statements like :

'The Shutdown mode is exit according Section : Exiting low power mode. A power-on reset occurs when exiting from Shutdown mode. All registers (except for the ones in the Backup domain) are reset after wakeup from Shutdown.'

from the reference manual suggest that exiting shutdown is just like a power-on reset, but it's clear from my experience that it isn't.  It's also not clear what happens to the PWR->CSR and RCC->SR1 registers.

The STM32L0 reference manual is a bit less ambiguous on standby mode :

'After waking up from Standby mode, program execution restarts in the same way as after a Reset (boot pins sampling, vector reset is fetched, etc.). The SBF status flag in the PWR_CSR register (see Section 6.4.2) indicates that the MCU was in Standby mode.'

This isn't a trivial issue if one is going to use the low power modes correctly.

Posted on August 27, 2017 at 16:45

That would not be a full answer.   A full answer would include:

After shutdown:  the contents of  PWR_SR1 and RCC_CSR for the various ways one might exit shutdown including

wakeup signal and pin reset.

It would be helpful to also have the same information for standby.

The reference manual is poorly written in this area.   I can answer the question experimentally for a specific chip, but that is not the same as a specification from ST on what is defined for all STM32L4 chips.   The problem with an experimental answer is that it presumes that things won't change even across revisions of the same part which is a very dangerous way to write code.