Carlrey_23
New member
I created a simple Watchdog timer program but Serial.begin interferes with its operation.
When I run with the "Serial Monitor" window open, it runs fine. When its closed, it does not.
I need it run under both conditions.
I am using a Teensy-LC board.
I am posting the code here to see if someone can help.
#define LOOP_DELAYS 500
extern "C" void startup_early_hook(void);
void startup_early_hook(void) {
SIM_COPC = 0x0C; // 1024 ms
//SIM_COPC = 0x08; // 256 ms
//SIM_COPC = 0x04; // 32 ms
}
void watchdog_reset() {
SIM_SRVCOP = 0x55;
SIM_SRVCOP = 0xAA;
}
void setup()
{
pinMode(13, OUTPUT);
// Calling Serial.begin causes the Watchdog timer to reset continuously
// However, if it's run with the "Serial Monitor" Window open, it runs fine.!!!
// I need the watchdog timer to run with the serial port active and with the "Serial Monitor" window closed or open.
// What's missing???
Serial.begin(57600);
}
void loop() {
watchdog_reset();
digitalWrite(13,HIGH);
delay(LOOP_DELAYS);
digitalWrite(13,LOW);
delay(LOOP_DELAYS);
}
When I run with the "Serial Monitor" window open, it runs fine. When its closed, it does not.
I need it run under both conditions.
I am using a Teensy-LC board.
I am posting the code here to see if someone can help.
#define LOOP_DELAYS 500
extern "C" void startup_early_hook(void);
void startup_early_hook(void) {
SIM_COPC = 0x0C; // 1024 ms
//SIM_COPC = 0x08; // 256 ms
//SIM_COPC = 0x04; // 32 ms
}
void watchdog_reset() {
SIM_SRVCOP = 0x55;
SIM_SRVCOP = 0xAA;
}
void setup()
{
pinMode(13, OUTPUT);
// Calling Serial.begin causes the Watchdog timer to reset continuously
// However, if it's run with the "Serial Monitor" Window open, it runs fine.!!!
// I need the watchdog timer to run with the serial port active and with the "Serial Monitor" window closed or open.
// What's missing???
Serial.begin(57600);
}
void loop() {
watchdog_reset();
digitalWrite(13,HIGH);
delay(LOOP_DELAYS);
digitalWrite(13,LOW);
delay(LOOP_DELAYS);
}