Once in a while the sketch hangs in the I2C_bus_OK() function right after the message [start_I2C_bus] Send Who Am I request to IMU shows up on the console. The code that causes the lock up is likly:
Wire.beginTransmission(MPU_address); //Get attention of MPU6050 IMU on I2C bus
Wire.write(MPU6050_WHO_AM_I); //Point to the Who am I register
Wire.endTransmission(); //Release I2C bus
Wire.requestFrom(MPU_address, 1); //Request one byte reply
while(Wire.available() < 1); //Wait for reply
The bug is that the function I2C_BUS_OK() is supposed to clear up I2C bus issues and seems to miss some sort of bus error.
Once in a while the sketch hangs in the I2C_bus_OK() function right after the message [start_I2C_bus] Send Who Am I request to IMU shows up on the console. The code that causes the lock up is likly: Wire.beginTransmission(MPU_address); //Get attention of MPU6050 IMU on I2C bus Wire.write(MPU6050_WHO_AM_I); //Point to the Who am I register Wire.endTransmission(); //Release I2C bus Wire.requestFrom(MPU_address, 1); //Request one byte reply while(Wire.available() < 1); //Wait for reply
The bug is that the function I2C_BUS_OK() is supposed to clear up I2C bus issues and seems to miss some sort of bus error.