cancel
Showing results for 
Search instead for 
Did you mean: 

How to data from the LSM6DS3 at maximum speed?

JHong.10
Associate

Hi there.

We tried to get data from the LSM6DS3 at maximum speed but data rate of the sensor was always around 400Hz.

Datasheet say 'LSM6DS3 supports up to 6.66kHz'. Then, can I read the raw data at 6.66kHz through SPI communication?

If it is possible, which resistor or setting must be configured?

Our code is down below.

Firstly, initializing LSM6DS3

void lsm6ds3_init(void)
 {
 	
         // CTRL1_XL Write
	TxData[0] = 0x10; // address
	TxData[1] = 0x00; // power down
	HAL_SPI_Transmit(&hspi1,&TxData[0],1,0xff);
        HAL_SPI_Transmit(&hspi1,&TxData[1],1,0xff);
	uint8_t cmd=0x10 ;
	uint8_t ret=SPI_Read(cmd,1,10);
 
	TxData[0] = 0x15; // address
	TxData[1] = 0x00; // highperformance mode
	HAL_SPI_Transmit(&hspi1,&TxData[0],1,0xff);
        HAL_SPI_Transmit(&hspi1,&TxData[1],1,0xff);
	cmd=0x15 ;
	ret=SPI_Read(cmd,1,10);
	 
	//CTRL1_XL 
	TxData[0] = 0x10; //address
	TxData[1] = 0xA0; // value 1010 00 00
        cmd=0x10 ;
	ret=SPI_Read(cmd,1,10);
	HAL_SPI_Transmit(&hspi1,&TxData[0],1,0xff);
        HAL_SPI_Transmit(&hspi1,&TxData[1],1,0xff);
 
	
	// CTRL2_G_XL Write	
	TxData[0] = 0x11; //address
	TxData[1] = 0x80; //value
        cmd=0x11 ;
	ret=SPI_Read(cmd,1,10);
	HAL_SPI_Transmit(&hspi1,&TxData[0],1,0xff);
	HAL_SPI_Transmit(&hspi1,&TxData[1],1,0xff);
         }

Secondly, Getting raw data from the sensor

while(1){
     LSM6DS3_state=LSM6DS3_Read_Status();
     if(LSM6DS3_state&0x01){
	  SensorData[2]=LSM6DS3_ReadXLData(0);
          SensorData[3]=LSM6DS3_ReadXLData(1);
	  SensorData[4]=LSM6DS3_ReadXLData(2);
	  SensorData[5]=LSM6DS3_ReadXLData(3);
	  SensorData[6]=LSM6DS3_ReadXLData(4);
	  SensorData[7]=LSM6DS3_ReadXLData(5);
	  SnsorData[8]=LSM6DS3_ReadGData(0);
	  SensorData[9]=LSM6DS3_ReadGData(1);
	  SensorData[10]=LSM6DS3_ReadGData(2);
	  SensorData[11]=LSM6DS3_ReadGData(3);
	  SensorData[12]=LSM6DS3_ReadGData(4);
	  SensorData[13]=LSM6DS3_ReadGData(5);
          }
}

0 REPLIES 0