15.3.1.5 Arbitration, Clock Synchronization, Clock Stretching
Arbitration and clock synchronization are features aimed at allowing multi-master buses. Arbitration occurs when two devices try to
drive the bus at the same time. If one device drives it low, while the other drives it high, the one attempting to drive it high will not be
able to do so due to the open-drain bus configuration. Both devices sample the bus, and the one that was unable to drive the bus in the
desired direction detects the collision and backs off, letting the other device continue communication on the bus undisturbed.
Clock synchronization is a means of synchronizing the clock outputs from several masters driving the bus at once, and is a requirement
for effective arbitration.
Slaves on the bus are allowed to force the clock output on the bus low in order to pause the communication on the bus and give them-
selves time to process data or perform any real-time tasks they might have. This is called clock stretching.
Arbitration is supported by the I
2
C module for both masters and slaves. Clock synchronization and clock stretching is also supported.
15.3.2 Enable and Reset
The I
2
C is enabled by setting the EN bit in the I2Cn_CTRL register. Whenever this bit is cleared, the internal state of the I
2
C is reset,
terminating any ongoing transfers.
Note:
When enabling the I
2
C, the ABORT command or the Bus Idle Timeout feature must be applied prior to use even if the BUSY flag is not
set.
15.3.3 Safely Disabling and Changing Slave Configuration
The I
2
C slave is partially asynchronous, and some precautions are necessary to always ensure a safe slave disable or slave configura-
tion change. These measures should be taken, if (while the slave is enabled) the user cannot guarantee that an address match will not
occur at the exact time of slave disable or slave configuration change.
Worst case consequences for an address match while disabling slave or changing configuration is that the slave may end up in an
undefined state. To reset the slave back to a known state, the EN bit in I2Cn_CTRL must be reset. This should be done regardless of
whether the slave is going to be re-enabled or not.
15.3.4 Clock Generation
The SCL signal generated by the I
2
C master determines the maximum transmission rate on the bus. The clock is generated as a divi-
sion of the peripheral clock, and is given by the following equation:
f
SCL
= f
HFPERCLK
/(((N
low
+ N
high
) x (DIV + 1)) + 8),
Figure 15.11. I2C Maximum Transmission Rate
N
low
and N
high
in combination with the synchronization cycles (discussed below) specify the number of prescaled clock cycles in the low
and high periods of the clock signal respectively. The worst case low and high periods of the signal are:
T
high
>= ((N
high
) x (DIV + 1) + 4)/f
HFPERCLK
,
T
low
>= (N
low
x (DIV + 1) + 4)/f
HFPERCLK
.
Figure 15.12. I2C High and Low Cycles Equations
In worst case, T
high
and T
low
can be 1 f
HFPERCLK
cycle longer than the number found by above equations due to synchronization uncer-
tainity (i.e., if the synchronization takes 3 f
HFPERCLK
cycles instead of 2). Similarly, in the worst case the number 8 in the denominator in
f
SCL
equation can be 9 (if the synchronization cycles were 3 instead of 2 in T
high
or T
low
) or 10 (if synchronization cycles were 3 in both
T
high
and T
low
). The values of N
low
and N
high
and thus the ratio between the high and low parts of the clock signal is controlled by
CLHR in the I2Cn_CTRL register.
Note:
DIV must be set to 1 during slave mode operation.
EFM32JG1 Reference Manual
I2C - Inter-Integrated Circuit Interface
silabs.com
| Smart. Connected. Energy-friendly.
Preliminary Rev. 0.6 | 401