Waspmote RTC provides two alarms to enable interruptions and wake up the device from a low-power state.
There are two different RTC alarms:
- Alarm1: is set by day/date, hour, minutes and seconds.
- Alarm2: is set by day/date, hour and minutes. Alarm2 is reserved for the RTC watchdog.
There are three inputs for setting a new alarm: time, offset and mode.
- Time: represents the time/date for the alarm.
- Offset: represents the two modes for setting the alarm time: offset or absolute. When offset is selected, the input time is added to the actual time in the RTC and the result is set as the alarm time. When absolute is selected, the input time is set as the alarm time.
- Mode: represents the different alarm modes. Alarm1 has 6 modes and Alarm2 has 5 modes.
When the time set in Alarm1 matches the time on RTC, the interruption pin is triggered. This pin is connected to an interrupt pin on the microcontroller, so as the alarm can wake up the microcontroller from a sleep mode.The RTC can be used to set a common time base in all Waspmotes within a network. Also, it can generate interruptions based on a specified temporal period.
The RTC provides two alarms to enable interruptions and wake up the microcontroller from a low consumption mode :
Alarm 1 is accurate to one second
Alarm 2 is accurate to one minute
The use of the RTC has been associated with Waspmote’s Deep Sleep and Hibernate modes, allowing it to put the microcontroller to sleep, activating alarm 1 in the RTC to wake it. Thus, Waspmote can be put into the lowest consumption mode and woken up using the RTC. For more information about these energy saving modes, consult the Energy and Power Programming Guide.
setAlarm1()function sets Alarm1 to the specified time, offset and mode. This function also enables the RXD1 interruption pin.
The RTC.setAlarm2(time, offset, mode) function sets Alarm2 to the specified time, offset and mode. This function also enables the RXD1 interruption pin.
The RTC generates a rising-edge interruption through the RXD1 pin. It also has a unique monitoring pin. When the interruption occurs in the RXD1 pin, the subroutine ‘onHAIwakeUP’ is run marking the corresponding flags.
detachInt()function disables the RXD1 interruption pin and also disables both RTC alarm1 and alarm2 the RTC alarm1 so as not to provoke any interruption. After calling this function, no module will be able to interrupt the microcontroller via RXD1 because it has been disabled.
Example of use:
// disable RTC interruption
Check RTC interruption
In order to check the interruption capture, it is necessary to poll
intFlagas seen below:
if (intFlag & RTC_INT)
// RTC interrupt treatment
Figure 10: RTC alarm operation
It is also possible to use the interruptions generated by the RTC as timed alarms without the need for the microcontroller to be in energy saving modes. The use of RTC alarms is recommended for times longer than 8s, since for shorter timersperiods of time, the microcontroller’s internal Watchdog can be used.
Related API libraries: WaspRTC.h, WaspRTC.cpp