cancel
Showing results for 
Search instead for 
Did you mean: 

Does STM32 have registers to determine the restart type?

*于.1
Associate II

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?

5 REPLIES 5
  /* 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 Up vote any posts that you find helpful, it shows what's working..

????

TDK
Guru

> 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
Associate II

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
Guru

There are also flags in PWR_CSR.

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