1

I'm trying to interface with an ADXL355 accelerometer via SPI on an RPI Zero W, and am unsure about the order that bits are written out via the function spiWrite.

The datasheet for the ADXL355 shows a timing diagram that seems to suggest that the bytes must be sent most significant bit first (see image), but I am unsure whether the spiWrite function observes this, and what the convention is.

Timing diagram for single byte write, ADXL355

2
  • Did you try using the function and have a problem?
    – NomadMaker
    Jul 1, 2022 at 18:52
  • @NomadMaker More a question on how the function formatted its output onto the SPI bus, but it has now been answered :) Jul 4, 2022 at 7:49

1 Answer 1

0

pigpio uses the SPI hardware for the spiRead, spiWrite, and spiXfer commands.

The hardware for the main SPI transmits most significant bit first. The auxiliary SPI defaults to most significant bit first but can be configured to use least significant bit first.

Here I used piscope to show the result of the following pigs commands.

pigs spio 0 50000 0
pigs spix 0 0xf0 0xf 128 1

piscope SPI transfer

2
  • Okay, that answers my question pretty well I think. I was also wondering whether pigpio automatically sends slave select signals, or if it must be done manually with a pin write function? Jul 4, 2022 at 7:49
  • pigpio sets the slave selects as long as you use the default GPIO. If you are using your own GPIO you will have to set them yourself. abyz.me.uk/rpi/pigpio/cif.html#spiOpen
    – joan
    Jul 4, 2022 at 8:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.