I am working on I2C driver for our system with Kinetis K65 MCU (MK60FN1M0VLQ15) with CW 10.6. MCU works as master and communication with other peripherals on the line like temperature sensor, pressure sensor, accelerometer. The driver is developed based on the example provided from "C:\Freescale\CW MCU v10.6\MCU\CodeWarrior_Examples\Kinetis_Examples\k60\i2c\Sources" and operates pretty well. However, since we have some hardware noisy on the line and sometimes make I2C failure. My task is if I can detect the failure condition happened and clear it.
I was able to find whenever failure condition happened, the data line is low, and "busy" flag is set in the i2c status register. (See the attachment for detail). I am always able to reset the MCU to clear the issue, which means the data line is not holding by any I2C slave. I have tried to clear the busy flag by reissue "start" and "stop" condition, disable I2C module, turn off I2C clock. re-declare as GPIO output and try to bring them high on purpose, However, the signal lever doesn't change, and as soon as I enable the I2C module, the busy flag is set right away. If you have any recommendation, please let me know. Thank you very much.