RTC Overview
Real-Time Clock 11-3
The prescaler stages are tapped to support real-time interrupt features. A periodic interrupt at 1Hz is
available, as well as an interrupt at the midnight rollover of the hours counter.
11.1.2 Time-of-Day Counter
Although the four counters that constitute the time-of-day counter are not restricted to operation as a
time-of-day counter, most designs use the counters in this fashion. The four counters (seconds, minutes,
hours, and days) are toggled by the 1Hz clock from the prescaler. The seconds and minutes counters (each
6 bits) and the hours counter (5 bits) are maintained in the RTC timer register (RTCTIME). The day
counter (9bits) can count up to 512 days and is located in its own register (DAYR). The four counters can
be read at any time. The seconds, minutes, and hours data is maintained in 24-hour time format, which
increments in day counts.
NOTE:
To allow maximum flexibility in design, each of the four counters in the
TOD clock can accept values that exceed their valid range. The
MC68VZ328 does not check for range validity. If an out-o f-range value is
entered, the counter will reset to zero the next tim e it is inc reme nted. For
example, if 26 is written to the hours counter, the counter will remain 26
until incremented by the minutes counters. When incremented, the hours
counter will return to zero. It is the responsibility of the user to ensure the
range validity of data in the TOD clock.
Each of the four counters may be enabled to produce an interrupt when it rolls over. Upon reaching 59, the
seconds and minutes counters each produce an MIN or HR interrupt (if enabled) the next time they are
incremented. Both counters reset to 00 and increment the next counter. Likewise, the hours counter, after
reaching a count of 23, produces an interrupt (DAY) with the next increment from the minutes counter.
The counter resets to 00 and increments the day counter.
11.1.3 Alarm
The alarm is composed of four registers that mirror those found in the time-of-day counter. The seconds,
minutes, and hours counters are in the RTC alarm register (RTCALRM). The day alarm register
(DAYALRM) contains the 9-bit DAYSAL field.
An alarm is set by accessing the RTCALRM and DAYALRM register and loading the days, hours,
minutes, and seconds for the time that the alarm is to generate an interrupt. The alarm is enabled when the
AL bit in the real-time interrupt enable re gister (RTCIENR) is set. When the time in the TOD counter
matches the time in the TOD alarm, the ALM bit in the real-t im e interrupt status register (RTCISR) is set.
If the alarm is not disabled, it will recur every 24 hours. If a sing le e vent a larm is de sired , then the in terr upt
service routine should change the values in the alarm registers or disable the ALM bit.