2018-03-12 06:48 AM
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 fullLIS2DH12_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));
}#fifo-buffer-interrupt #lis2dh12 #fifoSolved! Go to Solution.
2018-03-12 07:19 AM
I suppose the problem is in reading 6 bytes in one I2C transaction.
If you want to read multiple bytes in one transaction you have to set the MSB bit of the register address. Please check chapter 6.1.1 in the
.It should be like that:
sensorReadReg(0x80 | LIS2DH12_OUT_X_L_ADDR, readBuffer, 6);
2018-03-12 07:19 AM
I suppose the problem is in reading 6 bytes in one I2C transaction.
If you want to read multiple bytes in one transaction you have to set the MSB bit of the register address. Please check chapter 6.1.1 in the
.It should be like that:
sensorReadReg(0x80 | LIS2DH12_OUT_X_L_ADDR, readBuffer, 6);
2018-03-12 11:31 AM
Hi Miroslav,
You are right. It is workable now.
Thank you for your helping.
Best Regards,
Allen