Page 1 of 1

Get Program Counter after WatchDog reset

Posted: Mon Jan 20, 2020 7:14 pm
by Comiter
Hi!
I have a black F407 board running pretty stable. However, every now and then the watchdog kicks in and re-sets the board.
I know this as I have a SD card attached where debug info is stored, and I do check IWatchdog.isReset() to detect if re-set was caused by watchdog.

On the good old Arduinos, there is this great tutorial over at Megunolink on how to store the value of the program counter during a watchdog re-set:
https://www.megunolink.com/articles/how ... -watchdog/

However, I'm not able to figure out how to attach an ISR on the IWatchdog to complete the same, or if there exist some other way to extract the Program counter during or right after a watchdog event. Do anybody in here know how to complete this?

BR
Comiter

Re: Get Program Counter after WatchDog reset

Posted: Wed Jan 22, 2020 10:11 am
by fpiSTM
Hi comiter

I don't think the IWDG can do this. You can specify to stop in debug mode but that's all.
When the IWDG fire then it enter in reset.
The WWDG should be able to save the PC in a backup register thanks the WWDG_IRQn handler but you have to implement it yourself as there is no Arduino library to mange it.

Re: Get Program Counter after WatchDog reset

Posted: Wed Jan 22, 2020 6:36 pm
by Comiter
HI fpiSTM,
thank you for the reply. Then I'll see if I can manage to use the WWDG. I see there are HAL support for it, maybe I can figure out to use or re-use part of that code.

BR
Comiter

Re: Get Program Counter after WatchDog reset

Posted: Wed Jan 22, 2020 9:42 pm
by Squonk42
Hi comiter,

What I used on some other (EFM32GG) MCUs lacking a pre-reset watchdog IRQ is to setup a software watchdog using a standard timer to trigger before the hardware watchdog, so you can find out where the code is spending time.