Go Down

Topic: ADXL345 SPI problem on FPGA (Read 94 times) previous topic - next topic

techno-rogue

Oct 12, 2017, 05:40 pm Last Edit: Oct 12, 2017, 05:45 pm by techno-rogue
I am unable to communicate with ADXL345 using an FPGA i.e. the accelerometer has its output stuck at zero.I write(MSB = 0) to any configuration register and then read(MSB = 1) back the register value and get all zeros.I wanted a simple implementation of SPI in HDL, and decided to test it out with the ADXL345's 4-wire SPI bus.I have gone through the accelerometer's data sheet, and the supported SPI mode seems to be CPOL = 1, CPHA = 1.

Kindly view the attached simulation (SPI.PNG) and see if there's anything wrong with the timing.The timing axis isn't accurate in the simulation, but I tested the design with SCL from 300KHz to 2.5MHz and it didn't work once.The simulation shows the start,transfer and stop of a typical SPI 2-byte transfer.

After this, I hooked up the design to a logic analyzer(LogicAnalyzerSPI.jpg) which pretty much confirmed the simulation results.Note that the accelerometer remains stuck at zero.

I have no idea what I'm doing wrong and would appreciate help in this regard.

P.S. I know from going through the forums that there are two ADXL345 boards, one with pins on both side of the board and another with pins on only one side.I have tested my design with both the modules.








jremington

This is an Arduino forum and the ADXL345 works perfectly well with them.

Is there an FPGA forum you could try?

techno-rogue

That does make sense, and of course there are forums dedicated to FPGAs elsewhere.I posted this here because this forum already has plenty of stuff on the ADXL345.The point in attaching the logic analyzer diagram was so people here could point out if there's something wrong with my implementation of the SPI protocol i.e. the physical states of the pins/1s and 0s and chip select on each clock cycle or any timing constraints that the design doesn't meet.The  SPI protocol, I think, doesn't change depending on whether the master is an FPGA or an Arduino.

jremington

Grab an Arduino and examine the logic states while it is communicating with the ADXL345.

Go Up