cancel
Showing results for 
Search instead for 
Did you mean: 

How to detect STM32F417 MCU reset source

New.Fish
Associate III

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.

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

> 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.

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

View solution in original post

3 REPLIES 3
TDK
Guru

Read the RCC->CSR register.

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

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
Guru

> 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.

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