Skip to main content
*于.1
Associate II
January 11, 2021
Question

Does STM32 have registers to determine the restart type?

  • January 11, 2021
  • 5 replies
  • 1136 views

STM32L051C8, use standby mode; exit is equivalent to restart; whether there is a flag bit to determine the type of restart; for example, power-on restart, watchdog restart, low-power wake-up can be distinguished; whether it can distinguish the standby mode that wakes up by which way ? For example, is the wakeup pin interrupt or the RTC clock?

This topic has been closed for replies.

5 replies

Tesla DeLorean
Guru
January 11, 2021
 /* Configure the system Power */
 SystemPower_Config();
 
 /* Check and handle if the system was resumed from Standby mode */
 if(__HAL_PWR_GET_FLAG(PWR_FLAG_SB) != RESET)
 {
 /* Clear Standby flag */
 __HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);
 }
 
 /* Insert 5 seconds delay */
 HAL_Delay(5000);
 
 /*The Following Wakeup sequence is highly recommended prior to each Standby mode entry
 mainly when using more than one wakeup source this is to not miss any wakeup event.
 - Disable all used wakeup sources,
 - Clear all related wakeup flags,
 - Re-enable all used wakeup sources,
 - Enter the Standby mode.
 */
 /*Disable all used wakeup sources: Pin1(PA.0)*/
 HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN1);
 
 /*Clear all related wakeup flags*/
 __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
 
 /*Re-enable all used wakeup sources: Pin1(PA.0)*/
 HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1);
 
 /*Enter the Standby mode*/
 HAL_PWR_EnterSTANDBYMode();

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
*于.1
*于.1Author
Associate II
January 11, 2021

????

TDK
January 11, 2021

> Does STM32 have registers to determine the restart type?

Yes it does. The RCC->CSR register contains flags that show the reset source.

0693W000006I8O1QAK.png

"If you feel a post has answered your question, please click ""Accept as Solution""."
*于.1
*于.1Author
Associate II
January 11, 2021

Thanks for the reply, but the RCC register cannot determine whether it is reset by wakeup pin or RTC interrupt reset. Is there any way to determine whether the way to exit low power consumption is wakeup pin interrupt or RTC?

TDK
January 11, 2021

There are also flags in PWR_CSR.

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