Serial Peripheral Interface (SPI)
SPI is a synchronous, serial communication protocol. Devices communicating via SPI are said to be in a controller-peripheral relationship. The controller is the controlling device (usually a microcontroller), while the peripheral is a component (a sensor, display, or memory chip) that takes instruction from the controller. The simplest SPI configuration will have a single controller and a single peripheral, but one controller can control more than one peripheral.
One advantage of SPI over UART is that data can be transferred without interruption. Any number of bits can be sent or received in a continuous stream. With UART, data are sent in packets, limited to a specific number of bits with start and stop conditions defining the beginning and end of each packet which results in data interruption during transmission.
The SPI protocol specifies four logic signals, and devices communicating using this protocol have four pins:
- COPI (Controller Out-Peripheral In/): Used to send data from the controller to the peripheral. Earlier called MOSI, see callout below.
- CIPO (Controller In-Peripheral Out): Used to send data from the peripheral to the controller. Earlier called MISO, see callout below.
- CS (Chip Select): Used by the controller to select which peripheral to send data to in a multi-peripheral configuration. The controller can choose which peripheral it wants to send data to by setting the CS pin for that peripheral to a low voltage level keeping the other CS pins at a high voltage level. Earlier called SS, see callout below.
- SLCK/SCK/CLK/SCL: Used for the clock signal. The clock signal synchronizes the transmission of data between controller and peripheral. One bit of data is transferred in each clock cycle, which means the speed of data transfer is determined by the frequency of the clock signal.
Old names for logic signals
It has been agreed by the industry and community to discontinue the use of the terms MOSI (Master Out-Slave In), MISO (Master In-Slave Out), and SS (Slave Select) and in their place use COPI, CIPO, and CS as explained above.
Alternative terms used are:
- SDO – Serial Data Out: An output signal on a device where data is sent out to another SPI device (alternative to COPI).
- SDI – Serial Data In: An input signal on a device where data is received from another SPI device (alternative to CIPO).
Since this change is relatively new, you may find microcontrollers and components using either set of terms.