Author Topic: Watchdog Trigger  (Read 4335 times)

Offline Phil

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
Watchdog Trigger
« on: May 25, 2018, 12:35:41 AM »
Is there a configuration setting for the watchdog timer that can be adjusted?

It looks like the watchdog is set to about 1 second.

I'd like to change that to 2 seconds or possibly 3 before a watchdog reset occurs.

I know one can retrigger the watchdog periodically but I am using a library function that prevents me from initiating a retrigger within another person's code.

Another option might be to disable the watchdog while the function is performed then re-enable the watchdog afterward. This would be good to know as well.

Thank you.

Phil

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: Watchdog Trigger
« Reply #1 on: May 26, 2018, 01:42:12 AM »
Hi Phil

Look for the definition of ACTIVATE_WATCHDOG() (in app_hw_kinetis.h).
An example is:
UNLOCK_WDOG(); WDOG_TOVALL = (2000/5); WDOG_TOVALH = 0; WDOG_STCTRLH = (WDOG_STCTRLH_STNDBYEN | WDOG_STCTRLH_WAITEN | WDOG_STCTRLH_STOPEN | WDOG_STCTRLH_WDOGEN | WDOG_STCTRLH_ALLOWUPDATE) // watchdog enabled to generate reset on 2s timeout (further updates allowed)

Here the timeout is set to 2s (the 2000/5 - or 2000ms/5, where the /5 is due to the watchdog timer's clock to convert to seconds).
The sequence with the unlock at the beginning can be repeated (with different settings) as long as WDOG_STCTRLH_ALLOWUPDATE is set. Once WDOG_STCTRLH_ALLOWUPDATE is removed it will be locked so no further changes (nor stopping) are allowed.

The watchdog can also be disabled by removing WDOG_STCTRLH_WDOGEN.

Regards

Mark

P.S. This is for most K parts - KL parts tend to have a different watchdog as do KE parts but the method used should be evident from their corresponding macros.


Offline Phil

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
Re: Watchdog Trigger
« Reply #2 on: May 26, 2018, 03:18:00 PM »
Great info.

Thanks, Mark!