1
\$\begingroup\$

If there is only one SPI master and 8 SPI slave devices, How to we connect them together?

I am not allowed to have 8 dedicated Slave select pins on the master, nor am i allowed to daisy chain the complete setup

I was asked this question in an interview and i am not able to figure it out.

\$\endgroup\$
  • \$\begingroup\$ What about a MUX for the CS lines? How many Chip Select lines are you allowed? \$\endgroup\$ – Puffafish Apr 16 at 9:12
  • \$\begingroup\$ I am not sure how many are allowed,the Mux is a good idea,but i think the idea is to reduce the chip select pins if we are using a MCU with a low pin count.Can this be done in software?? bit banging.. \$\endgroup\$ – Arun Kumar Apr 16 at 9:15
  • \$\begingroup\$ So you use 4 pins out of the MCU into a MUX to give you your 8 chip select lines. Hence reducing the chip select lines out of the master MCU. \$\endgroup\$ – Puffafish Apr 16 at 9:18
  • \$\begingroup\$ CS pin will go to a 1x8 demux. Select lines will be 3 digital pins of MCU. \$\endgroup\$ – Mitu Raj Apr 16 at 9:31
  • 1
    \$\begingroup\$ @Mitu Raj: If its not too much trouble could you draw me a basic block diagram of it.It would be very help full. \$\endgroup\$ – Arun Kumar Apr 17 at 4:53
2
\$\begingroup\$

To reduce pin count, the normal way would be to use a demultiplexer that take 3 pin binary code and gives out 8 pin individual signals. Such as 74HC251.

That is, you can't use any "automatic /SS" features of SPI but must handle /SS manually by setting 3 pins. Optionally use a 4th pin to the /CS of the demux if you want to shut off all communication with no slave selected.

MOSI, MISO and clock are all connected to all nodes with no logic in between.

\$\endgroup\$
  • 1
    \$\begingroup\$ Without having any sources for the claim, I'd say this is the most common way to deal with multi-slave SPI. It seems far more common than daisy chain. \$\endgroup\$ – Lundin Apr 16 at 9:38
  • \$\begingroup\$ Could you draw me a basic block diagram.it would be very helpful in understanding the pin connections \$\endgroup\$ – Arun Kumar Apr 17 at 4:55
  • \$\begingroup\$ @ArunKumar Read the 74HC251 datasheet and take it from there. There's only one way to use it so it should be mostly self explanatory. \$\endgroup\$ – Lundin Apr 17 at 6:49
  • \$\begingroup\$ Thanks i understood it perfectly.so the 3 inputs S0,S1 and S2 go to the MCU and act as CS combinations(2^3=8 combinations). And the outputs I0 to I7 will go to the 8 slaves. \$\endgroup\$ – Arun Kumar Apr 17 at 8:59
1
\$\begingroup\$

enter image description here

This is the idea, that we were talking about. De-muxing the CS pin using 3 control pins from the MCU, so that only one slave will be selected at a time. It just saves four pins. MOSI, MISO and CLK pins will however be common. A simple 1x8 demux example: 74hc138

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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