Due watchdog

Is there a possibility to use watchdog with the Due board? According to the release notes from 1.6.5 watchdog should be implemented. However, it does not work.

I'm also quite keen to see an answer on this. I searched the forum and found a couple of references to watchdog solution referring to older version of Arduino where you had to modify the variants.cpp file and stuff like that. But it also does not seem to apply to 1.6.5 anymore and I could also not get watchdog to work on my Due as well.

This his how I’m trying to use it (Note : this does not work)

void setup() {
  WDT_Enable( WDT, 0x2000 | 2048 | ( wdp_ms << 16 ));

void loop()
 Serial.println(waittimer); // numer of loops
 if (waittimer > 10)
 { //after 10 timer, we freeze the code into an infinite loop
     for(;;); //this is a deadlock

Expected behavior : Unit should count 1 to 11 and hen freeze for a while and reboot over and over.
Actual behavior : It just counts 1 to 11 and then sits there indefinetely in a loop. (Watchdog never gets it out of that)

I found a solution for the problem. Watchdog IS implemented in Arduino IDE 1.6.5 but the latest SAM core version in the board manager is 1.6.4. So there is no official watchdog support available yet.

However, if you want to use watchdog for Arduino Due NOW, follow these steps:

  • Download the Arduino nightly build from https://www.arduino.cc/en/Main/Software
  • Install SAM boards in the board manager if not already available
  • Download the 1.6.5 SAM core version from here
  • Extract the file into sketchbook/hardware folder
  • Open Arduino IDE and choose Due board from 'ARM boards PR 3524'
  • Now you can use watchdog. Attention, the syntax has changed!

Thanks @facchinm @bobc https://github.com/arduino/Arduino/issues/3889 https://github.com/arduino/Arduino/pull/3524#issuecomment-136416350 https://github.com/arduino/Arduino/commit/d2c510d16686d16baf97534f1dc93ac949ecac44

Example sketch:

int counter = 0;

// Defines the time for the watchdog in ms
int watchdogTime = 1000;

// this function has to be present, otherwise watchdog won't work
void watchdogSetup(void) 
// do what you want here

void setup() 
  // Enable watchdog.

void loop() 
  // Reset watchdog
  if(counter >= 10)

Thanks you very much @kaddigat for sharing this info and for detailed instructions :)

I can confirm it worked for me too. (I did get all kinds of weird compiler warnings and stuff, but it eventually compiled successfully and your example worked well)

Hope this will be made simpler in future updates of the IDE.

Thanks very much @kaddigat!!! Works for me too!!! Detail: only Arduino IDE 1.6.7, SAM 1.6.6