2025-01-30 04:43 AM
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.
2025-01-30 06:00 AM
Hi, I tried printing out raw values.
Below you can see 3 samples with broken Z axis readout, each time it was broken the MSB of Z axis was equal to LSB of X axis. This might be a problem with my software, but if you guys now know how LIS2MDL registers are upgraded and how BDU works you can make me sure that this is not LIS2MDL problem but my software problem... I would be grateful if you could take a look at these results and assess whether this is a LIS2MDL problem.
Magn X | Magn Y | Magn Z | Raw data X | Raw data Y | Raw data Z |
------------------------------------------------------------------
-975, | 171, | 132, | 0x76, 0xfd, | 0x8e, 0xff, | 0x58, 0x00 |
-984, | 178, | 121, | 0x70, 0xfd, | 0x89, 0xff, | 0x51, 0x00 |
-1002, | 195, | 112, | 0x64, 0xfd, | 0x7e, 0xff, | 0x4b, 0x00 |
-991, | 189, | 111, | 0x6b, 0xfd, | 0x82, 0xff, | 0x4a, 0x00 |
-990, | 193, | 108, | 0x6c, 0xfd, | 0x7f, 0xff, | 0x48, 0x00 |
-994, | 193, | 123, | 0x69, 0xfd, | 0x7f, 0xff, | 0x52, 0x00 |
-1003, | 187, | 32764, | 0x63, 0xfd, | 0x83, 0xff, | 0x00, 0x63 |
-994, | 192, | 106, | 0x69, 0xfd, | 0x80, 0xff, | 0x47, 0x00 |
-991, | 187, | 120, | 0x6b, 0xfd, | 0x83, 0xff, | 0x50, 0x00 |
-994, | 196, | 103, | 0x69, 0xfd, | 0x7d, 0xff, | 0x45, 0x00 |
-999, | 192, | 109, | 0x66, 0xfd, | 0x80, 0xff, | 0x49, 0x00 |
-1003, | 193, | 108, | 0x63, 0xfd, | 0x7f, 0xff, | 0x48, 0x00 |
-997, | 198, | 105, | 0x67, 0xfd, | 0x7c, 0xff, | 0x46, 0x00 |
------------------------------------------------------------------|
-993, | 195, | 118, | 0x6a, 0xfd, | 0x7e, 0xff, | 0x4f, 0x00 |
-993, | 195, | 123, | 0x6a, 0xfd, | 0x7e, 0xff, | 0x52, 0x00 |
-991, | 180, | 114, | 0x6b, 0xfd, | 0x88, 0xff, | 0x4c, 0x00 |
-987, | 193, | 121, | 0x6e, 0xfd, | 0x7f, 0xff, | 0x51, 0x00 |
-1003, | 183, | 118, | 0x63, 0xfd, | 0x86, 0xff, | 0x4f, 0x00 |
-991, | 192, | 32764, | 0x6b, 0xfd, | 0x80, 0xff, | 0x50, 0x6b |
-982, | 190, | 126, | 0x71, 0xfd, | 0x81, 0xff, | 0x54, 0x00 |
-1000, | 192, | 124, | 0x65, 0xfd, | 0x80, 0xff, | 0x53, 0x00 |
-996, | 187, | 120, | 0x68, 0xfd, | 0x83, 0xff, | 0x50, 0x00 |
-996, | 189, | 118, | 0x68, 0xfd, | 0x82, 0xff, | 0x4f, 0x00 |
-999, | 196, | 121, | 0x66, 0xfd, | 0x7d, 0xff, | 0x51, 0x00 |
-994, | 190, | 114, | 0x69, 0xfd, | 0x81, 0xff, | 0x4c, 0x00 |
-------|--------|--------|-------------|-------------|------------|
-1000, | 192, | 121, | 0x65, 0xfd, | 0x80, 0xff, | 0x51, 0x00 |
-996, | 196, | 120, | 0x68, 0xfd, | 0x7d, 0xff, | 0x50, 0x00 |
-993, | 190, | 127, | 0x6a, 0xfd, | 0x81, 0xff, | 0x55, 0x00 |
-996, | 181, | 120, | 0x68, 0xfd, | 0x87, 0xff, | 0x50, 0x00 |
-997, | 186, | 32764, | 0x67, 0xfd, | 0x84, 0xff, | 0x00, 0x67 |
-996, | 186, | 126, | 0x68, 0xfd, | 0x84, 0xff, | 0x54, 0x00 |
-985, | 190, | 115, | 0x6f, 0xfd, | 0x81, 0xff, | 0x4d, 0x00 |
-991, | 193, | 120, | 0x6b, 0xfd, | 0x7f, 0xff, | 0x50, 0x00 |
-987, | 177, | 132, | 0x6e, 0xfd, | 0x8a, 0xff, | 0x58, 0x00 |
-969, | 172, | 139, | 0x7a, 0xfd, | 0x8d, 0xff, | 0x5d, 0x00 |
-985, | 177, | 130, | 0x6f, 0xfd, | 0x8a, 0xff, | 0x57, 0x00 |
2025-01-30 08:40 AM
Hi @amistar ,
You can read all the output registers. Can you implement our official drivers and let me know if you solve the issue?
Thanks