LPC55S16 Watchdog Fires in Debugger

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC55S16 Watchdog Fires in Debugger

423 Views
JK_265
Contributor III

Using LPC55S16 with IAR and I-jet.  Recently added a watchdog to the code (RELEASE build). 

It works fine, except for one issue.  When I download the code via the I-jet and attempt to debug, the watchdog continues to run when I pause the debugger, and ultimately resets the micro.

The watchdod MOD register has a value of 0x03, so it is not protected.

The watchdog config used during init is:
const wwdt_config_t WWDT_config = {
.enableWwdt = true,
.enableWatchdogReset = true,
.enableWatchdogProtect = false,
.windowValue = WWDT_WINDOW,
.timeoutValue = WWDT_TIMEOUT,
.warningValue = WWDT_WARNING,
.clockFreq_Hz = 250000
};

I have also confirmed that the I-jet option for "Leave Target Running" is disabled.

What is causing this?

Thanks!

0 Kudos
Reply
3 Replies

397 Views
HangZhang
NXP Employee
NXP Employee

Hi @JK_265 

When debugging with a watchdog timer enabled, the watchdog will continue to run even when the code execution is paused. This can cause the watchdog to reset the microcontroller. To handle this situation, you can use the following approaches:
1. Temporarily Disable the Watchdog During Debugging:
Modify your code to disable the watchdog when a debug session is detected. You can do this by checking if a debugger is connected and then disabling the watchdog accordingly. 

2. Feed the Watchdog in a Debug Hook:
Set up a debug hook to periodically feed the watchdog during debugging. This ensures that the watchdog is not triggered while you are stepping through the code or have the execution paused.

Hope this will help you.

BR

Hang

0 Kudos
Reply

384 Views
JK_265
Contributor III

Thanks for the information.  Do you have an example or app note on option #2?

I really don't understand why this would be permitted to happen.  Surely no other timers are running when the debugger is paused?  I don't recall having to do anything special like this when working with the K64.

Thanks.

0 Kudos
Reply

345 Views
HangZhang
NXP Employee
NXP Employee

Hi @JK_265 

Sorry, i don't have an example or app note on option #2.

You can also try to  add code to disable the watchdog timer at the beginning of your main loop when a debugger is connected. For example:
#ifdef DEBUG
// Disable the watchdog timer if in debug mode
WWDT->MOD &= ~WWDT_MOD_WDEN_MASK;
#endif

BR

Hang

0 Kudos
Reply