2

I am trying to read the data from an Analog to Digital Converter (ADC), the ADS1248 from texas instrument using the pigpio library in python with the SPI protocol.

When reading the data from the ADC on the MISO line, the manufacturer specified in chapter 9.5.1.3 Data Input (DIN) and 9.5.3. RREG that while that the data is sent on the MISO line, the pi should send a 1 on the MOSI line for every bit received.

In other words, it is a full-duplex communication, and the pi, while receiving data on the MISO from the ADC, should send a series of 1 (it is called a NOP command in the datasheet) on the MOSI. See the image below from the datasheet.

enter image description here

Before testing, I wanted to know if this type of full-duplex communication was supported by the pigpio library. Looking at the method: spi_xfer(handle, data), I understood that method send the data and then catch the response from the selected device.

Is that correct? In that case, how can I establish this sort of full-duplex communication with the pigpio library?

Thanks in advance, Rokual

PS: in chapter 9.5.3 the datasheet says: "A no-operation command (NOP) can be used to clock out data from the device without clocking in a command." So it may not be critical, I am going to try without, but I would like to know if it is possible to do full-duplex with pigpio anyway for future projects :)

2 Answers 2

3

If you want to send 8 NOP bits send a byte containing 0xFF.

count, rx_data = spi_xfer(handle, [0xff])

If you want to send 16 NOP bits send two bytes containing 0xFF.

count, rx_data = spi_xfer(handle, [0xff, 0xff])

Just send high bits for each NOP bit.

1
  • Yep it worked, Thank you for the quick answer!
    – rokual
    Sep 15, 2020 at 12:30
0

Joan's answer worked! enter image description here

  • in green ==> MISO (data from the ADC)
  • in yellow ==> MOSI (data from the pi)

it seems that we are looking at a 24-bit conversion (data rate: 2Mhz) from the ADC (green) and the pi is sending a NOP (yellow) at the same time.

Thanks

Your Answer

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

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