Rainbow Electronics DS12887 User Manual
Page 7
DS12887
7 of 19
TIME, CALENDAR, AND ALARM LOCATIONS
The time and calendar information is obtained by reading the appropriate memory bytes. The time,
calendar, and alarm are set or initialized by writing the appropriate RAM bytes. The contents of the 10
time, calendar, and alarm bytes can be either binary or binary coded decimal (BCD) format. Before
writing the internal time, calendar, and alarm registers, the SET bit in Register B should be written to a
logic 1 to prevent updates from occurring while access is being attempted. In addition to writing the 10
time, calendar, and alarm registers in a selected format (binary or BCD), the data mode bit (DM) of
Register B must be set to the appropriate logic level. All 10 time, calendar, and alarm bytes must use the
same data mode. The set bit in Register B should be cleared after the data mode bit has been written to
allow the RTC to update the time and calendar bytes. Once initialized, the RTC makes all updates in the
selected mode. The data mode cannot be changed without reinitializing the 10 data bytes. Table 2 shows
the binary and BCD formats of the 10 time, calendar, and alarm locations. The 24–12 bit cannot be
changed without reinitializing the hour locations. When the 12-hour format is selected, the high-order bit
of the hours byte represents PM when it is a logic 1. The time, calendar, and alarm bytes are always
accessible because they are double buffered. The 10 bytes are advanced once per second by 1 second and
checked for an alarm condition. If a read of the time and calendar data occurs during an update, a problem
exists where seconds, minutes, hours, etc., might not correlate. The probability of reading incorrect time
and calendar data is low. Several methods of avoiding any possible incorrect time and calendar reads are
covered later in this text.
The three alarm bytes can be used in two ways. First, when the alarm time is written in the appropriate
hours, minutes, and seconds alarm locations, the alarm interrupt is initiated at the specified time each day
if the alarm enable bit is high. The second use condition is to insert a “don’t care” state in one or more of
the three alarm bytes. The “don’t care” code is any hexadecimal value from C0 to FF. The two most
significant bits of each byte set the “don’t care” condition when at logic 1. An alarm is generated each
hour when the “don’t care” bits are set in the hours byte. Similarly, an alarm is generated every minute
with “don’t care” codes in the hours and minute alarm bytes. The “don’t care” codes in all three alarm
bytes create an interrupt every second.
Table 2. TIME, CALENDAR, AND ALARM DATA MODES
DATA MODE RANGE
ADDRESS
LOCATION
FUNCTION
DECIMAL
RANGE
BINARY
BCD
0
Seconds
0–59
00–3B
00–59
1
Seconds Alarm
0–59
00–3B
00–59
2
Minutes
0–59
00–3B
00–59
3
Minutes Alarm
0–59
00–3B
00–59
Hours, 12-hour Mode
1–12
01–0C AM,
81–8C PM
01–12AM,
81–92PM
4
Hours, 24-hour Mode
0–23
00–17
00–23
Hours Alarm, 12-hour
1–12
01–0C AM,
81–8C PM
01–12AM,
81–92PM
5
Hours Alarm, 24-hourr
0–23
00–17
00–23
6
Day of the Week
Sunday = 1
1–7
01–07
01–07
7
Date of the Month
1–31
01–1F
01–31
8
Month
1–12
01–0C
01–12
9
Year
0–99
00–63
00–99