xmos / lib_i2c

I²C library
Other
3 stars 25 forks source link

Repeated start condition setup time violated if a long delay occurs between completion of a non-terminated transmission and start of next transmission #81

Closed ACascarino closed 3 years ago

ACascarino commented 3 years ago

The I2C specification details specific timing requirements that must be adhered to. Two of these timing requirements relate to the "setup" and "hold" times for a start/repeated start condition, where a repeated start condition is a start condition without a preceding stop condition from a previous transmission; the definition of these two times is illustrated in Figure 1. The required setup time for a repeated start condition is 4.7/0.6 μs for busses running at 100/400 KHz respectively, while the required hold time for a start condition is 4/0.6 μs at 100/400 KHz.

I2C start condition timing constraints Figure 1: I2C start condition timing constraint illustration (not to scale)

Testing for the fix detailed in PR #79 has highlighted that under specific conditions we continue to violate the setup time constraint for a repeated start, even when the previous fix has been applied. This occurs when a long delay is seen between the conclusion of a non-terminated transmission and the start of the next, and is highlighted in test_bus_lock. A timing compliant repeated start can be seen in Figure 2a below, while Figure 2b shows the non-compliant timing seen when running this specific test.

I2C timing error Figure 2: a) timing-compliant repeated start condition. b) I2C timing error seen when running test_bus_lock.