This is already enabled and just need turning on.
// watch dog
constant WDTCLR 0xBF800004
constant WDTSET 0xBF800008 // wdtcomset
constant WDSW (1 << 15)
constant WDCLR 1
The watchdog is turned on by: @WDTSET = WDSW
The watchdog can be turned off by: @WDTCLR = WDSW
In the program loop incorporate: @WDTSET = WDCLR to prevent the watchdog firing.
The timing is set in the DEVCFG1 register that is set in the boot loader and so cannot be changed, a copy of the value can be seen in the WDTCON register, bits 6:2 but those values are read only. The current setting on the MX1 gives about 15 seconds
The watchdog time can also be used for waking the CPU up from sleep as it keeps running when the processor is asleep.
// power down here
wfPower(0) // wifi power down
@WDTSET = WDSW // turn on watch dog (about 16 sec)
for j = 1 to 2
powersave(1) // sleep mode for CPU (about 15-16 sec)
@WDTCLR = WDSW // watchdog off
The above will shut down the processor for about 30 seconds, increase the J index for more multiples of 15 seconds.