Figure 1 shows the address map for the DS3231 timekeeping
registers. During a multibyte access, when the
address pointer reaches the end of the register space
(12h), it wraps around to location 00h. On an I2C START
or address pointer incrementing to location 00h, the current
time is transferred to a second set of registers. The
time information is read from these secondary registers,
while the clock may continue to run. This eliminates the
need to reread the registers in case the main registers
update during a read.
I2C Interface
The I2C interface is accessible whenever either VCC or
VBAT is at a valid level. If a microcontroller connected
to the DS3231 resets because of a loss of VCC or other
event, it is possible that the microcontroller and DS3231
I2C communications could become unsynchronized, e.g.,
the microcontroller resets while reading data from the
DS3231. When the microcontroller resets, the DS3231
I2C interface may be placed into a known state by toggling
SCL until SDA is observed to be at a high level. At
that point the microcontroller should pull SDA low while
SCL is high, generating a START condition.
Clock and Calendar
The time and calendar information is obtained by reading
the appropriate register bytes. Figure 1 illustrates the RTC
registers. The time and calendar data are set or initialized
by writing the appropriate register bytes. The contents of
the time and calendar registers are in the binary-coded