Hi all,
My 1284p based Arduino keeps locking up after 5 to 20 minutes when I'm reading data from my MPU6050 accelerometer. I've cut my code back to basics as much as possible and it's still doing it.
Here's my sketch:
cannot enter due to forum's 9000 character limit
I've attached it, but here'es the part it hangs on:
Serial.print("a");
fifoCount = mpu.getFIFOCount();
Serial.print("b");
Using a couple of well placed Serial prints I have narrowed the problem down to the line.
fifoCount = mpu.getFIFOCount();
I know this because when the program freezes, the serial monitor has printed "a" and never the corresponding "B'.
Anyway I have included the .cpp file that contains the getFIFOCount() function as an attachment, but here is the function below to hopefully make it easier to identify.
uint16_t MPU6050::getFIFOCount() {
I2Cdev::readBytes(devAddr, MPU6050_RA_FIFO_COUNTH, 2, buffer);
return (((uint16_t)buffer[0]) << 8) | buffer[1];
}
Can anyone help me solve this crashing issue? I've been at it for days, searched many forums and tried so many different things, but none stop it crashing.
And I don't know if it helps, but the MPU6050 is on a GY521 breakout board, supplied with 5v, which the board's regulator converts to 3.3v. The SDA and SCL lines at 3.3v. my 1284p is 3.3v volts.
MPU6050.cpp (124 KB)
MPU6050_dig_int.ino (13.7 KB)