Yes, II2C is enabled, and the system works most of the time. Just on occasion with a warm boot it gets this error.
K60, derivative of the K60xxxF120 BSP, MQX 4.1, Keil 5.4.
I did not verify the bus hung condition with a scope but I will do this next. But I did peruse the MQX I2C drivers, and I could not find any handling for a bus-hung condition, that is when a slave peripheral is not fully clocked out and is holding the data line. So, I follow the same sequence of operations as the MQX I2C application code example:
| fd = fopen("ii2c0:", NULL); |
| |
| // Set bit rate to 400K |
| param = 400000; |
| ret = ioctl(fd, IO_IOCTL_I2C_SET_BAUD, ¶m); |
| if (ret == I2C_ERROR_DEVICE_BUSY) |
| { // I get here |
}
Looking at the SET_BAUD I/O handler in the driver it simply test for a busy bus then gives up:
i2c_ptr->S & I2C_S_BUSY_MASK
So my I2C bus is BUSY, but the K60 is (or would be) the only master on the bus, at least if I could get that far in the example initialization.
So the proper way to clear a bus hung is to keep clocking the CL line until the slave device releases the data line, but there is no ioctl() call to do this. Do I have to bang on the I2C registers directly?
Thanks,
PMT