A watchdog timer (WDT) is used to help the system recover from any anomalies/failures. It is a hardware timer which resets the system when it overflows. The system needs to reset the watchdog timer before it “times out”.
Any of the older projects can be used for this tutorial. They are available on Github at https://github.com/vicara-hq/da14531-tutorials
We will use a DA145xx Pro motherboard with a DA14531 Tiny module daughterboard.
Out of all the peripherals the DA14531 provides, the WDT is the easiest peripheral to use. The Dialog SDK6 has 2 preprocessor definitions which control the working of the Watchdog Timer. They can be found in the da1458x_basic_config.h file.
When CFG_WDOG is defined, the Watchdog timer is enabled. The pre configured duration for the WDT is 2048 ms which is ~2 seconds.
Note: The configuration files do not provide any options to change the WDT period but it can be changed by modifying WATCHDOG_DEFAULT_PERIOD in arch_wdg.h . I have not tested this change and cannot assure that this will not cause any other problems.
CFG_WDG_TRIGGER_HW_RESET_IN_PRODUCTION_MODE defines the behaviour of a WDT overflow when the project is built in Production mode i.e. CFG_DEVELOPMENT_DEBUG is undefined. If CFG_WDG_TRIGGER_HW_RESET_IN_PRODUCTION_MODE is defined, it generates a system reset. If it’s not defined, a Non Maskable Interrupt is generated which might store some data related to the fault before triggering a system reset.
If the project is in Debug mode, the execution of the code halts and does not reset. This allows a debugger to be attached and check what has caused the error.