Skip to main content
New.Fish
Associate III
May 27, 2021
Solved

How to detect STM32F417 MCU reset source

  • May 27, 2021
  • 3 replies
  • 1402 views

I try implement a function to detect how the MCU start from, reset from watchdog or hardfault or recycle power.

Watchdog reset, if the code goes to dead loop, it will trigger WD, but I have no good idea how to capture it.

Recycle power, I can use PVD_IRQHandler() interrupt, but I can't find how to configure the PWR_PVD parameter from STMCube .

Hardfault, I can use the HardFault_Hander() interrupt routine, it works for me.

This topic has been closed for replies.
Best answer by TDK

> If code goes to dead loop and trigger reset, it will reset RCC->CSR, in this case can RCC->CSR set IWDGRSTF?

If the IWDG causes the reset, then IWDGRSTF will be set upon reset. Check the flags when your program starts and then clear them by setting the the RMVF bit.

3 replies

TDK
Super User
May 27, 2021

Read the RCC->CSR register.

New.Fish
New.FishAuthor
Associate III
May 27, 2021

RCC->CSR is reset by system reset, IWDG is one of the system reset.

If code goes to dead loop and trigger reset, it will reset RCC->CSR, in this case can RCC->CSR set IWDGRSTF?

TDK
TDKBest answer
Super User
May 27, 2021

> If code goes to dead loop and trigger reset, it will reset RCC->CSR, in this case can RCC->CSR set IWDGRSTF?

If the IWDG causes the reset, then IWDGRSTF will be set upon reset. Check the flags when your program starts and then clear them by setting the the RMVF bit.