cancel
Showing results for 
Search instead for 
Did you mean: 

LIS3MDL SPI reading Sequence

AAYKA.1
Associate II

Hi,

I'm trying to simply read WHO_AM_I (0Fh). OUT_Z_L (2Ch) and OUT_Z_H (2Dh) registers. But output data is only FFh. Also other registers too. What is the data sequence for simple read function? My SPI bus output is MSB first and clock idles low. For WHO_AM_I I'm sending 0F00h.

My schematic and SPI bus views is in the attachement.

Thanks in advence for your support.

Best regards,

7 REPLIES 7
Eleon BORLINI
ST Employee

Hi @AAYKA.1​ , which are the Vdd and VddIO levels in your application? Are you pulling down the CS when you start the SPI communication? Regards

AAYKA.1
Associate II

Hi Eleon,

Vdd and VddIO levels are 3.3V. ​ CS pin is low before start the SPI communication.

Is the master SPI interface well configured? I mean for example the SPI datasize, the SPI polarity, the SPI phase/edge, etc... Regards

AAYKA.1
Associate II

For example I'm sending 0F00h for WHO_AM_I register. MSB first and clock idles high.

AAYKA.1
Associate II

May be I got it wrong about data type. Could you advice me please for WHO_AM_I or OUT_Z_H?

WHO_AM_I (0Fh) register value is 3Dh, while to see the OUT_Z_H varying try to enable OM[1:0] bits in CTRL_REG1 (20h). The SPI read protocol is the following one, so you have to send 16 clock shots and the SDI must contain the bit 0 (R/W) READ bit, which value is 1. For multiple readings the M/S bit has to be 1 too. SO you have to send the value 1F00h for WHO_AM_I reading. Regards

0690X00000BwxTHQAZ.png

AAYKA.1
Associate II

Hi, we have successful communication with sensor. But when we read the raw data from x,y,z axis, we read small values within, say - 1000 to +1000 by orienting sensor 360 degree. In datasheet it says data registers are 16bit in two's complement form. So, we expect to see from -32767 to +32767. Is there any way to increase these raw data values? We have worst case solution which is multiplying this value with a constant, but it results in big deviation even with no rotation.