Introduction#

Serial Peripheral Interface (SPI) is one of the most widely used serial interfaces between microcontrollers and peripheral ICs, such as sensors, ADCs, DACs, Shift Registers, SRAM, and others including modems. Every SPI system consists of one primary/main device and one or more secondary devices, where the main device initiates the communication by asserting the nth Chip Select (CSn) line. When a secondary device is selected, the primary starts clockingout the data through the Main Out Secondary In (MOSI) line and receives the data through the Main In Secondary Out (MISO) line. The primary sends and receives one bit for every clock edge. One byte can be exchanged in eight clock cycles. The main device finishes communication by de-asserting the CSn line.

SPI CommunicationSPI Communication

SPI Features#

Some of the notable features of SPI protocol are:

  • Full-duplex communication in the default version of this protocol.

  • Push-pull (as opposed to open-drain) provides good signal integrity and high speeds.

  • Higher throughput than I2C or SMBus. Not limited to any maximum clock speed, enabling potentially high speeds for data transfer.

  • Complete protocol flexibility for the bits transferred.

  • Extremely simple hardware interfacing.

  • Uses only four pins on IC packages and wires in board layouts or connectors, fewer than in parallel interfaces.

  • At most, one unique bus signal per device (chip select); all others are shared.

  • Signals are unidirectional allowing for easy galvanic isolation.

  • Simple software implementation.

  • SPI Secondary Interface supports 8-bit and 32-bit data granularity.

  • It also supports the gated mode of SPI clock, and the Low, High and Ultra high-frequency modes.