Hi,
I've set up the watchdog using startup_early_hook and enabled the ISR with NVIC_ENABLE)_IRQ but the isr still isn't firing, I'm using a teensy 3.6.
There's another thread here https://forum.pjrc.com/threads/41339-Different-Watchdog-timer-ISRs
but the isr problem isn't solved.
Can anyone try this on theirs to replicate the problem?
Find the program below
Thanks,
Rowan
I've set up the watchdog using startup_early_hook and enabled the ISR with NVIC_ENABLE)_IRQ but the isr still isn't firing, I'm using a teensy 3.6.
There's another thread here https://forum.pjrc.com/threads/41339-Different-Watchdog-timer-ISRs
but the isr problem isn't solved.
Can anyone try this on theirs to replicate the problem?
Find the program below
Code:
//taken from https://forum.pjrc.com/threads/25370-Teensy-3-0-Watchdog-Timer
#include <EEPROM.h>
#define RCM_SRS0_WAKEUP 0x01
#define RCM_SRS0_LVD 0x02
#define RCM_SRS0_LOC 0x04
#define RCM_SRS0_LOL 0x08
#define RCM_SRS0_WDOG 0x20
#define RCM_SRS0_PIN 0x40
#define RCM_SRS0_POR 0x80
#define RCM_SRS1_LOCKUP 0x02
#define RCM_SRS1_SW 0x04
#define RCM_SRS1_MDM_AP 0x08
#define RCM_SRS1_SACKERR 0x20
void kickDog() {
Serial.println("Kicking the dog");
noInterrupts();
WDOG_REFRESH = 0xA602;
WDOG_REFRESH = 0xB480;
interrupts();
}
void printResetType() {
if (RCM_SRS1 & RCM_SRS1_SACKERR) Serial.println("[RCM_SRS1] - Stop Mode Acknowledge Error Reset");
if (RCM_SRS1 & RCM_SRS1_MDM_AP) Serial.println("[RCM_SRS1] - MDM-AP Reset");
if (RCM_SRS1 & RCM_SRS1_SW) Serial.println("[RCM_SRS1] - Software Reset");
if (RCM_SRS1 & RCM_SRS1_LOCKUP) Serial.println("[RCM_SRS1] - Core Lockup Event Reset");
if (RCM_SRS0 & RCM_SRS0_POR) Serial.println("[RCM_SRS0] - Power-on Reset");
if (RCM_SRS0 & RCM_SRS0_PIN) Serial.println("[RCM_SRS0] - External Pin Reset");
if (RCM_SRS0 & RCM_SRS0_WDOG) Serial.println("[RCM_SRS0] - Watchdog(COP) Reset");
if (RCM_SRS0 & RCM_SRS0_LOC) Serial.println("[RCM_SRS0] - Loss of External Clock Reset");
if (RCM_SRS0 & RCM_SRS0_LOL) Serial.println("[RCM_SRS0] - Loss of Lock in PLL Reset");
if (RCM_SRS0 & RCM_SRS0_LVD) Serial.println("[RCM_SRS0] - Low-voltage Detect Reset");
}
void watchdog_isr(){
EEPROM.update(1024, 156);
}
#ifdef __cplusplus
extern "C" {
#endif
void startup_early_hook() {
uint16_t toval = 1000;
WDOG_TOVALL = 1000; //Abt a minute
WDOG_TOVALH = 0;
WDOG_STCTRLH = (WDOG_STCTRLH_ALLOWUPDATE | WDOG_STCTRLH_WDOGEN | WDOG_STCTRLH_WAITEN | WDOG_STCTRLH_STOPEN | WDOG_STCTRLH_IRQRSTEN); // Enable WDG
NVIC_ENABLE_IRQ(IRQ_WDOG);
//WDOG_PRESC = 0; // prescaler
}
#ifdef __cplusplus
}
#endif
void setup() {
Serial.begin(9600);
while (!Serial);
while (Serial.available());
Serial.printf("EEPROM 1024 = %u\n", EEPROM.read(1024));
printResetType();
}
uint32_t dogTimer = 0;
void loop() {
if (millis() - dogTimer > 1000){
dogTimer = millis();
kickDog();
}
if (Serial.available()){
int c = Serial.parseInt();
switch(c){
case 150:
Serial.printf("Hang at %lu\n", millis());
kickDog();
while(1);
}
}
}
Thanks,
Rowan