Watchdog won't reset my program?

airpanther

Active member
Hello,

I have a program that runs well, but becomes unresponsive at random intervals. Sometimes within 4 hours, sometimes within 30 minutes. I'd like to use a watchdog to reset the program when it becomes unresponsive, but for some reason, it isn't working for me on Teensy 4.1 I used the Blink example just to see if the board would reset after 4 seconds, but it never resets. I've also tried adding a while(1) loop to see if the watchdog will trigger, but no luck. Any suggestions?


Code:
#include <avr/wdt.h>

// the setup function runs once when you press reset or power the board
void setup() {

  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
  wdt_enable(WDTO_4S);
   wdt_reset();
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(1000);                      // wait for a second
  digitalWrite(LED_BUILTIN, LOW);   // turn the LED off by making the voltage LOW
  delay(1000);                      // wait for a second
}

Thanks,
Robert
 
Try this WDT @tonton81 designed/tested with the Teensy's 1062 in mind: github.com/tonton81/WDT_T4

Forum search should show development and use if the github examples are insufficient.

Thank you, I will certainly check that out.

Curious though... the AVR library seems really straight forward, so is there something I'm doing wrong, or is it not compatible with Teensy 4.1?

Thanks,
Robert
 
Curious though... the AVR library seems really straight forward, so is there something I'm doing wrong, or is it not compatible with Teensy 4.1?

It's not implemented for Teensy 4, the functions you've used are just #defined to nothing in the header file.
 
Back
Top