Author Topic: How to identify code that causes a SW watchdog reset  (Read 1633 times)

Offline FAQ

  • Newbie
  • *
  • Posts: 27
    • View Profile
How to identify code that causes a SW watchdog reset
« on: April 29, 2023, 01:43:19 PM »
If I have a project that sometimes causes a SW watchdog reset - but not due to a fault such as a hard fault - how can I catch the cause if the watchdog time itself doesn't support an interrupt?

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: How to identify code that causes a SW watchdog reset
« Reply #1 on: April 29, 2023, 01:45:48 PM »
Hi

If you have code that may take a long time and causes a SW WDOG timeout (but not due to an error, as such) you can increase the watchdog value in (for example the i.MX RT project)

#define ACTIVATE_WATCHDOG()     UNLOCK_WDOG3(); WDOG3_TOVAL = (2 * 32000); WDOG3_WIN = 0; WDOG3_CS = (WDOG_CS_CLK_LPO | WDOG_CS_FLG | WDOG_CS_CMD32EN | WDOG_CS_EN); // enable watchdog with 2s timeout (32kHz reference)

or add re-triggers in the code [fnRetriggerWatchdog()].

To identify the location you can add a HW timer (single-shot that can be re-triggered) configured to a slightly lower timeout than the watchdog timeout.
Add a re-trigger of it to the macro
Code: [Select]
TOGGLE_WATCHDOG_LED()
and set a break point in its interrupt handler.

If this interrupt fires you can look to see which code is executing (step out of the interrupt or look at the call stack).

Regards

Mark