Nations Technologies Inc.
Tel
:
+86-755-86309900
:
Address: Nations Tower, #109 Baoshen Road, Hi-tech Park North.
Nanshan District, Shenzhen, 518057, P.R.China
427
/
631
Clock synchronization and Arbitration
The I2C module supports multi-master arbitration, which means two masters can initiate an I2C START
operation concurrently when the bus is inactive. So some mechanisms are needed to grant a master the access
to the bus. This process is generally named Clock Synchronization and Arbitration.
I2C module has two key features:
SDA and SCL are drain open circuit structures, and the signal "wire-and" logic is realized through an external
pull-up resistor.
SDA and SCL pins will also detect the level on the pin while outputting the signal to check whether the output
is consistent with the previous output. This provides the hardware basis for "Clock Synchronization" and "Bus
Arbitration".
The I2C device on the bus is to output logic 0 by "grounding the line". Based on the characteristics of the I2C bus, if
one device sends logic 0 and the other sends logic 1, then the line sees only logic 0, so there is no possibility of level
conflicts on the line.
The physical connection of the bus allows the master to read data while writing data to the bus. In this way, when
two masters are competing for the bus, the one that sends logic 0 does not know the occurrence of the competition.
Only the one that sends logic 1 will find the conflict (when writing a logic 1, but read 0) and exit the competition.
Clock synchronization
The high-to-low switching of the SCL line causes the devices to begin counting their low-level periods, and once the
device's clock goes low, it keeps the SCL line in this state until the high-level of the clock is reached. However, if
another clock is still in the low period, the low-to-high switch of this clock will not change the state of the SCL line.
Therefore, the SCL line is kept low by the device with the longest low-level period. A device with a short low-level
period will enter a high-level wait state.
When all related devices have counted their low-level periods, the clock line is released and goes high-level, after
which there is no difference in the state of the device clock and SCL lines, and all devices will begin counting their
high-level periods, the device that completes the high-level period first will pull the SCL line low again.
In this way, the low-level period of the generated synchronous SCL clock is determined by the device with the longest
low-level clock period, and the high-level period is determined by the device with the shortest high-level clock period.
Arbitration
Arbitration, like synchronization, is to resolve bus control conflicts in the case of multiple masters. The arbitration
process has nothing to do with the slave. When the two masters both produce a valid start bit when the bus is idle, in
this case, it is necessary to decide which master will complete the data transmission. This is the process of arbitration.
Each master controller does not have the priority level of controlling the bus, which is all determined by arbitration.
The bus control is determined and carried out bit by bit. They follow the principle of "low level first", that is, whoever
sends the low level first will control the bus. During the arbitration of each bit, when SCL is high, each host checks
whether its own SDA level is the same as that sent by itself. In theory, if the content transmitted by two hosts is
exactly the same, then they can successfully transmit without errors. If a host sends a high level but detects that the
SDA line is low, it considers that it has lost arbitration and shuts down its SDA output driver, while the other host
continues to complete its own transmission.