I2C Reset via 9 clock pulse in FRDM-K64 and FreeRTOS

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

I2C Reset via 9 clock pulse in FRDM-K64 and FreeRTOS

Jump to solution
2,158 Views
darshan_shah1
Contributor II

Hi,

Sometimes while doing I2C communication, I was getting error "I2C Busy" status 1100 from the i2c driver.

I am testing in remote set-up so unfortunately I am not able to take SCL and SDA line pulses on CRO.

I would like to implement 9-clock pulse reset yet I don't find any guide or code in I2C driver.

Please suggest a way.

Labels (1)
0 Kudos
1 Solution
2,042 Views
ErichStyger
Senior Contributor V

Hi Darshan,

I have implemented this and using it in different projects with the MCUXpresso SD, including in this one: Building a Raspberry Pi UPS and Serial Login Console with tinyK22 (NXP K22FN512) | MCU on Eclipse 

There is an example project for this on GitHub (mcuoneclipse/Examples/MCUXpresso/tinyK22/tinyK22_RaspberryPi_UPS at master · ErichStyger/mcuoneclips... ), have a look at the I2CLib_ResetBus() function in mcuoneclipse/i2clib.c at master · ErichStyger/mcuoneclipse · GitHub .

Basically it re-muxes the pins as GPIO pins, does the 9 clocks and then switches back to the I2C normal muxing.

I call the release bus always after reset, because the slaves on the bus could be already blocking if not doing a power-on reset. As for using the bus or the I2CLib functions from tasks, there is a mutex implemented in it to allow multiple tasks accessing the bus in a reentrant way.

I hope this helps,

Erich

View solution in original post

0 Kudos
1 Reply
2,043 Views
ErichStyger
Senior Contributor V

Hi Darshan,

I have implemented this and using it in different projects with the MCUXpresso SD, including in this one: Building a Raspberry Pi UPS and Serial Login Console with tinyK22 (NXP K22FN512) | MCU on Eclipse 

There is an example project for this on GitHub (mcuoneclipse/Examples/MCUXpresso/tinyK22/tinyK22_RaspberryPi_UPS at master · ErichStyger/mcuoneclips... ), have a look at the I2CLib_ResetBus() function in mcuoneclipse/i2clib.c at master · ErichStyger/mcuoneclipse · GitHub .

Basically it re-muxes the pins as GPIO pins, does the 9 clocks and then switches back to the I2C normal muxing.

I call the release bus always after reset, because the slaves on the bus could be already blocking if not doing a power-on reset. As for using the bus or the I2CLib functions from tasks, there is a mutex implemented in it to allow multiple tasks accessing the bus in a reentrant way.

I hope this helps,

Erich

0 Kudos