Hi guys, i have read the forums and examples included with gabriel’s RTCZero but i can’t get a simple loop timer to work with my autonomo, how do i make it wake up, do something and then sleep for 10 mins in a continuous loop?
The RTCZero library configures the alarm to generate an interrupt at a configured time. This interrupt wakes the board from sleep mode.
The __WFI() call in this example is the call for the board to enter sleep mode and Wait For Interrupt.
You can specify the specific time and date for the alarm to be generated. Additionally, by using the alarm mask you can specify what components of the time and date to match and what parts to ignore.
For example, by using the MATCH_YYMMDDHHMMSS mask, the alarm interrupt will only be generated when all components of the date and time (year, month, day, hour, minutes, seconds) match. Whereas the MATCH_SS mask will ignore everything except for the seconds value, using this mask will generate an interrupt every minute when the seconds value of the clock matches that of the alarm.
This makes it easy to create regular interrupts with the intervals of once per minute, per hour, per day, per month and per year. Creating a regular interrupt for other periods is a bit more complicated. Effectively, you will have to reschedule the alarm each sleep/wake cycle.
If you want a 10-minute sleep/wake cycle, I would recommend using the MATCH_MMSS mask (match minutes and seconds). Then reschedule the alarm minutes value every cycle with something like: