English
Language : 

DS1347_13 Datasheet, PDF (9/17 Pages) Maxim Integrated Products – Low-Current, SPI-Compatible Real-Time Clock
DS1347
Low-Current, SPI-Compatible
Real-Time Clock
Setting the Clock
Writing to the Timekeeping Registers
The time and date are set by writing to the timekeeping
registers (Seconds, Minutes, Hours, Date, Month, Day,
Year, and Century). During a write operation, an input
buffer accepts the new time data while the timekeeping
registers continue to increment normally, based on the
crystal counter. The buffer also keeps the timekeeping
registers from changing as the result of an incomplete
write operation, and collision-detection circuitry
ensures that a time write does not occur coincident with
a Seconds register increment. The updated time is
loaded into the timekeeping registers after the rising
edge of CS, at the end of the SPI write operation. An
incomplete write operation aborts the update proce-
dure, and the contents of the input buffer are discard-
ed. The timekeeping registers reflect the new time
beginning with the first Seconds register increment
after the rising edge of CS.
Although both single writes and burst writes are possi-
ble, the best way to write to the timekeeping registers is
with a burst write. With a burst write, the main time-
keeping registers (Seconds, Minutes, Hours, Date,
Month, Day, Year) and the Control register are written
sequentially following the address/command byte. They
must be written as a group of eight registers, with 8 bits
each, for proper execution of the burst write function.
All seven timekeeping registers are simultaneously
loaded into the clock counters by the rising edge of CS,
at the end of the SPI write operation.
If single write operations are used to enter data into the
timekeeping registers, error checking is required. If not
writing to the Seconds register, begin by reading the
Seconds register and save it as initial-seconds. Then
write to the required timekeeping registers, and finally
read the Seconds register again (final-seconds). Check
to see that final-seconds is equal to initial-seconds. If
not, repeat the write process. If writing to the Seconds
register, update the Seconds register first, and then
read it back and store its value (initial-seconds).
Update the remaining timekeeping registers and then
read the Seconds register again (final-seconds). Check
to see that final-seconds is equal to initial-seconds. If
not, repeat the write process.
AM/PM and 12Hr/24Hr Mode
Bit 7 of the Hours register selects 12hr or 24hr mode.
When high, 12hr mode is selected. In 12hr mode, bit 5
is the AM/PM bit, logic-high for PM. In 24hr mode, bit 5
is the 20hr bit, logic-high for hours 20 through 23.
Write-Protect Bit
Bit 7 of the Control register is the write-protect bit.
When high, the write-protect bit prevents write opera-
tions to all registers except itself. After initial settings
are written to the timekeeping registers, set the write-
protect bit to logic 1 to prevent erroneous data from
entering the registers during power glitches or inter-
rupted serial transfers. The lower 7 bits (bits 0–6) are
unusable, and always read zero. Any data written to
bits 0–6 are ignored. Bit 7 must be set to zero before a
single write to the clock, before a write to RAM, or dur-
ing a burst write to the clock.
Example: Setting the Clock
with a Burst Write
To set the clock to 10:11:31PM, Thursday July 4th,
2002, with a burst write operation, write 3Fh as the
address/command byte, followed by 8 bytes, 31h, 11h,
B0h, 04h, 07h, 05h, 02h, and 00h (Figure 2). 3Fh is the
clock burst write address/command. The first data
byte, 31h, sets the Seconds register to 31. The second
data byte, 11h, sets the Minutes register to 11. The
third data byte, B0h, sets the Hours register to 12hr
mode, and 10PM. The fourth data byte, 04h, sets the
Date register (day of the month) to the 4th. The fifth
data byte, 07h, sets the Month register to July. The
sixth data byte, 05h, sets the Day register (day of the
week) to Thursday. The seventh data byte, 02h, sets
the Year register to 02. The eighth data byte, 00h,
clears the write-protect bit of the Control register to
allow writing to the device. The Century register is not
accessed with a burst write and therefore must be writ-
ten to separately to set the century to 20. Note the
Century register corresponds to the thousand and hun-
dred digits of the current year and defaults to 19.
Maxim Integrated
9