I must be missing something, but a simple WD timer routine that will work on an Arduino fails to cooperate on the Teensy 3.2. Secret sauce please.
Test code is below. Just a quick and slow flashing LED pattern to show me it has reset.
//========================
#include <avr/wdt.h>
#define LED 16
bool flipflop=false;
void setup() {
pinMode(LED, OUTPUT);
digitalWrite(LED, HIGH);
wdt_disable(); // Should kill the timer if it was on before reset.
for(int i=0; i<20; i++){
digitalWrite(LED, LOW); // Pulse a pattern of quick flashes
delay(200);
digitalWrite(LED, HIGH);
delay(200);
}
wdt_enable(WDTO_4S); // Enable for a 4 sec timeout.
delay(1);
wdt_reset(); // Reset just in case.
}
void loop() {
if(flipflop) digitalWrite(LED, HIGH); // Flash slowly here until we reset.
else digitalWrite(LED, LOW);
flipflop=!flipflop;
delay(1000);
}
Test code is below. Just a quick and slow flashing LED pattern to show me it has reset.
//========================
#include <avr/wdt.h>
#define LED 16
bool flipflop=false;
void setup() {
pinMode(LED, OUTPUT);
digitalWrite(LED, HIGH);
wdt_disable(); // Should kill the timer if it was on before reset.
for(int i=0; i<20; i++){
digitalWrite(LED, LOW); // Pulse a pattern of quick flashes
delay(200);
digitalWrite(LED, HIGH);
delay(200);
}
wdt_enable(WDTO_4S); // Enable for a 4 sec timeout.
delay(1);
wdt_reset(); // Reset just in case.
}
void loop() {
if(flipflop) digitalWrite(LED, HIGH); // Flash slowly here until we reset.
else digitalWrite(LED, LOW);
flipflop=!flipflop;
delay(1000);
}