Skip to main content
Neha Tawale
Associate
Jan 10, 2018 9:32 AM UTC
Question

LIS2DH12 is always returning only 0x80,0x40,0xC0 values in receive buffer of spi

Posted on January 10, 2018 at 10:32

I am trying to interface LIS2DH12 with NRF51822 chip using SPI communication no matter in what way i configure my spi, it is always returning fixed values 0x80,0x40,0xc0 in all six registers for x,y,z co-ordinate.

I am not using FIFO but trying directly to read from register is it right way or should i choose FIFO mode.

thanks in advance.

    This topic has been closed for replies.

    6 replies

    ST Employee
    Jan 10, 2018 9:48 AM UTC
    Posted on January 10, 2018 at 10:48

    To check your SPI communication first try to read who_am_i (0x0F) register, if it works then try to write a value to a register and read it back.

    If this works, please share you sensor configuration and I can check it.

    Neha Tawale
    Associate
    Jan 10, 2018 10:00 AM UTC
    Posted on January 10, 2018 at 11:00

    Thanks for your attention and I am able to read value 0x33 from WHO_M_I register as well as able to write and read from any register.

    This are my MEMS configuration function:

    void MCAL_MEMS_Init()

    {

    int i;

    /* MEMS Configuration Register */

    LIS2DH12_Write( LIS2DH12_REG_CTRL_REG1,0x77);

    for(i=0;i<100;i++);

    LIS2DH12_Write( LIS2DH12_REG_CTRL_REG2,0x00);

    for(i=0;i<100;i++);

    LIS2DH12_Write( LIS2DH12_REG_CTRL_REG4,0x00);

    for(i=0;i<100;i++);

    LIS2DH12_Write( LIS2DH12_REG_CTRL_REG5,0x00);

    for(i=0;i<100;i++);

    LIS2DH12_Write( FIFO_CTRL_REG ,0x00);

    for(i=0;i<100;i++);

    LIS2DH12_Write( TEMP_CFG_REG ,0x00);

    for(i=0;i<100;i++);

    LIS2DH12_Write( INT1_CFG ,0x00);

    for(i=0;i<100;i++);

    }

    Please suggest me if i am doing anything wrong in configuring MEMS registers.

    ST Employee
    Jan 10, 2018 11:26 AM UTC
    Posted on January 10, 2018 at 11:26

    You configuration is correct, only set the CTRL_REG1 is enough to make the sensor work, other registers are in default value.

    Are you sure you you are reading the correct output registers. You wrote that you read 3 values (0x80, 0x40, 0xC0) in all six registers, it doesn't make much sense. What are the values in all six registers? Are they stable?

    Neha Tawale
    Associate
    Jan 11, 2018 3:45 AM UTC
    Posted on January 11, 2018 at 04:45

    Thanks for your attention again and for testing purpose if i check only one register suppose OUT_X_L or any other it will return those values(0x80,0x40,0xc0) which is not right i guess, i am suppose to get variable and not fix values in these registers on movement of the sensor.

    What could be the possible reason if u can tell.

    ST Employee
    Jan 11, 2018 9:20 AM UTC
    Posted on January 11, 2018 at 09:20

    Unfortunately, your explanation is not clear. I think, the sensors works, you only misinterpret the results.

    Please read all six output registers (during movement or in different sensor position) and share the values, I can then check it.

    Visitor II
    Sep 16, 2023 7:06 PM UTC

    I had the same issue using I2C - the XYZ values received by reading 6 bytes in one go were as Neha Tawale described. In my case the solution was to enable automatic incrementation of the address register by adding 0x80 to the address value.