IIS2DH axis Z not working
Hello everyone,
I have an issue with the IIS2DH accelerometer when I try to pool data from it.
My setup is:
STM32L442 connected to the IIS2DH using SPI interface and sending data through USART to Tera Term (using a FTDI cable).
First I have a small initialization process which sets up the chip following my needs:
400Hz, X Y and Z axis enabled, +-2G scale, high resolution, SPI 4 wires, BDU.
Then I read all the 6 control registers and the "who I am" register to check if everything is ok and I display the results on Tera Term. All works nicely, as expected.
However, when I pool data from output registers (OUT_X_L, OUT_X_H, ...) it works only for X and Y axis...
Once data from the several registers are stored, there is a small sequence which constructs the 16-bit signed integers from the high and low regisiters of each axis, then it shifts the 16 bits to the right to keep only the first 12 bits (HR mode) and finally I send the data through USART (using atoi() function to convert the data into strings).
But as I said, it works perfectly for the X and Y axis, but not for the Z axis. Instead of having something corresponding to -1g (or -1024 on a 12 bit scale), I read almost -2g (-2039).
Sometimes when I hit the sensor, the Z axis moves a little bit but it does not correspond to normal operating.
Has anyone ever encountered this type of problem?
Thank you for your help!
Maxime
