arduino-libraries / Arduino_LSM6DS3

LSM6DS3 Library for Arduino
GNU Lesser General Public License v2.1
30 stars 31 forks source link

wrong register configuration (CTRL8_XL) #13

Open leo-oel opened 4 years ago

leo-oel commented 4 years ago

LSM6DS3.cpp sets 0x09 to LSM6DS3_CTRL8_XL register while the LSM6DS3 datasheet says the bit3 shoud be zero for the correct operation. I suppose the value should be 0x05.

kaiiorg commented 4 years ago

Working on my own branch to try to implement FIFO usage and decided to try to address this issue while I was at it. I was running into issues where setting LSM6DS3_CTRL8_XL to 0x05 instead of the existing 0x09; it was changing the accelerometer data you would read from the device.

If I'm interpreting the documentation and the block diagram correctly, setting LSM6DS3_CTRL8_XL to 0x05 sets LPF2_XL_EN to 0, HP_SLOPE_XL_EN to 1, and HPCF_XL[1:0] to 00, and thus enables the slope filter. The values you'd read would be (near) zero until there was a change.

Setting LSM6DS3_CTRL8_XL to 0x09, an invalid bit was set to 1 and no filters were enabled, and the data you'd get would be whatever acceleration the device was measuring at the time; movement of the device and/or gravity. I guess we could have also been tempting fate at undefined behavior since, as stated before, the documentation says that bit should remain 0.

Therefore, we should remove the lines changing the register altogether as the default value for LSM6DS3_CTRL8_XL on power up is 0x00.