AnsweredAssumed Answered

I2C Lockout on M26 - how to reset to normal state?

Question asked by Chris Smith on Feb 4, 2020
Latest reply on Feb 4, 2020 by Mark Butcher

We are using a M26 Microprocessor and its I2C system with an external device.  Every so often, it gets into a state where the SDK software returns an error and the situation does not ever recover.

 

In fact - this code in fsl_i2c.c fails since kI2C_TransferCompleteFlag remains 0 even if the I2C init code to initialize I2C runs again, even through resets.  I've even done what the register description says and put the I2C into read mode and read the data register to reset this bit to on.  

 

The trace says that one condition that trips this is the device acking the initial address, but for some reason the M26 never sees it and does not continue sending the register address so nothing happens.

 

status_t I2C_MasterTransferBlocking(I2C_Type *base, i2c_master_transfer_t *xfer)
{
assert(xfer);

i2c_direction_t direction = xfer->direction;
status_t result = kStatus_Success;

/* Clear all status before transfer. */
I2C_MasterClearStatusFlags(base, kClearFlags);

#if I2C_WAIT_TIMEOUT
uint32_t waitTimes = I2C_WAIT_TIMEOUT;
/* Wait until the data register is ready for transmit. */
while ((!(base->S & kI2C_TransferCompleteFlag)) && (--waitTimes))
{
}
if (waitTimes == 0)
{
return kStatus_I2C_Timeout;
}

 

The effect of this is that we never hit the hardware bus again.

 

Is there a way to get the I2C controller to fully reset and get back to normal after such an error?

Outcomes