Watchdog reset fails on quick repeats - Teensy 3.5

Status
Not open for further replies.
Hi

Teensy 3.5

I'm using the watchdog timer on a project and find issues with the reset failing when the loop function runs quickly, code example as follows:
Code:
void setup() {
  Serial.begin(115200);
  while(!Serial);

  noInterrupts();
  WDOG_UNLOCK = WDOG_UNLOCK_SEQ1;
  WDOG_UNLOCK = WDOG_UNLOCK_SEQ2;
  delayMicroseconds(1);
  WDOG_STCTRLH = WDOG_STCTRLH_WDOGEN;
  WDOG_TOVALH = 0;
  WDOG_TOVALL = 10000;
  WDOG_PRESC = 0;
  interrupts();
}

void loop() {
  noInterrupts();
  WDOG_REFRESH = 0xA602;
  WDOG_REFRESH = 0xB480;
  interrupts();

  Serial.println(WDOG_RSTCNT);
  delayMicroseconds(400);
}
The serial monitor reports the restart count due to watchdog timeouts - it will increment every 10 seconds as WDOG_TOVALL is set to 10000 (watchdog clock is 1khz).

I have found that to get this working I need to put a guard around the reset as follows:
Code:
  if(WDOG_TMROUTL > 1)
  {
    noInterrupts();
    WDOG_REFRESH = 0xA602;
    WDOG_REFRESH = 0xB480;
    interrupts();
  }
Not sure this is right - any help welcomed.
 
Last edited:
Feeding the dog too fast is as bad as not feeding it in time. It seems a delay is required, and noted in the linked thread.
* update: I must have been Kicking the dog too quickly. Added in conditions for limiting how quickly I could kick the dog and everything works fine. I'll make a little guide for anyone who needs to use a watchdog timer with the Teensy 3.1/3.0 soon.

This repository has library for watchdog - though readme is sparse the examples show usage:
github.com/tonton81/WDT_T4

@luni - is there enough info around to make an appropriate WATCHDOG entry in github.com/TeensyUser/doc/wiki
 
Status
Not open for further replies.
Back
Top