cancel
Showing results for 
Search instead for 
Did you mean: 

LSM9DS1 FIFO usage

Zaren
Associate

Hello,

I tried to use FIFO in way to count data ready . My idea to count sample and if it is a 32 sample in FIFO I read all at once. As far I understand, according by datasheet "

Accelerometer and gyroscope multiple reads (burst)" Page 21

Data stores into FIFO in this way

0, OUT_G_X,OUT_G_Y,OUT_G_Z,OUT_XL_X,OUT_XL_Y,OUT_XL_Z

1, OUT_G_X,OUT_G_Y,OUT_G_Z,OUT_XL_X,OUT_XL_Y,OUT_XL_Z

...

31, OUT_G_X,OUT_G_Y,OUT_G_Z,OUT_XL_X,OUT_XL_Y,OUT_XL_Z

That is my setup of sensor

lsm9ds1_fifo_temp_batch_set(IMU_I2C_ADD, 0);
		lsm9ds1_fifo_mode_set(IMU_I2C_ADD, LSM9DS1_STREAM_MODE);
		lsm9ds1_fifo_stop_on_wtm_set(IMU_I2C_ADD, 28);
 
		pin_cfg.int1_drdy_xl= 0;
		pin_cfg.int1_drdy_g = 1;
		pin_cfg.int1_boot   = 0;
		pin_cfg.int1_fth    = 0;
		pin_cfg.int1_ovr    = 0;
		pin_cfg.int1_fss5   = 0;
		pin_cfg.int1_ig_xl  = 0;
		pin_cfg.int1_ig_g   = 0;
		lsm9ds1_fifo_watermark_set(IMU_I2C_ADD, 32);
		lsm9ds1_fifo_watermark_get(IMU_I2C_ADD, &value);
		lsm9ds1_filter_settling_mask_set(IMU_I2C_ADD, 1);
		lsm9ds1_act_mode_set(IMU_I2C_ADD, 0);

This part of function:

unit8_t size_of_sample 6;
unit8_t gyro_and_accel = 2;
uint8_t samples_count = 32;
 
lsm9ds1_fifo_data_level_get(IMU_I2C_ADD, &unread_samples);
PRINTF("FIFO number of samples %d", unread_samples);
lsm9ds1_read_reg(IMU_I2C_ADD, LSM9DS1_OUT_X_L_G, &data[0],  gyro_and_accel  * size_of_sample  * samples_count) );
lsm9ds1_fifo_data_level_get(IMU_I2C_ADD, &unread_samples);
PRINTF("unread_samples %d", unread_samples);
 

Expected print out :

>> FIFO number of samples 32

>> unread_samples 0

But I got

>> FIFO number of samples 32

>> unread_samples 8

Why it is 8 samples? It should be 0

My I2C works on 400Hz

1 ACCEPTED SOLUTION

Accepted Solutions
TSand.1
Associate III

Hi, are you working in FIFO mode or in STREAM mode? You should work in FIFO mode. And you can try to set the STOP_ON_FTH bit with threshold 32, even if it is should be no need if you are already in FIFO mode.

View solution in original post

1 REPLY 1
TSand.1
Associate III

Hi, are you working in FIFO mode or in STREAM mode? You should work in FIFO mode. And you can try to set the STOP_ON_FTH bit with threshold 32, even if it is should be no need if you are already in FIFO mode.