2025-01-29 06:25 AM
I have a LIS3MDLTR connected over I2C on an aerial system that is used as part of our GNC system. In our most recent test we received data from the magnetometer that appears to have gotten "stuck" reporting to exact same measurement (see below). The system was flying from minute 0 until around minute 10.
I've seen this behavior in the lab as well and I have found that I can temporarily fix this by rebooting the magnetometer by writing to the REBOOT bit in CTRL_REG2. While this does resolve the issue, it frequently re-appears (about every 2-3 power ups). What is causing this issue and how can I avoid it?
I have multiple peripherals connected to the I2C bus that continue operating correctly so it is not an issue with the I2C master.
The LIS3MDLTR is configured as follows.
0xFC, // CTRL_REG1
0x0, // CTRL_REG2
0x0, // CTRL_REG3
0x0E, // CTRL_REG4
0x40 // CTRL_REG5
Since I'm reading from the magnetometer at a rate of 10Hz, significantly lower rate than it's 80Hz output rate, I do not check the ZYXDA data ready bit and just read directly OUT_X, OUT_Y, and OUT_Z in three separate consecutive calls.