Post Go back to editing

DS3231 alarm interrupt behavior upon update of RTC time

Category: Hardware
Product Number: DS3231

I have an application for an alarm clock where a DS3231 is used to generate 1-minute interrupts with Alarm 2, at which time an attached microcontroller requests the current time from the DS3231 and compares the hours and minutes to registers internal to the microcontroller for a user-settable alarm. The date/time of the DS3231 is periodically updated to keep it synchronized with UTC, and these updates can happen at any time.

Suppose at UTC time 11:00:02 the microcontroller updates the time on the DS3231, which currently thinks the time is 10:59:58. During this update the DS3231 will skip right past 11:00:00. Will the DS3231 generate an interrupt for the minute 11:00:00, or will that interrupt be skipped since there was no 59->00 seconds transition?

  • ADI will need to confirm this, but my guess is that the 11:00:00 Alarm 2 interrupt gets skipped, and you don't get another interrupt until 11:01:00.

    I see two possible solutions. Both assume the same microcontroller is providing the UTC updates as is generating the user-settable alarms. I'm assuming the UTC updates come asynchronously from a WWV or GPS radio receiver, and do not come at known, specific intervals.

    (1) When the UTC update comes in, the microcontroller must read current time and compare to UTC-update time. If a user alarm is in between those two times, it must activate the user alarm as soon as the UTC update occurs.

    (2) When the UTC update arrives, the microcontroller must store both current time and UTC update time in RAM, and then wait for the next one-minute interrupt. After servicing the interrupt (and issuing the user alarm if needed), then it calculates the adjustment needed, reads the now-current time, and adjusts that accordingly. For example, UTC update of 11:00:02 arrives at local current time of 10:59:10. Adjustment needed is +52 seconds. After the local Alarm 2 interrupt at 11:00:00, if the user-alarm is set for that time, then issue the user alarm. After the user alarm service is complete, let's say local current time is now 11:00:05. Local time is now adjusted +52 seconds to 11:00:57. However, if the current time seconds register plus the adjustment exceeds 60 seconds, you still need to deal with the possibility of skipping a user alarm.

    Whichever method you use, also remember that adjustments can be negative, and you probably don't want to generate the user alarm a second time one or two minutes later. For example, you issue the user alarm at local time of 11:00:00, then UTC-adjust back to 10:59:40. You probably don't want to issue another user alarm 20 seconds later.

  • Upon running a test I can confirm that the alarm will be skipped and, and the Alarm 2 flag will not set until the following minute when there is a 59->00 second transition.