Skip to main content
Visitor II
June 8, 2022
Question

Incorrect LSM303AGR Accelerometer Data

  • June 8, 2022
  • 2 replies
  • 964 views

I'm trying to interface with the LSM303AGR using the 3-wire SPI protocol. I'm polling the registers 0x28 - 0x2D in high-accuracy mode, and what I've noticed is that the least-significant nibble of each axis is occasionally 0x1 instead of 0x0 as expected. I understand that the data needs to be right shifted by one nibble, but I would've expected the least significant nibble to always be 0x0 if the data is 12-bit left-justified. Does this last bit have any significance?

Example data (Queried with 0xE8):

X LSB   X MSB   Y LSB   Y MSB   Z LSB   Z MSB

0x00 0xFE 0x20 0x20 0xC1 0x1A

0x00 0xEF 0x61 0x2F 0x 21 0x9C

0xC1 0xC9 0x41 0xF0 0x61 0x8B

    This topic has been closed for replies.

    2 replies

    ST Employee
    June 10, 2022

    Hi @ESun.1​ ,

    I would agree with you, the last 4 bits should be all 0.

    Did you try to convert a stream of data in physical units and see if you are getting sensible values (e.g. 1g along z axis, and almost 0g along the others when the device is in steady condition)?

    float_t lsm303agr_from_fs_2g_hr_to_mg(int16_t lsb)
    {
     return ((float_t)lsb / 16.0f) * 0.98f;
    }

    -Eleon

    Visitor II
    December 27, 2022

    Hi @ESun.1​ . How do you communicate with 3 wire SPI ? I cant communicate. How did you connet the hardware ? What did you choose SPI mode. Full Duplex or half duplex ? Can you help me ?