Watchdog

The Watchdog allows the microcontroller to be woken up from a low consumption state by generating an interruption.

This is a software-generated interruption. The interruption generation is different to other Waspmote modules. To unify the operation with the rest of the modules, a hardware interruption is simulated when receiving the software interruption.

Enable interruption

The setWatchdog() function enables the microcontroller interruption in the INT4 pin. Besides, it sets the Watchdog interruption indicating two input parameters: the mode and timer to set.

The possible modes are:

WTD_ON: enable the Watchdog WTD_OFF: disable the Watchdog

The possible timers before generating the interruption are:

WTD_16MS: 16ms WTD_32MS: 32ms WTD_64MS: 64ms WTD_128MS: 128ms WTD_250MS: 256ms WTD_500MS: 500ms WTD_1S: 1s WTD_2S: 2s WTD_4S: 4s WTD_8S: 8s

Example of use:

{
 // enable Watchdog interruption to be generated after 8 seconds
 PWR.setWatchdog(WTD_ON,WTD_8S);
 }

Interruption Event

When the Watchdog interruption occurs, an internal subroutine is run to generate the hardware interruption simulation. The reserved DIGITAL0 (INT4 pin) is used to monitor this simulated interruption which is a low active interruption. For this reason, when this interruption occurs, the subroutine onLAIwakeUP is executed, marking the corresponding flags.

Disable interruption

The setWatchdog() function disables the INT4 interruption pin and stops the Watchdog timer.

Example of use:

{
 // disable Watchdog interruption
 PWR.setWatchdog(WTD_OFF,WTD_8S);
 }

Check Watchdog interruption

In order to check the interruption capture, it is necessary to poll intFlag as seen below:

if (intFlag & WTD_INT)
 {
 // Watchdog interrupt treatment
 

The generated interruptions can also be used by the Watchdog as timed alarms without the need for the microcontroller to be in energy saving mode. The Watchdog alarms can be used for time less or equal to 8s. For longer times the RTC must be used.

• Watchdog interruption example:

http://www.libelium.com/development/waspmote/examples/int-01-watchdog-timer-interrupt

Related API libraries: WaspPWR.h, WaspPWR.cpp

All information about their programming and operation can be found in the document: Energy and Power Programming Guide.

All the documentation is located in the Development section in the Libelium website.

Last updated