SPI Background
The SPI bus is a full-duplex, synchronous serial data link, that provides an efficient, low-cost communications solution. Like I2C, SPI provides good support for communications with low-speed peripheral devices, though is capable of higher data speeds than I2C.
At the simplest level, SPI communications consists of a single bus master connected to a single bus slave.
The bus itself involves four signals:
SCLK
– Serial Clock, generated by the master.
DIN
– Serial Data Input. This is the data written to the slave SPI-compatible device. Data is shifted into the device on the rising edge of the serial clock.
DOUT
– Serial Data Output. This is the data read from the slave SPI-compatible device. Data is shifted out of the device on the falling edge of the serial clock.
CS
– Chip Select for the slave SPI-compatible device. When the master activates this signal (active Low), the slave device is enabled for communications.
DIN
and DOUT
refer to direction from the slave device perspective. These signals are often seen in literature as MOSI
and MISO
respectively.
For each additional slave device added to the communications system, the SCLK
, DOUT
and DIN
lines can be shared, resulting in a common, multiplexed SPI bus. The bus master simply needs to generate a separate device select line for each slave.
By activating a single select line and keeping all others inactive, the master is able to communicate with the required slave over the shared SPI bus.