An I2C target device pulls the SCL
line low to push the I2C controller device into the wait state preventing the I2C
controller from transmitting data. This concept is called Clock Stretching.
The I2C supports three different types of clock
stretching:
- Automatic Clock Stretching:
Figure 33-15 shows the timing diagram for automatic clock stretching.
- Target Receiver mode:
- Non-FIFO mode:
I2C clock stretches after receiving 2 bytes from the
controller.
- FIFO mode: I2C
clock stretches after receiving 17 bytes from the
controller.
- Target Transmitter mode:
I2C clock stretches, if I2C transmit buffer is empty.
Note: Automatic Clock
Stretching is enabled by default and cannot be disabled.
- Extended Automatic Clock
Stretching: provides enhanced flexibility to preemptively clock stretch
after every address and data byte, to allow the I2C target to
performing housekeeping.
Extended Automatic Clock Stretching can be enabled
through the following steps:
- Set I2CEMDR.ALT_ECS =
1 to enable ECS.
- Once this feature is
enabled, the hardware automatically does clock stretching by pulling
the SCL line low after every ACK/NACK and generate an I2C interrupt,
if using interrupts. If using the polling method, the I2CSTR.SCL_ECS
flag can be used to monitor the status.
- Within the I2C ISR,
I2CSTR.SCL_ECS is set to 1 to release the I2C from clock
stretching.
Figure 33-16 shows the timing diagram for extended automatic clock stretching.
Note: Extended
Automatic Clock Stretching is disabled by default and can be enabled by following
the above instructions.