This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

PROCESSOR-SDK-AM437X: I2C Bus Recovery

Part Number: PROCESSOR-SDK-AM437X

The Problem:

I have an I2c Bus that works most of the time. But due to some physical error It's occasionally locking. The physical error is probably due to human interaction, and is outside the scope of this problem. In order to simulate this problem I first wait for the program to start reading I2c and verify that im getting valid readings. Then I manually grounding the sck line, after ~5 seconds I remove the ground. 

  

When Using "I2C_transfer()" In blocking mode:

The I2c Driver seems to be locking up I see that the driver is calling 'I2CMasterBusBusy' in a loop on that task. Also looking at the registers via the debugger seems to suggest its getting the correct answer. However at no point does this ever exit. This Task will sit there and keep calling that same function forever. Any task With higher priority will still run correctly but any lower priority task will be blocked. 

When Using "I2C_transfer()" In Call Back mode: 

Its harder to debug what exactly is happening here. From what I can Tell an exception is thrown due to the lock up. The callback is never called here when a lock up happens. This ends up killing the task that the I2c call is happening in as well as all other tasks.

How should I go about trying to recover this bus? The Examples Provided Suggest this should be possible however no attempt ive made so far have been successful. Even if I can't fix the bus it would be nice if the task wasn't locked up or causing the entire chip to crash. 

int32_t I2CMasterBusBusy(uint32_t baseAddr)
{
uint32_t status;

if (HW_RD_FIELD32(baseAddr + I2C_IRQSTATUS_RAW,
I2C_IRQSTATUS_RAW_BB) == I2C_IRQSTATUS_RAW_BB_SET)
{
status = 1U;
}
else
{
status = 0U;
}

return (int32_t) status;
}