How can I connect more than 5 or 6 MCP4922 DAC using Raspberry Pi 2 Model B, if it is possible?

I saw SPI SDA GPIO Rspi.

1 Answer 1


There are many ways.

I'd say the simplest is just to ignore the slave select signals used by the SPI driver and use your own.

E.g. say you have 6 DACs.

Find 6 spare GPIO. Let's say you use 22, 23, 24, 25, 5, and 6 (chosen as they are not used by SPI).

Connect DAC 1 slave select to 22
Connect DAC 2 slave select to 23
Connect DAC 3 slave select to 24
Connect DAC 4 slave select to 25
Connect DAC 5 slave select to 5
Connect DAC 6 slave select to 6

Write 1 to all those GPIO to deselect the DAC.

Connect the other SPI lines normally (i.e. MISO, MOSI, SCLK).

Then to talk to, say, DAC 4, write 0 to GPIO 25 to select DAC 4, call the SPI functions you want, write 1 to GPIO 25 to deselect DAC 4.

Repeat as needed for the other DACs.

E.g. in pigpio terms

h = pi.spi_open(0, 100000) # Get handle for all DACs at 100kbps.
                           # Use any legal channel, it will not be used.
# Write to DAC2
pi.write(23, 0) # Select DAC2.
pi.spi_xfer(h, [0, 95]) # Set DAC2 channel 0 to 95.
pi.write(23, 1) # Deselect DAC2.
  • Excuse me! how can I disable Raspberry Pi's CE0 and CE1 pinouts? Have you got any idea or could you share python or C example codes to use regular GPIO pins as chip select pins? Mar 31, 2016 at 6:08
  • Just don't connect CE0 and CE1 to anything. They can toggle away as much as they want but if they are not connected they will do no harm. Alternatively switch them to a mode other than ALT0 (SPI). If you switch them to OUTPUT mode you can use them as one of your slave selects. The SPI hardware will try to switch them but internally the SPI hardware won't be connected to CE0 and CE1 anymore - CE0 and CE1 will only respond to your write commands.
    – joan
    Mar 31, 2016 at 8:10
  • I added an example code snippet to the answer.
    – joan
    Mar 31, 2016 at 8:19

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.