27.5.3 Alarm
In Gregorian and Persian modes, the RTC has five programmable fields: 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 the RTC Calendar Alarm register (RTC_CALALR) and the RTC 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 UTC_TIME alarm field, proceed as follows:
- Disable the UTC alarm by clearing RTC_CALALR.UTCEN if it is not already cleared.
- Change the RTC_TIMALR.UTC_TIME alarm value.
- Re-enable the UTC alarm by setting RTC_CALALR.UTCEN.