First value in LIS3DSH is incorrect.
Hi,
i'm using the LIS3DSH to read data in different sampling rates (from 25 up to 1600), but in some cases i notice the first data in Z axe is not correct (some times it's too low or too high, for example, first data is -0.7g (or -1.5) and the rest are around -1g) and this happen with a random sampling rate, somethings happen when i use 100 hz and sometimes when i use 400 or 800. i even changed the anti-aliasing but i had no luck, the only think i can do is to wait until the value is updated in the sensor so i can get the next value at the start.
this is a snap of my code to about the state machine configuration
this is the initialization section:
AccelTxCmd(0x01, LIS3DSH_CTRL_REG3_ADDR); /* registers reset */
AccelTxCmd(0x00, LIS3DSH_CTRL_REG4_ADDR); /* make sure LIS3DSH is off */
AccelTxCmd(0x00, LIS3DSH_CTRL_REG3_ADDR); /* make sure IRQs disabled */
AccelTxCmd(0,LIS3DSH_CS_X_ADDR); /* constant shift for x axis*/
AccelTxCmd(0,LIS3DSH_CS_Y_ADDR);/* constant shift for y axis*/
AccelTxCmd(0,LIS3DSH_CS_Z_ADDR);/* constant shift for z axis*/
AccelTxCmd(0x4<< 3, LIS3DSH_CTRL_REG5_ADDR);
AccelTxCmd(<ThresholdValueHere>, LIS3DSH_THRS1_2_ADDR);
AccelTxCmd(0x19, LIS3DSH_SETT2_ADDR); /*diff data for State Machine 2 ,constant shift enabled */
AccelTxCmd(0xfc, LIS3DSH_MASK2_B_ADDR);
AccelTxCmd(0xfc, LIS3DSH_MASK2_A_ADDR);
AccelTxCmd(0x32, LIS3DSH_ST2_1_ADDR); /* state machine 2 first step : activate constant shift */
AccelTxCmd(0x05, LIS3DSH_ST2_2_ADDR); /* state machine 2 second step : any axis greater than threshold1_2 */
AccelTxCmd(0x11, LIS3DSH_ST2_3_ADDR);/* state machine 2 third step : restart state machine from beginning */
AccelTxCmd(0x9<< 4 | 0x7, LIS3DSH_CTRL_REG4_ADDR); /* Sampling rate + Axis Bitmap */and i call this section every time i start the streaming:
AccelTxCmd(0x9<< 4 | 0x7, LIS3DSH_CTRL_REG4_ADDR); /* Sampling rate + Axis Bitmap */
AccelTxCmd(0x4<< 3, LIS3DSH_CTRL_REG5_ADDR);after that i just keep reading data from sensor.
I'm not sure if the sensor need time to apply the configuration and the anti-aliasing and i need to wait for a delay before i start collecting the data, or i'm just skipping the first value by apply the delay since i'm using the continuous update option or i'm doing something wrong. and i hope someone can point them out for me.
Best regards,
Habib

