I'm looking at building a product that combines over 40 LCD pushbutton switches (example here that communicate via SPI). I've been looking at microprocessors to handle this, but I am running into trouble finding any. The highest that Atmel offers is 12 devices (as found here), and ARM isn't looking better.

What is the best way to go about controlling this many SPI devices? Do I need to link several processors together into a master?

  • 3
    \$\begingroup\$ You do realize that you are not forced to use a dedicated slave select pin? You can actually use any GPIO or scheme you like of generating them, as long as you make sure they are valid in time. So really your limit is the electrical loads on the bus. There are ways you could deal with that, but you might consider a fan-in of slave micros batching data for a master. Or potentially an FPGA, operating multiple busses at the same time and dealing in batch data with the host MCU. \$\endgroup\$ Commented Aug 28, 2016 at 4:34
  • 1
    \$\begingroup\$ You realize that the XMEGA devices your link refers to can handle up to 12 SPI busses as Master, not only 12 SPI clients? You could split the 40 devices over 10 busses for example and should still have enough GPIOs free for slave select lines. But maybe I am missing the point. \$\endgroup\$
    – Rev
    Commented Aug 28, 2016 at 12:22
  • \$\begingroup\$ @ChrisStratton I did not realize that, thanks. I'm a programmer who is trying to get into embedded, so there is plenty of learning to be done. \$\endgroup\$
    – kfriede
    Commented Aug 28, 2016 at 13:34
  • \$\begingroup\$ @Rev1.0 Probably not missing the point, i'm just new to this. So does the "split 40 devices over 10 busses" offer a solution to the Input Capacitance issue that Majenko brought up below? \$\endgroup\$
    – kfriede
    Commented Aug 28, 2016 at 13:35
  • \$\begingroup\$ Can you provide a datasheet that shows typical connections and the SPI protocol that the LCD switch uses? \$\endgroup\$ Commented Aug 28, 2016 at 15:14

3 Answers 3


Either use demultiplexers such as the 74HC138 for the slave select, or use diode-ORs with a matrix select.

Or if the protocol allows for it, you could chain all the buttons together and use one long SPI transfer for all of them.

  • \$\begingroup\$ Now that you say that, the demultiplexer makes total sense. Didn't even cross my mind. Thank you. \$\endgroup\$
    – kfriede
    Commented Aug 28, 2016 at 4:33
  • \$\begingroup\$ As Majenko's answer points out, you'll also want to multiplex the MISO (master in slave out) pins, and demux the MOSI (master out slave in) pins. \$\endgroup\$ Commented Aug 28, 2016 at 13:38
  • \$\begingroup\$ No, you demultiplex slave select and bus the MISO and MOSI lines. The whole point of SS is that you can tie all of the MOSI together and, with the correct slave devices, tie all of the MISO lines together. \$\endgroup\$ Commented Aug 28, 2016 at 15:12

One word of caution when you are using that many SPI devices on a single bus:

  • Input Capacitance.

That number of devices will put a massive amount of capacitance on the bus. Unless you take precautions it will severely limit your maximum bus frequency, and thus the speed at which you can update display contents etc. (Basically the input capacitance coupled with the output impedance of the MCU's IO pins form a low-pass filter turning higher frequency square waves into more like sine waves, which SPI doesn't like - it messes with the timing).

If you are happy to use lower communication speeds then that's fine - however I would recommend splitting the bus into a number of smaller segments and buffering each SCK and MOSI signal to keep the capacitance on each segment to within reasonable levels. An alternative is to use a single high current drive buffer to reduce the output impedance of the SCK and MOSI pins.

  • 2
    \$\begingroup\$ Quite good hint. I'd strongly prefer splitting busses over buffering. This will keep peak currents much lower (only one bus at the time needs to be switching) reducing noise and decoupling issues. \$\endgroup\$
    – carloc
    Commented Aug 28, 2016 at 10:46

There is NO limit to the number of SPI devices that can be hooked together to a single SPI, assuming that there are enough IOs for selecting the right device.

But practically there might be some difficulties when the number is more at higher speeds. But that is rare.

You can connect MISO MOSI and SCK parallely to all devices. But you should connect GPIO of controller to SS(slave select) pin in one to one manner.

Go for GPIO expander or multiplexers only if the number of GPIOs on controller is limited


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.