cancel
Showing results for 
Search instead for 
Did you mean: 

how to find the reason when watchdog reset happens

roseanne qiu
Associate II

Dear Sir/Madam:

I have a problem and would need your help.

when I write a watchdog like the following:

void init()

{

..

 SystemClock_Config();

 /*######## Configure watchdog timer ############################*/

 // Watchdog clock is LSI, runs at 32kHz. The below settings give

 // a max watchdog period of 4 sec before reset.

 WDHandle.Instance = IWDG;

 WDHandle.Init.Prescaler = IWDG_PRESCALER_256;

 WDHandle.Init.Reload = 511; 

 HAL_IWDG_Init(&WDHandle);

 HAL_IWDG_Start(&WDHandle);

}

in the main loop function

int main()

{

...

while(1)

{

HAL_IWDG_Refresh(&WDHandle);

func1();

func2();

....

}// while

}

sometimes, whatdog reset happen, I do not know which func cause the watchdog problem.

my question is:

  1. whether am I correct for the usage of watchdog?
  2. how could I find which one cause watchdog reset?
  3. is there any watchdog interrupt, once the watchdog reset, this interrupt routine give/print some cause before the system reset?

thanks for your help

roseanne

1 ACCEPTED SOLUTION

Accepted Solutions

You did not care to tell us your mcu model, but if it has a WWDG you can use that instead of IWDG (with the respective changes of course); WWDG does have an Early Warning Interrupt.

Another approach is to replace the watchdog by a timer, for debugging purposes.

JW

View solution in original post

3 REPLIES 3

You'd need to provide instrumentation/telemetry to understand the flow of your code and why it didn't kick the watchdog. You can either output, or record, checkpoint information, and process that post reset.

You should be able to pull the reset cause (ie watchdog, standby) but not the what/where of your code.

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

You did not care to tell us your mcu model, but if it has a WWDG you can use that instead of IWDG (with the respective changes of course); WWDG does have an Early Warning Interrupt.

Another approach is to replace the watchdog by a timer, for debugging purposes.

JW

roseanne qiu
Associate II

thanks for your answers!

I may try to need use timer or IWDG

thanks

roseanne