cancel
Showing results for 
Search instead for 
Did you mean: 

LSM6DS3 fifo read via i2c

thejas
Associate II

I have been reading a 780 samples from lsm6ds3 FIFO via i2c (i2c_dev driver from linux) but the read is taking arround ~1.5 to 2 sec. this seems little unusual to me . is there any way to reduce the i2c read time ?.

Here is my read function:

static int32_t i2c_read_low_latency(int file,__u8 reg,__u8 *buff,__u16 len)
{
	buff[0]=reg;
	int temp=write(file, buff, 1);
	temp=read(file, buff, len);
	if ( temp!= len) {
	    /* ERROR HANDLING: i2c transaction failed */
		printf("i2c transaction error \n");
	  }
	return temp;
}

This is the fifo read pseudo code:

for(780 samples in FIFO )
{
      i2c_read_low_latency(fd_i2c4,LSM6DS3_FIFO_DATA_OUT_L,ch1,2);  //read XLx
      i2c_read_low_latency(fd_i2c4,LSM6DS3_FIFO_DATA_OUT_L,ch2,2); //read XLy
      i2c_read_low_latency(fd_i2c4,LSM6DS3_FIFO_DATA_OUT_L,ch3,2); //read XLz
}

2 REPLIES 2
Eleon BORLINI
ST Employee

Hi @thejas​ , please note that FIFO samples are read at ODR rate, and if the ODR is set to 400Hz, you will read 780 different samples in about 2sec. The single-sample I2C communication can of course go much higher. If you want to speed up the communication, you can set the ODR at maximum speed 6.66kHz (ref. to p.53 and sgg fo the ds, but note that you should be limited in frequency BW at 1.66kHz). Regards

but fifo is filled at odr min(XL, GY). data sheet does not telling about reading ODR or reading speed