Arduino with Multiple SPI Slaves?

In most SPI tutorials, we see images which look like this:

When designing a schematic to drive multiple slaves using the Arduino, is it as simple as shown in the above picture (direct wire connections) or does a person need to add in resistors/OR gaates, etc somewhere?

It is just that simple. One bus for all the SCK, MOSI, and MISO lines, and separate SS lines.

It is that simple. If you are confused because the AVR chip only has one SS pin, don't think that way. That's only used if your AVR is acting as the slave, but in our case, the AVR chip is the master. Almost any pin on the AVR chip can be used to select a slave device, thus you can have multiple slave select signals, thus you can have multiple slaves.

frank26080115:
If you are confused because the AVR chip only has one SS pin, don't think that way. That's only used if your AVR is acting as the slave, but in our case, the AVR chip is the master. Almost any pin on the AVR chip can be used to select a slave device, thus you can have multiple slave select signals, thus you can have multiple slaves.

A very good point, which I haven't seen documented often.

It's just that simple.

But! And here's the big gotcha.

Sending data from the Master to the Slave is easy, Slave gets interrupt, deals with data before the next one comes in. Slave has to be interrupt driven, basically.

But sending data to the master is harder. The Master shifts in the request, then has to wait until the Slave understands the request and loads the response into the buffer. It's fastest when it can either synchronously transfer (Slave knew what you wanted ahead of time, and had it in the buffer already) or when the slave is hardware fast so you can send the request for data from the master and immediately shift in the response from the slave.

Thanks everyone. I just didn't want to get a "Surprise! You have to add a resistor/cap/etc in between here and here" after I sent off my designs to a board house. :slight_smile:

joe426:
Thanks everyone. I just didn't want to get a "Surprise! You have to add a resistor/cap/etc in between here and here" after I sent off my designs to a board house. :slight_smile:

Er, read this just in case http://www.sparkfun.com/tutorials/65

I might at least breadboard it first.