i2c waiting for ever

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by dragilla on Sun Jan 29 07:58:15 MST 2012
Hello again :)

I fixed all my hard faults, and other silly errors and now I faced another behavior of my hardware which I don't understand.
I have an IMU 6DOF board (accelerometer and gyroscope) connected to my lpcxpresso 1769 board through i2c. The whole set works 100% ok... for a while :) Last time it run for almost 3 hours with no fault. But if I wait long enough the program always gets stuck in one line:

static uint32_t I2C_Start (LPC_I2C_TypeDef *I2Cx)

// Wait for complete
while (!(I2Cx->I2CONSET & I2C_I2CONSET_SI)); // <--- HERE IT GETS STUCK

And it stops here from the function that reads data from the gyroscope (ITG3200) - never the accelerometer. 3 hours is kind of long... my loop reading data from this IMU board runs at 100hz... so I don't have much idea of what can happen. Do you?

I tried changing clock speeds for the I2C - the default was 100khz, I tried 120khz as my core clock is 120mhz, then I tried 60khz - same result.
The itg3200 can run on frequencies from 0 to 400khz.

I even tried rearranging the code, to put the accelerometer reading before the gyroscope. I tried putting some other commands between the two reads, to make a time gap between using the i2c - nothing.

Please give me an idea what can I try. Maybe I should try to do something with my hardware, or something?