cancel
Showing results for 
Search instead for 
Did you mean: 

How to communicate with LIS2DE12 (SPI)

luiscarmignotto
Associate II

Hi! I am trying to establish a SPI comm with an LIS2DE12 accelerometer. First, I would like to say that I have checked phase, polarity, msbFirst and CS. I am using an EM9304 as the master of the communication, and the spi clock frequency is aproppriated.

Writing or reading from the sensor, makes it sends an weird symmetrical waveform in to MISO pin.

(This waveform is equal to the LIS2DE12 ID (0X33 = 00110011))

I had tried many different registers (writing and reading) and the sensor only send this signal.

PS: Both images corresponds to clock and MISO. The MOSI signals was checked too and it is sending the correct bytes to the sensor.

0690X000009jv1vQAA.png0690X000009jv1qQAA.png

14 REPLIES 14
Eleon BORLINI
ST Employee

Hi @luiscarmignotto​ , so if you are correctly reading the WHO_AM_I 0Fh register getting 33h, the SPI (4-wires) is set and well running between the master EM9304 and the LIS2DE12. Changing the SPI register, you always get 33h. It seems you are running multiple bit reading, receiving the same... did you remember to correctly set the auto-increment MS bit, and try different register from 0Fh?

0690X000009jwF0QAI.png

Regards

luiscarmignotto
Associate II

Hi Eleon! Thanks for the answer. Could you please give me more details on how to use the MS bit?

​you have to add it at the beginning of the SPI communication. E.g. if you want to READ registers from 20h to 22h (CTRL registers) you have to send as first byte the bit sequence 11001111 and send total 8x4 clock pulse blocks (8 pulses for the address and 3x8 pulses for the 3 registers you want to read). Regards

I think I am using it the right way. If I need to pass some bytes to non sequential registers, I should set MS to 0, right? Is there a minimum delay time between data transactions? Thanks!

Right, for non-sequential registers you have to re-iterate the single-byte SPI​ pattern (with MS = 0). Do you correctly configured the data decoding of the master? Is it possible for you to check another LIS2DE12? Regards

luiscarmignotto
Associate II

Hi! Eleon, these are the prints from the oscilloscope with the MOSI and MISO signals. In the MOSI print, I am sending a write commando to CTRL_REG4 (0x23) and an 8bit data (0x34). In the following pack of bytes, I am trying to read te content of this same register (CTRL_REG4). As you can see, the module keeps sending 0x33 through MISO. 0690X000009k0J6QAI.png 0690X000009k0I8QAI.png

luiscarmignotto
Associate II

I also tried with other LIS2DE12. They all have the same behavior, which is why I imagine the problem is in the way I am using it.

luiscarmignotto
Associate II

Hi, Eleon!

Is there any advice you could give me after seeing the prints?

Thanks in advance.

Eleon BORLINI
ST Employee

​I see.. the MOSI data seems ok and well synchronized... Is the Vdd of the sensor tied with the VddIO? What I could suggest you is to try decrease the Vdd value (which by now seems to be 3.3V)... But what does the second 16 clock pulses sequence of the last screenshot you posted refer to? Regards