Skip to main content
Visitor II
January 20, 2022
Solved

Problems with LIS3DSH, always receiving 0xFF

  • January 20, 2022
  • 1 reply
  • 1911 views

Hi,

so a few months ago I wrote a program to read values from LIS3DSH sensor. It was working good until last week Z axis stopped working, and this week Y axis also. It always sends back 0x8080 values, while X axis is still working great.

I have a custom PCB board with STM32F407VG and LIS3DSH (and more :) ) and this problem only occures on this board - when I put the same program to STM32F407VG - DISC board it works great, thats why I don't think there is a problem with my program or my SPI configuration.

So, I decided to change LIS3DSH to a new one (I can do that because it's changeable on my board). The problem is that new LIS always responds 0xFF to whatever I send to him. To be fair with you, I don't remember now if I had to anything special at the first start up of the old LIS3DSH, but the one doesnt wont to work with the same program that DISC works.

Does anyone had this kind of problem? Or maybe, there is a special config to put at the first start up (but I cant find it)?

Thank you and have a nice day! :)

    This topic has been closed for replies.
    Best answer by bmak

    Hello 2 months later.

    Turned out that two of my sensor were broken... I got a new one and it works perfect with this code. Thanks for your help :)

    1 reply

    ST Employee
    January 31, 2022

    Hi @Maria Bąk​ ,

    if the setup worked for some time and then it stopped more or less suddenly, I suspect in an issue related to some kind of "shock" in the acquisition chain on your custom PCB. It might be related to a damage of the sensor (but I would exclude it, since changing the physical sensor, the issue is still there), or to a damage on the board. This might be related to the an issue there. Did you check the continuity on all the sensors lines to the application processor? Is the LIS3DSH soldered on your board or plugged in some way?

    -Eleon

    bmakAuthor
    Visitor II
    February 3, 2022

    Hi, thanks for your reply.

    Actually, I have another board with the same connections, but a new one that I'm sure isn't damaged, and the problem still occurs.

    So, there is no special setup at the begging?

    Here is my code that works on DISCovery board, but stopped on mine:

    /***/
    //Init
    LIS3DSH_Write(CTRL_REG4, 0x6F);
    LIS3DSH_Write(CTRL_REG1, 0x00);
    LIS3DSH_Write(CTRL_REG2, 0x00);
    LIS3DSH_Write(CTRL_REG3, 0x00);
    LIS3DSH_Write(CTRL_REG5, 0x00); 
    LIS3DSH_Write(CTRL_REG6, 0x00);
     
    while(1){
     outx_l	= 	LIS3DSH_Read(OUT_X_L);
     outx_h	= 	LIS3DSH_Read(OUT_X_H);
     
     outy_l	= 	LIS3DSH_Read(OUT_Y_L);
     outy_h	= 	LIS3DSH_Read(OUT_Y_H);
     
     outz_l	= 	LIS3DSH_Read(OUT_Z_L);
     outz_h	=	LIS3DSH_Read(OUT_Z_H);
    }

    ST Employee
    February 3, 2022

    Hi @Maria Bąk​ ,

    The initialization code looks correct.

    Please check if the SPI you are using on your board is the Mode 3 (CPOL = 1, CPHA = 1), and if it is different from the Discovery one (datasheet, p. 25):

    0693W00000JORSBQA5.png 

    -Eleon