From c42a6faaba870b601c5a27481b2eebab96afdcf5 Mon Sep 17 00:00:00 2001 From: playztag <47277378+playztag@users.noreply.github.com> Date: Sun, 20 Jun 2021 11:22:14 -0700 Subject: [PATCH] Update MPU9250.cpp Resolving issue 250, divide-by-zero error when calibrating IMU https://github.com/m5stack/M5Stack/issues/250 --- src/utility/MPU9250.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utility/MPU9250.cpp b/src/utility/MPU9250.cpp index 157da08a..c3eb3f1d 100644 --- a/src/utility/MPU9250.cpp +++ b/src/utility/MPU9250.cpp @@ -233,7 +233,7 @@ void MPU9250::calibrateMPU9250(float * gyroBias, float * accelBias) { delay(40); // accumulate 40 samples in 40 milliseconds = 480 bytes // At end of sample accumulation, turn off FIFO sensor read - writeByte(MPU9250_ADDRESS, FIFO_EN, 0x00); // Disable gyro and accelerometer sensors for FIFO + //writeByte(MPU9250_ADDRESS, FIFO_EN, 0x00); // Disable gyro and accelerometer sensors for FIFO <--- disabling FIFO sensors cause the next line to return 0 for FIFO_COUNTH, causing divide-by-zero crash readBytes(MPU9250_ADDRESS, FIFO_COUNTH, 2, &data[0]); // read FIFO sample count fifo_count = ((uint16_t)data[0] << 8) | data[1]; packet_count = fifo_count / 12; // How many sets of full gyro and accelerometer data for averaging