ATSAMD21 Watchdog on Oyssey using PlatformIO

Has anyone had any success getting the HW Watchdog on the Odyssey working under PlatformIO?

I saw some examples for the ATSAMD21 but they won’t compile under PlatformIO under VSCode

Thanks

Can you share an example? Maybe I can help you.

Hi,

I’m using the SAMCrashMonitor library. I can get the watchdog to trigger a shutdown but the Arduino does not reset. I would also like to redirect the watchdog to call a custom SystemPanic function before the reset. I can do this in the ESP32 platform but need help in the AmtelSam platform.

Thanks


#include <Arduino.h>

#include "SAMCrashMonitor.h"


void setup() {
  // put your setup code here, to run once:
    SerialUSB.begin(9600);
    while(!SerialUSB);
    
    SerialUSB.println();
    SAMCrashMonitor::begin();
    SAMCrashMonitor::dump();
    SerialUSB.println();
    
    SerialUSB.println(F("Enabling watchdog."));
    int timeout = SAMCrashMonitor::enableWatchdog(4000);
    SerialUSB.print(F("Watchdog enabled for "));
    SerialUSB.print(timeout);
    SerialUSB.println(" ms.");
    
}

void loop() {
  // put your main code here, to run repeatedly:

  Serial.println("1st Test");
  SAMCrashMonitor::iAmAlive();

  delay(3500);

  Serial.println("2nd Test");
  SAMCrashMonitor::iAmAlive();

  delay(10000);

  Serial.println("Shouldnt get here"); 


}

ESP32 and SAMD21 are two completely different architectures.I’m not sure if it can do it.

Accorgind to the specifications on the Seeed website the Amtel D21 has a watchdog. Doesnt do me any good if I can’t use it under PlatformIO

Your program works under “PlatformIO in Atom”.
In your loop I had to change Serial.println (…) to
SerialUSB.println (…).


=========================================

Reset reason: 1, Normal power-on reset
=========================================

Enabling watchdog.
Watchdog enabled for 4000 ms.
1st Test
2nd Test

=========================================

Reset reason: 32, Reset requested by Watchdog
=========================================

Enabling watchdog.
Watchdog enabled for 4000 ms.
1st Test
2nd Test

=========================================

Reset reason: 32, Reset requested by Watchdog
=========================================

Enabling watchdog.
Watchdog enabled for 4000 ms.
1st Test
2nd Test

=========================================

Reset reason: 32, Reset requested by Watchdog
=========================================

Enabling watchdog.
Watchdog enabled for 4000 ms.
1st Test
2nd Test

=========================================

Reset reason: 32, Reset requested by Watchdog
=========================================

Enabling watchdog.
Watchdog enabled for 4000 ms.
1st Test

Thanks for checking.

On the Odyssey board the system triggers the watchdog once and does not restart. So there is something wrong with the restart sequence on the board. I’m hoping that @ansonhe97 from Seeed can figure out what is going on

Hi Mark,

I have just ran a quick test and it did restart. My thought is that under Windows the COM port is not auto choosing the COM again. So if you open the Serial monitor again, you can see the code is actually still going

@ansonhe97. I’m running vas and platformio directly on the odyssey. The port disappears from /dev until I restart the IDE. So it is NOT still running in the background. I can show you during the call today

Thx

I see, will talk later then :smiley: