Hi, I am using Arduino MKR1500 and I am running a watchdog timer. This is just a simple test code I am running(using the code from here). When I run the modified code
#include <WDTZero.h>
WDTZero MyWatchDoggy; // Define WDT
void setup() {
int t = 20; //Initialize serial and wait for port to open, max 10 seconds
Serial.begin(9600);
while (!Serial) {
delay(500);
if ( (t--) == 0 ) break;
}
Serial.print("\nWDTZero-Demo : Setup Soft Watchdog at 32S interval");
MyWatchDoggy.attachShutdown(myshutdown);
MyWatchDoggy.setup(WDT_SOFTCYCLE32S); // initialize WDT-softcounter refesh cycle on 32sec interval
}
void loop() {
unsigned int t = 0;
Serial.print("\nWatchdog Test1 - run 60 seconds with a WDT.clear()\n");
for (t = 1; t < 60; ++t) {
MyWatchDoggy.clear(); // refresh wdt - before it loops
delay(950);
Serial.print(t);Serial.print(".");
}
Serial.print("\n\nWatchdog Test2 - Free run wait for reset @32s\n");
for (t = 1; t > 0; ++t) {
delay(950);
Serial.print(t);Serial.print(".");
}
Serial.print("\nYou will never read this line");
}
void myshutdown()
{
Serial.print("\nWe gonna shut down ! ...");
NVIC_SystemReset();
}
The code shows the following output:
11:40:54.794 -> WDTZero-Demo : Setup Soft Watchdog at 32S interval
11:40:54.794 -> Watchdog Test1 - run 60 seconds with a WDT.clear()
11:40:55.724 -> 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.48.49.50.51.52.53.54.55.56.57.58.59.
11:41:51.064 ->
11:41:51.064 -> Watchdog Test2 - Free run wait for reset @32s
11:41:52.003 -> 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.
11:42:22.285 -> We gonna shut down ! ...
After that the I hear the USB disconnect and connect sound(ensuring the Arduino reset) but after that the code never starts running again and the serial monitor is blank. How do I make it keep counting down and then reset itself after the timer ends and I can see in the serial monitor that counter again?