va3wam / SegbotSTEP

Arduino ESP8266 code for balancing two-wheeled robot with stepper motors
1 stars 0 forks source link

Bug: Intermittent code lock up when polling I2C for IMU device #3

Open va3wam opened 6 years ago

va3wam commented 6 years ago

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.

va3wam commented 6 years ago

This should be done once the code is ported over per task: Port IMU code to this code base