
-96-
v8.6
Programming
22.2. Interruptions
Interruptions are signals received by the microcontroller which indicate it must stop the task it is doing to handle
an event that has just happened. Interruption control frees the microcontroller from having to control sensors all
the time. It also makes the sensors warn Waspmote Plug & Sense! when a determined value (threshold) is reached.
Waspmote Plug & Sense! is designed to work with two types of interruptions: Synchronous and asynchronous:
•
Synchronous interruptions:
They are scheduled by timers. They allow to program when we want them to be
triggered. There are two types of timer alarms: periodic and relative.
-
Periodic alarms
are those to which we specify a particular moment in the future, for example: “Alarm
programmed for every fourth day of the month at 00:01 and 11 seconds”. They are controlled by the RTC.
-
Relative alarms
are programmed taking into account the current moment, eg: “Alarm programmed
for 5 minutes and 10 seconds”. They are controlled through the RTC and the microcontroller’s internal
Watchdog.
•
Asynchronous Interruptions:
These are not scheduled, so it is not known when they will be triggered. Types:
-
Sensors:
The sensor boards can be programmed so that an alarm is triggered when a sensor reaches a
certain threshold.
-
Accelerometer:
The accelerometer can be programmed so that certain events such (as a fall or change of
direction) generate an interruption.
All interruptions, both synchronous and asynchronous can
wake
Waspmote Plug & Sense! up from the
Sleep
and
the
Deep Sleep
modes.
All information about the programming and operation of interruptions can be found in the
Interruption
Programming Guide
.
22.3. Watchdog
The ATmega1281 microcontroller inside the Waspmote Plug & Sense! has an internal Enhanced Watchdog Time
– WDT. The WDT
precisely
counts the clock cycles generated by a
128 kHz oscillator
. The WDT generates an
interruption signal when the counter reaches the set value. This interruption signal can be used to wake the
microcontroller from the
Sleep
mode or to generate an internal alarm when it is running in on mode, which is very
useful when developing programs with timed interruptions.
The WDT allows the microcontroller to wake up from a low consumption Sleep mode by generating an interruption.
For this reason, this clock is used as a time-based alarm associated with the microcontroller’s Sleep mode. This
allows very precise control of small time intervals:
16 ms, 32 ms, 64 ms, 128 ms, 256 ms, 500 ms, 1 s, 2 s, 4 s, 8 s
.
For intervals over 8 s (Deep Sleep mode), the RTC is used and not the microcontroller.
All information about their programming and operation can be found in the
.
All the documentation is located in the Development section in the Libelium website.
22.3.1. RTC Watchdog for reseting Waspmote
One of the alarms of the RTC (Alarm 2) is connected to a Watchdog reset circuit that is able to reset the
microcontroller of Waspmote Plug & Sense! when the alarm is generated. This Watchdog has been implemented
for reseting Waspmote Plug & Sense! if it gets stuck. That periodical reset avoids erratic behaviour. This is highly
recommended for applications that need to be very robust and can never stop working. The use of the Watchdog
feature ensures us that our Waspmote will never stop working.
The Watchdog feature requires the physical watchdog switch to be put in “enable” position (default state in
Waspmote Plug & Sense! Devices).
All information about the RTC programming and operation can be found in the
.
All the documentation is located in the Development section in the Libelium website.