Solved
LIS2MDL BDU only works for 3 axis independent readouts
HI, it seems to me that reading the LIS2MDL sensor only works correctly if I read first the X axis, then the Y axis, and finally the Z axis separately, each axis in a separate SPI transaction.
My settings:
- continuous measurement, output data rate set at maximum 100Hz
- temperature compensation turned on
- high resolution mode
- low pass filter disabled, offset compensation disabled
- i2c disabled, SPI 3-wire clocked 10MHz, BDU enabled
- data ready interrupt on INT pin triggers enqueuing event into event queue, then main loop perform readout after some time (there are other higher priority tasks)
My observations:
1. Reading 8 bytes in one SPI transaction (from OUTX_L_REG 0x68 to TEMP_OUT_H_REG 0x6F) to read all data does not work at all, temperature data is broken, you need to split readout into 6 bytes of "axis data" and 2 bytes of temperature data
2. In certain edge cases of my application when possible readout latency is high I have incorrect readouts of Z axis from time to time (around once per 2 seconds), when I spitted SPI readouts into 3 transactions (first 2 bytes of X axis, then 2 bytes of Y axis, then 2 bytes of Z axis) the problem is gone.
Please confirm whether it is necessary to read 2-byte registers independently and if so, please check if this information is in the documentation.
