
The only way around this is to use a different timeout-capable I2C implementation. Supplying a timeout in I2Cdevlib code would make zero difference, because there's no way to pass it to the underlying Wire/TWI implementation. If you dig into the code, you'll see a blocking loop in the TWI calls. Arduino's Wire library does not actually provide timeout functionality. However, in this case, I strongly doubt that it is the lack of a timeout argument that is causing the underlying issue. The best laid plans of mice and men, as it were. I've tried to migrate most of the effort to online forums and other willing (and often more capable) contributors as much as possible, since I can't devote the time to this that I used to. I really hope someone fix this and add a timeout so nobody would spent entire months anymore seeking a problem that's is really hard to track an intermitent.Īpologies for the lack of support. It could be the problem but MY PROBLEM FOR ALMOST A FULL YEAR has been this bug reported here. Some people mistakenly believe it's related to bufffer overflow in the FIFO or because of some non optimized code. I am pretty sure maaaany MAAAANY other people alterady experienced this problem and spent a lot of time trying to understand what went wrong. You see the problem? The function readBytes accepts one last parameter which is "timeout" but the function getFIFOCount uses readBytes without the timeout parameter! That's probably a bug cause sometimes I think the readBytes takes too long to execute and a TIMEOUT SHOULD BE set to avoid the function hanging out forever. I2Cdev::readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data, uint16_t timeout) I checked the function "readBytes()" inside I2Cdev.cpp and I found this: Return (((uint16_t)buffer) << 8) | buffer I2Cdev::readBytes(devAddr, MPU6050_RA_FIFO_COUNTH, 2, buffer)

Inside the file MPU6050.cpp there is a code like this: So I discovered everytime my arduino hanged/freezes it was at a line with getFIFOCount() or getIntStatus().

I discovered that inserting many Serial.print with tags along my entire code so I could know exactly which line hanged. I discovered it is usually when executin getFIFOCount() or getIntStatus().

It took me almost a full year to discover the problem and today I had some spare time and I tried to find where exactly arduino hangs/freezes.

Sometimes my Arduino freezes or crashes when using JEFF ROWBERG library to read DMP data from MPU6050.
