0

Just wanted to check my understanding of the SPI0 bus on the pi zero w.

I have a DAC (MCP4921) driving the gate of a MOSFET as a current source for a load in the drain. I also have a ADC (MCP3008) reading the voltage across a 1 Ohm resister connected between the source and ground. In the python code, I would set the value for the DAC to produce a certain gate voltage, and therefore a drain current, and read the current value from the ADC.

Ignoring the need to level shift signals between the +5V chips and +3.3V chips (ie using 2 74HCT125N chips), am I correct in my thinking that I can use one CS signal to control both devices, and connect the input of the DAC to the MOSI pin for SPI0 and the output of the ADC to the MISO pin? Basically, I don't need to use the SPI1 bus, and I can do all the work on the SPI0 bus.

Thanks!

Mark

2
  • 1
    Please show a schematic of your wiring. Your description is a bit confusing.
    – PMF
    Oct 31, 2021 at 12:50
  • you may be able to use the daisy-chain method to minimize the number of connections ... analog.com/en/analog-dialogue/articles/…
    – jsotola
    Oct 31, 2021 at 16:55

1 Answer 1

2

Multiple devices can be connected to a SPI bus (MISO, MOSI, SCLK).

Each device on the bus requires a chip select signal connected to a GPIO. Normally all the chip select signals are high which indicates no device is selected.

To talk to a device you set its chip select low, write to the device via MOSI, and read the results back via MISO. You then set its chip select high to release the device.

You need to have separate chip select lines (GPIO) for the DAC and the ADC.

1
  • 1
    By inversing the CS line for one device, it should be possible to alternatively select either of the two devices using a single pin.
    – PMF
    Oct 31, 2021 at 12:52

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.