cancel
Showing results for 
Search instead for 
Did you mean: 

LIS3DH does not output 12-bit high performance resolution as expected.

Kefei Yao
Associate III
Posted on March 09, 2018 at 07:12

The register configuration is as below array which corresponds to ctrl_reg 1-5 of LIS3DH. I read back the ctrl_reg after configure it, the result is correct which means the register is programmed to the value as I wanted. The result I expected is that I could get 12-bit data from OUT_X_L(28h) - OUT_Z_H(2Dh). But the result is I could only get 8-bit data from those registers. The MSB's of the data output registers are always zero. The function I am using to read the acceleration data is copied below as well, where the last parameter of i2c_read as 1 meas burst read. I'm wondering what the problem is to prevent me from getting 12-bit output data. Thanks.

uint8_t ctrl_reg[5]=

{

/* Enable x,y,z accelaration detect, normal mode, with 400HZ odr */

0x77,

/* Enable high pass filter for AOI1 */

0x09,

/* Enable IA1 on INT1 */

0x40,

/* Full Scale 2g, high resolution

0x08,

/* Fifo Disabled */

0x00

};

void accel_read(int16_t* accel)

{

uint8_t buffer[6];

i2c_read(OUT_X_L,buffer,6,1);

accel[0]=(buffer[1]<<8)|buffer[0];

accel[1]=(buffer[3]<<8)|buffer[2];

accel[2]=(buffer[5]<<8)|buffer[4];

}
2 REPLIES 2
Miroslav BATEK
ST Employee
Posted on March 12, 2018 at 10:42

The function accel_read is not correct (you can't shift left by 8 bits in 8 bit variable).

Try this:

accel[0] = ((int16_t)buffer[1]<<8)+(uint16_t)buffer[0];

...

Kefei Yao
Associate III
Posted on March 13, 2018 at 08:43

Please ignore this thread. The sensor we are using is lis3de in stead of lis3dh. So it's no way to get more than 8-bit resolution.