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.

LAUNCHXL-F280049C: i2c Clock suddenly goes low at and hangs device

Part Number: LAUNCHXL-F280049C

Tool/software:

Hello,

I am using a i2c port expander in my project but the port expander / I2C is not working as expected.

After device start up the i2c works well and suddenly the clock of the i2c becomes low and the system then resets.

I have checked my code and the i2c port expander set up but I could not figure out the problem.

What can be the problem and how can this be solved.

Thanks

  • Hi Abayomi,

    At first glance, it sounds like the I2C target module is holding the clock low to push the I2C controller into a wait state known as clock stretching. Besides seeing a "sudden clock low and system resets", when you are debugging your code, is there a certain line that causes this behavior? What are you seeing in the registers that leads you to believe the I2C is causing the reset / is in reset? Please clearly identify the issue and the related symptoms using documentation and the I2C SW examples.

    Best Regards,

    Aishwarya

  • Hello Rajesh,

    Thanks for your reply.

    I have looked at my code and observed that the reset was from my code.  When the i2c bus is not available, the data to be transmitted is save for later transmission) and this leads to lack of memory (as the data is continously been saved) and a system reset.

    What can I do with regards to the clock stretching.  The setting of my i2c bus is at 100khz.

    Is there a specific way to handle this?

    Thanks

  • Hi,

    The behaviour of the bus is captured below.

    The bus works well and data is sent every 100ms.  A total of 6 data is always sent: i2c slave address, i2c salve register address and 4 byte data payload.  But From the logic analyser snapshot, at the point when the clock goes low, 7 data is sent on the i2c bus instead of 6.  This is strange and the additional data is the i2c slave address.  My C2000 is configured as master.

    What can be responsible for the sudden transmission of the additional byte of data. and the bus going low.

    Thanks

  • Abayomi,

    Since the I2C hardware does not have a mechanism to reset the bus and flush data, the software must take care of that. The solution is to flush the stale remaining byte in the data register. When the bus is reset, the byte is probably not being cleared during the previous reads, so you can do a dummy read of the data register before the controller actually reads the data.

    Best Regards,

    Aishwarya

  • Hi Rajesh,

    Thanks for the feedback.

    I need some clarification on your reply.  Am not sure what you mean by the read operation.  My I2C device only sends out data to the port expander and does not do any read operation.

    I could provide more information as needed.

    Thanks

  • Resolved using the tip you provided.  Thanks

  • Abayomi,

    Glad to hear it. If the suggestion was helpful, can you please mark the answer I provided earlier as resolved, to help people viewing the thread in the future as well? Thank you.

    Best Regards,

    Aishwarya

  • HI,

    I further tested my code and observed that the problem was not completely solved.

    The I2C bus does not shutdown again but the data been sent on the bus are not correct.   I preusme that the location of this line of code - 

    I2caRegs.I2CDXR.bit.DATA = 0; //flush data transmit register to prevent bus issues

    was responsible.

    Is there any particular sequence of flusing the register?

    Thanks

  • Abayomi,

    We do not have any examples of this since this is not a procedure, we support on the I2C hardware. The previous answer was a suggestion based on what the issue was. Maybe you can try this approach as well: TMS320F28379D: stale byte sent when polling XRDY during slave transmit routine

    Best Regards,

    Aishwarya

  • Hi,

    Thanks so much for the reply.  I have solved the problem.  However I have another problem.

    When I change to optimisation level of the compiler to 0 - Register optimizations, the ic2 does not work again. Specifically the clock goes low after working for some time period.  

    Do you knnow what I can do about this?

    Thanks

  • Abayomi,

    Glad to hear it. If the above suggestions were helpful, can you please mark the answers I provided earlier as resolved, to help people viewing the thread in the future as well?

    As this is a different question, please start a new thread. Thank you.

    Best Regards,

    Aishwarya