cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with LIS3DSH, always receiving 0xFF

bmak
Senior

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! :)

1 ACCEPTED SOLUTION

Accepted Solutions

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 :)

View solution in original post

8 REPLIES 8
Eleon BORLINI
ST Employee

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

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);
}

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

Hi Eleon,

my SPI is in correct mode. I did some testing and i connected Discovery board with two additional LIS3DSH throughout SPI. I connected all the lines together, except MISO lines. Then on oscilloscope I looked at signals, and:

  • LIS3DSH on Discovery board is working great, I can see on oscilloscope that readings from registers OUTX, OUTY, OUTZ are "moving" which is correct.

0693W00000JOWTEQA5.jpg

  • LIS3DSH on one of my boards that worked before (but now stopped) is working great on X axis, Y axis isn't moving at all, always 0x8080, and Z axis looks like its readings are moved, because it often shows maximum range (2g) but when i move my board it changes to lower values (still, although readings are moving, it doesnt look correct)

0693W00000JOWTTQA5.jpg

  • LIS3DSH on another board, new one, always 0xFF, doesn't respond to anything.

0693W00000JOWUlQAP.jpgI also tried changing boards with LIS in places, but as I thought it didn't change a thing.

For now I don't have an idea what can cause this, I thought that maybe my board broke, and I need a special config for a new one, but if you say that there isn't such thing I have no clue.

Here is a photo of my test circuit.

0693W00000JOWSfQAP.jpgThank your very much that you are trying to help me! :)

Hi @Maria Bąk​ ,

I know this is a dummy suggestion, but did you check the cables and connections are OK? I mean, you can check if the MOSI is stable before and after the cables, and check if the issue on the MISO can be related to this.

-Eleon

Yeah, everything looks okay. I will try to figure it out, maybe this or next week. Right now I think I need a little break from LIS, maybe something will come up to my mind in a few days. Of course I will post my solution if I will get one :)

Thank you so much for your help!

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 :)

Hi @Maria Bąk​ ;

better late than never ;)

Thank you for sharing the root cause of the issue.

I hope that the two sensors have been broken during an improper soldering phase of the custom PCB board, or due to the exceeding of the absolute maximum ratings described in the LIS3DSH datasheet p.10.

-Eleon