cancel
Showing results for 
Search instead for 
Did you mean: 

Hello! I am currently working with an LSM6DS0 IMU (3D accelerometer + 3D gyroscope), and I would like to use the embedded FIFO in Continuous mode. I have a question regarding the sequence of the samples in the FIFO and what is the proper way to read them

PMylo.1
Associate II

As far as I can understand from the datasheet, the FIFO is shared and there is no guarantee in the sequence of the samples. For instance, accelerometer and gyroscope samples can be interleaved (e.g. first 2 samples are 3-axial accelerometer measurements and then the 3rd sample is a 3-axial gyroscope measurement e.t.c.). Without knowing the exact sequence how can I read data from FIFO? Does the MEMS sensor know that when I read for example from the OUT_X_G it should shift the oldest gyro measurement to the data register so I can read it out? (I suppose not because if the gyro and accel measurements are interleaved in the FIFO how it can keep track of where it is?).

3 REPLIES 3
Eleon BORLINI
ST Employee

Hi @PMylo.1​ ,

Are you referring to LSM6DS0 ("zero") part number or to the LSM6DSO ("o") one? In this second case, I suggest you to read the AN5192 application note, p.100, or to refer to the C drivers examples on Github --> lsm6dso_fifo.c As you can see, this example sets the FIFO in continuous mode:

  /* Set FIFO mode to Stream mode (aka Continuous Mode) */
  lsm6dso_fifo_mode_set(&dev_ctx, LSM6DSO_STREAM_MODE);

Can you compare your code with this example and see whether it matches or not?

-Eleon

PMylo.1
Associate II

Hi @Eleon BORLINI​ ,

I am referring to LSM6DS0 (with a "zero"). I know how to enable the FIFO and set it to Continuous mode, I do it with the following code (in Zephyr RTOS, although the API would be similar to other environments):

i2c_reg_update_byte(data->i2c_master, config->i2c_slave_addr,

                LSM6DS0_REG_CTRL_REG9,

                LSM6DS0_MASK_CTRL_REG9_FIFO_EN,

                (1 << LSM6DS0_SHIFT_CTRL_REG9_FIFO_EN));

i2c_reg_update_byte(data->i2c_master, config->i2c_slave_addr,

                LSM6DS0_REG_FIFO_CTRL,

                LSM6DS0_MASK_FIFO_CTRL_FMODE,

                (LSM6DS0_FIFO_CONTINUOUS_MODE << LSM6DS0_SHIFT_FIFO_CTRL_FMODE));

My concern is the following. Because there is only one common FIFO for both the accelerometer and the gyroscope, the samples inside the FIFO could be interleaved right? For example, the FIFO could look like this:

0693W00000LwTrdQAF.pngAs you can see in the picture above, first we have an accelerometer sample, then a gyroscope one and then a second accelerometer one.

For convenience, let's assume that FIFO has only these 3 samples, therefore:

0693W00000LwTucQAF.png 

My question is if I issue a multi-byte read command to the OUT_X_G register like the following:

i2c_burst_read(data->i2c_master, config->i2c_slave_addr, LSM6DS0_REG_OUT_X_L_G, buf, 6); // 3 axes, 16bit values therefore 6 bytes

Will the device be able to pop the g_x[0], g_y[0], g_z[0] gyroscope sample from the FIFO, although it's not the first one and transmit it to my microcontroller? In addition what happens with the first sample which is an accelerometer one?

From the datasheet it is not clear, how the samples are popped from the FIFO and pushed to the respective registers in order to be transmitted.

PMylo.1
Associate II

Is there any update regarding my question?