Something changed with I2C from firmware version 4.5.9 to version 4.7.0. Continuously polling the ST1633I touch controller works fine in firmware version 4.5.9 on the RT1062, but with firmware version 4.7.0 I’m now getting OSError: [Errno 5] EIO errors after a few seconds.
Hi, can you check if there’s an actual error on the I2C bus? The MIMXRT port is maintained in upstream MicroPython. I’ve never encountered an error while using the I2C driver except when there’s an actual error.
FYI … i2c frequency is incorrect below 4000. I measured actual clock frequency on a scope and found:
I2C(1, freq=1000, timeout=50000) → actual freq = 22.2KHz
I2C(1, freq=2000, timeout=50000) → actual freq = 43.2KHz
I2C(1, freq=3000, timeout=50000) → actual freq = 16.5KHz
I2C(1, freq=4000, timeout=50000) → actual freq = 3.97KHz
I2C(1, freq=5000, timeout=50000) → actual freq = 4.95KHz
I2C(1, freq=10000, timeout=50000) → actual freq = 9.9KHz
I2C(1, freq=4000, timeout=50000) → actual freq = 3.97KHz
I2C(1, freq=5000, timeout=50000) → actual freq = 4.95KHz
I2C(1, freq=10000, timeout=50000) → actual freq = 9.9KHz
Seems about right… The 1K, 2K, and 3K numbers seem suspect.
Measured on scope. The actual I2C clock frequency when freq=1000, 2000 or 3000 are not correct.
Also the clock frequency for machine.SoftI2C is incorrect. When I set freq=400000, the readback is 500000 and the actual clock frequency is 500000 on the scope.
This can be reproduced using:
scl_pin = machine.Pin(“P4”)
sda_pin = machine.Pin(“P5”)
i2c = machine.SoftI2C(scl_pin, sda_pin, freq=400000)
print("I2C: Config ", i2c)
Output: I2C: Config SoftI2C(scl=GPIO_AD_B0_12, sda=GPIO_AD_B0_13, freq=500000)
With further testing:
i2c = machine.SoftI2C(scl_pin, sda_pin, freq=200000) creates SoftI2C(scl=GPIO_AD_B0_12, sda=GPIO_AD_B0_13, freq=250000)
i2c = machine.SoftI2C(scl_pin, sda_pin, freq=300000) creates SoftI2C(scl=GPIO_AD_B0_12, sda=GPIO_AD_B0_13, freq=500000)
i2c = machine.SoftI2C(scl_pin, sda_pin, freq=100000) creates SoftI2C(scl=GPIO_AD_B0_12, sda=GPIO_AD_B0_13, freq=100000)
There’s a new release now, 4.8.0, but I don’t recalling making/seeing any mimxrt I2C fixes or any changes for that matter.