Interruptions
Last updated
Last updated
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 when a determined value (threshold) is reached.
Waspmote is designed to work with 2 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 2 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 4th 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: Waspmote\'s 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 up from the Sleep and the Deep Sleep modes. However, only the synchronous interruption by the RTC is able to wake it up from the Hibernate mode.
The Hibernate mode totally disconnects the Waspmote power, leaving only the battery powering the RTC to wake Waspmote up when the time alarm is reached. Because of this disconnection, when the RTC generates the corresponding alarm, the power in Waspmote is reconnected and the code starts again from the setup.
The way of detecting whether a reboot from the Hibernate mode has happened is to check whether the corresponding flag has been activated. The activation of this flag happens when the ifHibernate()
function is called, which must be done at the beginning of the setup part of the code. This way, when Waspmote starts, it tests if it is a normal start or if it is a start from the Hibernate mode.
All information about the programming and operation of interruptions can be found in the Interruptions Programming Guide.