cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4: Catch the last PC address before WD reset

yonatan
Associate II
Posted on September 20, 2016 at 11:20

Hi all.

I am trying to catch the last PC value before WD reset.

For doing that I am configuring the WWDG and enabling its interrupt.

then, while the WD interrupt fire I am writing the important information

(i.e., the PC value before the the exception occurs), in dedicated location,

and then the reset occurs.

I was thinking that the LR register will do for me the job but it seems useless (something like 0xFFFFFFE1).

So I changed my mind back to the old and good - the stack and SP register.

Indeed, I managed to find the last value of PC at address SP + 0x20

1. Is there more convenient way to do that?

2. Does the offset of 0x20 will be consistent?

Thank you very much

Yonatan Sade

#!stm32f4 #iwdg #wwdg #watchdog
1 REPLY 1
Posted on September 20, 2016 at 16:19

The SRAM is preserved, but I don't think there is any behaviour about a RESET here that is defined to carry through. You could track most recent PC seen in say a SysTick, and revisit that to see if it is a loop that the code is stuck in. You could also instrument your code to understand the flow that's causing the watchdog to fire.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..