Inter-integrated Circuit (I2C) Interface
User Manual All information provided in this document is subject to legal disclaimers. © REALTEK 2019. All rights reserved.
255
13.2.7
Clock Synchronization
When two or more masters try to transfer information on the bus at the same time, they must arbitrate and synchronize the SCL clock. All
masters generate their own clock to transfer messages. Data is valid only during the high period of SCL clock. Clock synchronization is
performed using the wired-AND connection to the SCL signal. When the master transitions the SCL clock to 0, the master starts counting the
low time of the SCL clock and transitions the SCL clock signal to 1 at the beginning of the next clock period. However, if another master is
holding the SCL line to 0, then the master goes into a HIGH wait state until the SCL clock line transitions to 1.
All masters then count off their high time and the master with the shortest high time transitions the SCL line to 0. The masters then count out
their low time and the one with the longest low time forces the other master into a HIGH wait state. Therefore, a synchronized SCL clock is
generated, which is illustrated in Fig 13-20. Optionally, slaves may hold the SCL line low to slow down the timing on the I
2
C bus.
Fig 13-20 Multi-Master clock synchronization
13.2.8
Operation Modes
This section provides information on operation modes.
Note:
It is important to note that the I
2
C should only be set to operate as an I
2
C Master, or I
2
C Slave, but not both simultaneously. This is
achieved by ensuring that bit 6 (IC_SLAVE_DISABLE) and bit 0 (IC_MASTER_MODE) of the IC_CON register are never set to 0 and 1, respectively.
13.2.8.1
Slave Mode Operation
This section discusses slave mode procedures.
13.2.8.1.1
Initial Configuration
To use the I
2
C as a slave, perform the following steps:
(1)
Disable the I
2
C by writing a ‘0’ to bit 0 of the IC_ENABLE register.
(2)
Write to the IC_SAR register (bits 9:0) to set the slave address. This is the address to which the I
2
C responds.
(3)
Write to the IC_CON register to specify which type of addressing is supported (7- or 10-bit by setting bit 3). Enable the I
2
C in slave-only
mode by writing a ‘0’ into bit 6 (IC_SLAVE_DISABLE) and a ‘0’ to bit 0 (MASTER_MODE).
Note:
Slaves and masters do not have to be programmed with the same type of addressing 7- or 10-bit address. For instance, a slave can
be programmed with 7-bit addressing and a master with 10-bit addressing, and vice versa.
(4)
Enable the I
2
C by writing a ‘1’ in bit 0 of the IC_ENABLE register.
13.2.8.1.2
Slave-Transmitter Operation for A Single Byte
When another I
2
C master device on the bus addresses the I
2
C and requests data, the I
2
C acts as a slave-transmitter and the following steps
occur:
(1)
The other I
2
C master device initiates an I
2
C transfer with an address that matches the slave address in the IC_SAR register of the I
2
C.
(2)
The I
2
C acknowledges the sent address and recognizes the direction of the transfer to indicate that it is acting as a slave-transmitter.
(3)
The I
2
C asserts the RD_REQ interrupt (bit 5 of the IC_RAW_INTR_STAT register) and holds the SCL line low. It is in a wait state until
software responds.
Realtek confidential files
The document authorized to
SZ99iot
2019-05-15 10:08:03