When trying to use the Watchdog on the DUE, you will come over short to one finding:
After a Processor Reset, the value of WDV is 0xFFF, corresponding to the maximum value of
the counter with the external reset generation enabled (field WDRSTEN at 1 after a Backup
Reset). This means that a default Watchdog is running at reset, i.e., at power-up. The user must
either disable it (by setting the WDDIS bit in WDT_MR) if he does not expect to use it or must
reprogram it to meet the maximum Watchdog period the application requires.
The Watchdog Mode Register (WDT_MR) can be written only once. Only a processor reset
resets it. Writing the WDT_MR register reloads the timer with the newly programmed mode
As variant.cpp contains the line WDT_Disable(WDT); in its init() function, the watchdog is disabled forever. So you need solutions, to prevent the disabling. I added now the following lines in variants.cpp before the init() function:
#pragma weak WDT_Init
And replaced WDT_Disable(WDT);
in the init() function.
That is now first hand a neutral solution, but gives you the ability to define a strong version of WDT_Init();
in your program. That can either be an empty-function, which leaves the Watchdog configured as from startup, or any other code, which changes the Watchdog to call the ISR WDT_Handler() or change any other settings.
Do I miss something in my thoughts or should this go into the main code?