22.5.3 Alarm
In Gregorian and Persian modes, the RTC has five programmable fields for month, date, hours, minutes and seconds.
Each of these fields can be enabled or disabled to match the alarm condition:
- If all the fields are enabled, an alarm flag is generated (the corresponding flag is asserted and an interrupt generated if enabled) at a given month, date, hour/minute/second.
- If only the “seconds” field is enabled, then an alarm is generated every minute.
Depending on the fields that are enabled in Calendar Alarm register (RTC_CALALR) and Time Alarm register (RTC_TIMALR), a large number of possibilities are available to the user ranging from minutes to 365/366 days.
In UTC mode, RTC_TIMALR must be configured to set the UTC alarm value and bit 0 in RTC_CALALR must be used to enable or disable the UTC alarm. If the UTC alarm is enabled, the alarm is generated once the UTC time matches the programmed UTC_TIME alarm field.
To change the RTC_TIMALR.UTC_TIME alarm field, proceed as follows:
- Disable the UTC alarm by clearing the RTC_CALALR.UTCEN bit if it is not already cleared.
- Change the RTC_TIMALR.UTC_TIME value.
- Re-enable the UTC alarm by setting the RTC_CALALR.UTCEN bit.
