cancel
Showing results for 
Search instead for 
Did you mean: 

SPI with LIS3DH Accelerometer is not working

Zahme.1
Associate

I am using a PIC32MX250F128B . I am trying to communicate with LIS3DH through SPI connection. I have several other devices like ADC, DAC working with SPI protocol perfectly fine. However the Accelerometer does not.

With the scope my CS, Clock and SDA matches the diagram from datasheet (its sending the correct address of WHO_AM_I register ) but SDO output remains silent. Cant see anything coming out of accelerometer.

I am trying to get the who_am_i register value but the output i am getting is zero.

I have attached a scoped picture of my SPI. I have tried rest of the 3 mode other than the mode mentioned in the datasheet.

Any suggestions or solution from the community would be much appreciated. I have gone through several posts with the same problem but with no solution.

I hope I can get one.

N.B: All my connections are perfectly fine and other SPI connections are also working fine (ADC, DAC). I've also purchased several breakout boards (Adafruit, seedstudio) but that does not work either.

Here in this picture

yellow line : CLK

Pink waveform : SDO

Cyan waveform: SDA

CS is working fine.

0693W00000AOzvGQAT.jpg 

23 REPLIES 23
niccolò
ST Employee

Hi @Zahme.1​ ,

it seems to me that you are reading the wrong address.

judging by the picture, I see on SDA 0xAF (10101111) that is a read of register 2F, while you should be reading 0x0F for the WHO_AM_I.

can you check that?

also, can I ask you which Vdd and Vdd_IO levels are you using?

Niccolò

ABouk.1
Associate III

Hi,

I also have this problem with my LIS3DH. CS is always driven low, MISO is pulled up and I receive 0xFF when I try to read WHO_AM_I register, been stuck on this bug for days now and i need your help.

The signals measured are SCK and MOSI, MISO is always 1.

0693W00000BZxipQAD.jpg

Hi @Community member​ ,

here you are reading 0x1F, that is not the WHO_AM_I register.

Can you try to modify the bytes you are sending?

also, it would be clearer to show every signal (MOSI MISO CLK CS) in the picture, if need further help.

Let me know if you manage to solve the issue

Niccolò

Hi,

Thanks for your answer. I modified the bytes to be sent but still, I am not getting the value holded in WHO_AM_I register.

Here is my configuration :

CS : always low (tied to GND)

CLK : Yellow

MOSI : Pink

MISO : Blue0693W00000BZyU5QAL.jpg

Hi @Community member​ ,

linking the CS to GND is not good practice, I fear this could be a cause of the issue, I never worked with tied CS.

in theory it is possible to work with CS tied to GND, but it is not recommended.

Another thing I would like to ask you is what is the Vdd level at the sensor pin.

(can you check physically with a multimeter, to be sure the level is not too low?)

Niccolò

Hi,

I just measured Vdd with a voltmeter, it gave 3.331V.

According to the datasheet, tying CS to GND will just enable SPI, there is no restriction on setting CS high again.

Hi @Community member​ ,

thanks for confirming that Vdd is ok, I forgot to mention that also Vdd_IO is important, how much is that?

and can you confirm that CLK level is 4.06V and the input is 2.03V? (peak-to-peak values)

regarding CS, you are right, it is just strange for me to work with fixed CS, but let's try to solve this issue regardless.

Niccolò

Hi,

Vdd_IO is also 3.331V, the same wire is feeding Vdd and Vdd_IO.

As for CLK level, the peak-to-peak value is approx 5v.

I managed to lower the CLK frequency to 800 KHz, now the LIS3DH is sending 0x33 everytime I try to read something.

Hi @Community member​ ,

if Vdd_IO is 3.3V, SDA line has to be at least 2.64V (80% of Vdd_IO, as stated in Table 6 of the datasheet).

can you check also that?

Niccolò