Get Program Counter after WatchDog reset

Post here first, or if you can't find a relevant section!
Post Reply
Comiter
Posts: 3
Joined: Mon Dec 30, 2019 10:28 pm

Get Program Counter after WatchDog reset

Post 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
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Get Program Counter after WatchDog reset

Post 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.
Comiter
Posts: 3
Joined: Mon Dec 30, 2019 10:28 pm

Re: Get Program Counter after WatchDog reset

Post 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
Squonk42
Posts: 16
Joined: Sat Dec 21, 2019 8:35 am

Re: Get Program Counter after WatchDog reset

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

Return to “General discussion”