AnsweredAssumed Answered

Why do I always get the same values of x, y and z for LIS2DH12 FIFO?

Question asked by Allen Lin on Mar 12, 2018
Latest reply on Mar 12, 2018 by Allen Lin

Hi,

   Thank you for reading my question.

   I always get the same values of x,y and z for using FIFO mode on LIS2DH12. The x, y and z values will change for each interrupt of WTM, but the three values are the same.

  My configurations are represent as yellow mark at following table 

I'm using I2C and  SDO is connected GND. I can get the correct WHO_AM_I value (0x33) . I also checked the registers after I set them and they are correct. I also can receive the interrupt of INT1 for reading x, y and z, but the valuesare not correct. The value of FIFO_SRC_REG is 0x00 before I read x, y and z. 

   Could you help me to check the configuration for startup and reading FIFO buffer procedure?

Best Regards,

Allen

 

My initialization is:
if(LIS2DH12_getRegisterValue(LIS2DH12_WHO_AM_I_ADDR) == LIS2DH12_WHO_AM_I_DEF)
{


LIS2DH12_setRegisterValue(LIS2DH12_CTRL_REG1_ADDR, LIS2DH12_ODR_SELECTION(LIS2DH12_bandWithCode) | LIS2DH12_OUT_XYZ_ALL);
LIS2DH12_setRegisterValue(LIS2DH12_CTRL_REG3_ADDR, LIS2DH12_INT1_WTM_MASK | LIS2DH12_INT1_OVERRUN_MASK); // set INT1 triger by FIFO buffer is full
LIS2DH12_setRegisterValue(LIS2DH12_CTRL_REG4_ADDR, LIS2DH12_FS_CODE(LIS2DH12_FS_2G_CODE) | LIS2DH12_HR_MASK); 
LIS2DH12_setRegisterValue(LIS2DH12_CTRL_REG5_ADDR, LIS2DH12_FIFO_EN_MASK); //Enable FIFO
LIS2DH12_setRegisterValue(LIS2DH12_FIFO_CTRL_REG_ADDR, LIS2DH12_FIFO_MODE(LIS2DH12_FIFO_FIFO) | LIS2DH12_SAMPLES(FIFOBuffSize-1)); //set FIFO mode and FIFO buffer size

}

 

My follow control for reading FIFO buffer:

 

[call My initialization function]

LIS2DH12_setRegisterValue(LIS2DH12_FIFO_CTRL_REG_ADDR, LIS2DH12_FIFO_MODE(LIS2DH12_FIFO_BYPASS) | LIS2DH12_SAMPLES(GSENSOR_CATCH_BUFF_SIZE-1));
LIS2DH12_setRegisterValue(LIS2DH12_FIFO_CTRL_REG_ADDR, LIS2DH12_FIFO_MODE(LIS2DH12_FIFO_FIFO) | LIS2DH12_SAMPLES(GSENSOR_CATCH_BUFF_SIZE-1));


for (;;)
{

 

 

Semaphore_pend(Semaphore_handle(&PedoSemaphore), BIOS_WAIT_FOREVER); //waiting the data

       regValue = LIS2DH12_getRegisterValue(LIS2DH12_FIFO_SRC_REG_ADDR); 

sensorReadReg(LIS2DH12_OUT_X_L_ADDR, readBuffer, 6);

 

LIS2DH12_setRegisterValue(LIS2DH12_FIFO_CTRL_REG_ADDR, LIS2DH12_FIFO_MODE(LIS2DH12_FIFO_BYPASS) | LIS2DH12_SAMPLES(GSENSOR_CATCH_BUFF_SIZE-1));
LIS2DH12_setRegisterValue(LIS2DH12_FIFO_CTRL_REG_ADDR, LIS2DH12_FIFO_MODE(LIS2DH12_FIFO_FIFO) | LIS2DH12_SAMPLES(GSENSOR_CATCH_BUFF_SIZE-1)); 


}

 

Outcomes