David Pinball
Member
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:
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:
Not sure this is right - any help welcomed.
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);
}
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();
}
Last edited: