KrisKasprzak
Well-known member
All,
My elaborate telemetry system is working like a million bucks--most of the time. Most times is works w/o any issues but on occasion it will lock up, but I have not way to test, debug or reproduce. My loop displays measured data every second, saves to SD, and a few other things.
I'm thinking a watchdog timer will do the trick. If code stops running, hopefully the WDT will restart the whole thing. I found this code
The code implemented in setup and loop work fine, if I comment out the code in the loop, my Teensy 3.2 will restart -- this *may* simulate a lock up since the WDT is not getting reset.
I would like to simulate a real lockup to see if this code actually restarts, Anyone know how to lock up a Teensy 3.2? Maybe by accessing some null pointer, divide by zero, something?
Thanks in advance.
Kris
My elaborate telemetry system is working like a million bucks--most of the time. Most times is works w/o any issues but on occasion it will lock up, but I have not way to test, debug or reproduce. My loop displays measured data every second, saves to SD, and a few other things.
I'm thinking a watchdog timer will do the trick. If code stops running, hopefully the WDT will restart the whole thing. I found this code
Code:
in setup
// Setup WDT
noInterrupts(); // don't allow interrupts while setting up WDOG
WDOG_UNLOCK = WDOG_UNLOCK_SEQ1; // unlock access to WDOG registers
WDOG_UNLOCK = WDOG_UNLOCK_SEQ2;
delayMicroseconds(1); // Need to wait a bit..
// for this demo, we will use 1 second WDT timeout (e.g. you must reset it in < 1 sec or a boot occurs)
//7.2mhz will require WDT reset < 1 second
//WDOG_TOVALH = 0x006d;
//WDOG_TOVALL = 0xdd00;
// Kris I want make timer to reboot over 1 second, maybe this is the correct way to do this
WDOG_TOVALH = 0x0098;
WDOG_TOVALL = 0x9680;
// This sets prescale clock so that the watchdog timer ticks at 7.2MHz
// Kris, no clue what this is but leaving it alone
WDOG_PRESC = 0x400;
// Set options to enable WDT. You must always do this as a SINGLE write to WDOG_CTRLH
WDOG_STCTRLH |= WDOG_STCTRLH_ALLOWUPDATE |
WDOG_STCTRLH_WDOGEN | WDOG_STCTRLH_WAITEN |
WDOG_STCTRLH_STOPEN | WDOG_STCTRLH_CLKSRC;
interrupts();
in my loop
if ((CurrentTime - UpdateTime) >= Update ) {
noInterrupts(); // No - reset WDT
// kris not sure what this does but it actually works just fine
WDOG_REFRESH = 0xA602;
WDOG_REFRESH = 0xB480;
interrupts();
...
}
The code implemented in setup and loop work fine, if I comment out the code in the loop, my Teensy 3.2 will restart -- this *may* simulate a lock up since the WDT is not getting reset.
I would like to simulate a real lockup to see if this code actually restarts, Anyone know how to lock up a Teensy 3.2? Maybe by accessing some null pointer, divide by zero, something?
Thanks in advance.
Kris