Background:
Raspberry Pi 2B to get the vibration data in ADcmXL3021 sensor via SPI, in RTS mode.
ADcmXL3021 datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/ADcmXL3021.pdf
Issue:
When I send the command to the sensor, most data are 0s, as the data format should be

And the data I get as below:

As I show above, the data I get should have 200 bytes, include the header 0xAD00, -x -y -z Vibration data and Temperature data, CRC bits. But now seems like almost all 0s.
Hardware connection:
ADcmXL3021 is powered by individual power supply(3.3V,30.6mA)
|
NO |
Raspberry Pi 2B |
ADcmXL3021 |
|
1 |
SPICE0 |
CS |
|
2 |
SPICE1 |
SYNC/RTS |
|
3 |
SPI MISO |
DOUT |
|
4 |
SPI MOSI |
DIN |
|
5 |
SPI SCLK |
SCLK |
CS set as low, SYNC/RTS set as high(RTS need this pin high to keep conversion active).
Use python spidev for SPI communication, code as below:
=======================================================
# -*- coding:utf-8 -*-
#for ADcmXL3021 Sensor data acquistion
import time
from spidev import SpiDev
spi=SpiDev() #build a slave
spi.open(0,0) #Raspberry Pi SPICE0 Pin(the other is SPICE1), this is for CS
spi.mode=0b11 #RTS mode (SPI mode3)
spi.max_speed_hz=7800000 #for Raspberry Pi is 7.8,15.6MHz, but for ADc should be 12.5~14MHz, so I set as 7.8M, as a little slower should be ok
spi.lsbfirst = False #msb,high bits first
spi.cshigh=False #cs set as low
spi.bits_per_word=8 #Raspberry only support 8 bits, even ADc output data is 16 bits, I think just need to combine 2 received data
spi.writebytes([0xBE,0x08,0x00]) #send command to get the data
time.sleep(0.012) #12ms delay between command and data receiving
data=spi.readbytes(200) #read data in RTS mode,and then conbine 2 data into 1(here I not give out the code as I think it's easy to do)
print(data)
==================================================================
Here, why I send the command is form the info in datasheet:

1011 1110 0000 1000 0000 0000:0XBE 0x08 0x00
From my side, maybe it’s caused by the commands format I send to the sensor is wrong.
also, different from other register map, the map of ADcmXL3021, has 7 pages, not sure how to send the command to tell the sensor which page I select, as I think before write and read to the register, need to give the register is in which page.
Hope you can share your point, many thanks.
Edit Notes
forget to post the timing diagram[edited by: WallXu at 3:51 AM (GMT 0) on 22 Sep 2019]