AnsweredAssumed Answered

MQX 4.0 I2C Locks Up

Question asked by Myke Predko on Apr 19, 2013
Latest reply on Feb 24, 2016 by shikha suresh

This may be a follow on to "Using AN4652 - I2C Driver Locks Up" ( but I had a couple of questions that didn't seem to be answered here. 


I am prototyping my product using the Tower System with the TWRK20D72M processor board (note that J25 and J26 have been pulled to minimize the load on the I2C bus, which seems to help), a TWR-SER PCB (there are no I2C devices here) and a prototype PCB with an I2C hand wired OLED mounted to it and a connection to an I2C controlled audio amplifier through an IDC cable.  I'm running at 400,000bps.  This is obviously not an optimal situation and I can see where the wiring can cause problems on the line as opposed to a properly terminated line on a PCB - this supposition seems to be supported with what I am observing. 


Periodically, the I2C crashes with the SDA line being held low.  The OLED *seems* to be holding down the (ie I can see the line being held low and when I pull the OLED, the SDA line goes high again). 


When the I2C line is down, I pause the application in CW and I find that execution is stuck in I2c_pol_ki2c.c at line 361:

         while (tmp & I2C_S_BUSY_MASK)


            if (tmp & I2C_S_IICIF_MASK)


               i2c_ptr->S |= I2C_S_IICIF_MASK;

               tmp = (uint_8)i2c_ptr->D;


            tmp = i2c_ptr->S;




This seems to be polling loop for the SDA line to go high. 


As I hinted at above, with the accelerometer connection through J25 and J26 disconnected, the rate of errors is much less - but it still happens.  What is really interesting is that if there is a 'scope probe on the SDA line, the program runs indefinitely (which tells me that it's a termination problem). 


My questions are:

1.  Is there a version of the MQX I2C driver which supports timeouts on the SDA/SCL lines?  I didn't want to use the code that was attached to "Using AN4652 - I2C Driver Locks Up" as the discussion was regarding MQX 3.8.1 and I'm working with MQX 4.0

2.  Any suggestions on how the line should be terminated?  This won't be an issue with the final product, but I want to have a reliable prototyping platform until the PCBs are available.  I'm going to try to match the scope termination with 1M resistors to ground.