WatchDogSAMD.h file
Contains the extendedWatchDogSAMD class.
Code for this is taken from the Adafruit SleepyDog library: https://github.com/adafruit/Adafruit_
Classes
- class extendedWatchDogSAMD
- The extendedWatchDogSAMD class uses the early warning interrupt to of the built in SAMD watchdog to extend the allowable time between resets of the watchdog's clock up to multiple minute timescales.
Functions
- void WDT_Handler(void)
- ISR handler for watchdog timer early warning (WDT EW) interrupt.
Defines
- #define MAXIMUM_WATCHDOG_PERIOD = 16UL
- The longest possible time between watchdog interrupts in seconds.
- #define GENERIC_CLOCK_GENERATOR_MS = (5u)
- The clock generator number to use for the watchdog timer and the external interrupt controller.
Define documentation
#define MAXIMUM_WATCHDOG_PERIOD = 16UL
The longest possible time between watchdog interrupts in seconds.
For a SAMD board, we can get the longest possible time between interrupts by using the maximum closed window period in "windowed" mode and setting the early warning interrupt that opens the window to occur at the mimimum possible time before a reset fires. The maximum number of clock cycles for the closed window period is 16384 cycles on both a SAMD21 and SAM(D/E)51.
On a SAM(D/E)51 the only clock available for the watch dog is the 1.024kHz CLK_WDT_OSC clock sourced from the ULP32KOSC.
On a SAMD21 the WDT can be clocked from any clock source with the maximum dividor depending on the selected clock generator. To save power, we force the SAMD21 to use the ULP32KOSC for the WDT and EIC. For simplicity of code, we use a 32x divisor on the ULP32KOSC to match the SAM(D/E)51 1.024kHz CLK_WDT_OSC.
16384 clock cycles at 1.024kHz = 16s
#define GENERIC_CLOCK_GENERATOR_MS = (5u)
The clock generator number to use for the watchdog timer and the external interrupt controller.
This only applies to a SAMD21 device. Neither the WDT nor the EIC require a dedicated clock generator on the SAM(D/E)51.