Friday, March 24, 2017
What is Slave Select SS in SPI
What is Slave Select SS in SPI
Theres one last line you should be aware of, called SS for Slave Select. This tells the slave that it should wake up and receive / send data and is also used when multiple slaves are present to select the one youd like to talk to.
The SS line is normally held high, which disconnects the slave from the SPI bus. (This type of logic is known as active low, and youll often see used it for enable and reset lines.) Just before data is sent to the slave, the line is brought low, which activates the slave. When youre done using the slave, the line is made high again. In a shift register, this corresponds to the latch input, which transfers the received data to the output lines.
Multiple slaves
There are two ways of connecting multiple slaves to an SPI bus:
- In general, each slave will need a separate SS line. To talk to a particular slave, youll make that slaves SS line low and keep the rest of them high (you dont want two slaves activated at the same time, or they may both try to talk on the same MISO line resulting in garbled data). Lots of slaves will require lots of SS lines; if youre running low on outputs, there are binary decoder chips that can multiply your SS outputs.
- On the other hand, some parts prefer to be daisy-chained together, with the MISO (output) of one going to the MOSI (input) of the next. In this case, a single SS line goes to all the slaves. Once all the data is sent, the SS line is raised, which causes all the chips to be activated simultaneously. This is often used for daisy-chained shift registers and addressable LED drivers.
Note that, for this layout, data overflows from one slave to the next, so to send data to any one slave, youll need to transmit enough data to reach all of them. Also, keep in mind that the first piece of data you transmit will end up in thelast slave.
This type of layout is typically used in output-only situations, such as driving LEDs where you dont need to receive any data back. In these cases you can leave the masters MISO line disconnected. However, if data does need to be returned to the master, you can do this by closing the daisy-chain loop (blue wire in the above diagram). Note that if you do this, the return data from slave 1 will need to pass through all the slaves before getting back to the master, so be sure to send enough receive commands to get the data you need.
Source :https://learn.sparkfun.com/tutorials/serial-peripheral-interface-spi/slave-select-ss
Available link for download