ST micro LIS3LV02DL accelerometer interfacing
hi,
i am trying to read data from an accelerometer (ST micro LIS3LV02DL) through SPI.
I used shiftin and shiftout command in picbasic pro but not able to read data. I have read the datasheet quite a few times but not able to get how to use SPI. I am basically confused in using SPI.
any help is solicited.
here's the data sheet: http://www.st.com/stonline/products/...e/ds/12094.pdf
here's my program:
INCLUDE "modedefs.bas"
CS VAR PORTB.4
CLK VAR PORTB.3
DI VAR PORTB.2
DO VAR PORTB.2
BUFF VAR WORD
ATM CON $32
MSB CON $AC
LSB CON $F3
START
GOSUB GETDATA
GOTO START
GETDATA
Low CS
Shiftout DI,CLK,MSBFIRST,[ATM,MSB,LSB]
Shiftin DO,CLK,MSBPRE,[BUFF]
High CS
serout PORTA.2,N2400,[BUFF]
RETURN
END
-Thanks