The RTC provides a flexible alarm system. There are two user-programmable alarms (A0 and A1) which can be programmed based on the settings contained in the alarm registers for minutes, hours,
day of week, and day of month.
Each alarm register contains an alarm enable (AE) bit that can be used to enable the respective alarm register. By setting the AE bits of the various alarm registers, a variety of alarm events
can be generated.
- Example 1: A user wants to set an alarm every hour at 15 minutes past the hour (for example, at 00:15:00, 01:15:00, 02:15:00, and so on). This is possible by setting AxMIN to 15. By
setting the AE bit of the AxMIN and clearing all other AE bits of the alarm registers, the alarm is enabled. When enabled, the RTCAx interrupt flag is set when the count transitions from 00:14:59 to 00:15:00, 01:14:59 to 01:15:00,
02:14:59 to 02:15:00, and so on.
- Example 2: A user wants to set an alarm every day at 04:00:00. This is possible by setting AxHOUR to 4. By setting the AE bit of the AxHOUR and clearing all other AE bits of the
alarm registers, the alarm is enabled. When enabled, the RTCAx interrupt flag is set when the count transitions from 03:59:59 to 04:00:00.
- Example 3: A user wants to set an alarm for 06:30:00. AxHOUR would be set to 6 and AxMIN would be set to 30. By setting the AE bits of AxHOUR and AxMIN, the alarm is enabled. When
enabled, the RTCAx interrupt flag is set when the time count transitions from 06:29:59 to 06:30:00. In this case, the alarm event occurs every day at 06:30:00.
- Example 4: A user wants to set an alarm every Tuesday at 06:30:00. AxDOW in the AxDAY register would be set to 2, AxHOUR would be set to 6 and AxMIN would be set to 30. By setting
the AE bits of AxDOW, AxHOUR and AxMIN, the alarm is enabled. When enabled, the RTCAx interrupt flag is set when the time count transitions from 06:29:59 to 06:30:00 and the DOW transitions from 1 to 2.
- Example 5: A user wants to set an alarm the fifth day of each month at 06:30:00. AxDAY would be set to 5, AxHOUR would be set to 6 and AxMIN would be set to 30. By setting the AE
bits of AxDAY, AxHOUR and AxMIN, the alarm is enabled. When enabled, the RTCAx interrupt flag is set when the time count transitions from 06:29:59 to 06:30:00 and the RTCDAY equals 5.
Note:
Invalid alarm settings
Invalid alarm settings are not checked through hardware. It is the user's responsibility that valid alarm settings are entered.
Note:
Invalid time and date values
Writing of invalid date and/or time information or data values outside the legal ranges specified in the calendar and alarm registers can result in unpredictable behavior.
Note:
Setting the alarm
Before setting an initial alarm, all alarm registers including the AE bits should be cleared.
To prevent potential erroneous alarm conditions from occurring, the alarms should be disabled by clearing the RTCAx interrupt enable, RTCAx interrupt flag, and AE bits before writing initial
or new time values to the RTC time registers.