A Serial Peripheral Interface (SPI) is used for short-distance communication, particularly in embedded systems. A more common serial communication protocol is I2C, which facilitates communication between electronic components, whether the components are on the same PCB or connected with a cable.
Selecting between I2C and SPI, the two main serial communication protocols, requires a solid understanding of the advantages and limitations of I2C, SPI, and the application. Each communication protocol has distinct advantages that tend to distinguish themselves as they apply to your application.Ach5SPI
Better for high speed and low power applications.
Not an official standard—generally less compatible.I2C
Better for communication with several peripherals and changing of the primary device role.
Standardization ensures better compatibility.
SPI is better for high speed, low power applications. I2C is better suited for communication with a large number of peripherals. Both SPI and I2C are robust, stable communication protocols for embedded applications that are well suited for the embedded world.TEK IMAGE / Getty Images
SPI Pros and ConsAdvantages
Supports higher speed full-duplex communication.
Very low power.Disadvantages
Short transfer distances, can't communicate between components on separate PCBs.
Several variants and customizations can create compatibility problems.
Requires additional signal lines to manage multiple devices on the same bus.
Does not verify that data is received correctly.
More susceptible to noise.
Serial to Peripheral Interface is a very-low-power four-wire serial communication interface. It is designed so that IC controllers and peripherals can communicate with each other. The SPI bus is a full-duplex bus, which allows communication to flow to and from the primary device simultaneously at rates of up to 10 Mbps. The high-speed operation of SPI generally limits it from being used to communicate between components on separate PCBs because of the increase in capacitance that longer-distance communication adds to the signal lines. PCB capacitance can also limit the length of SPI communication lines.
While SPI is an established protocol, it is not an official standard. SPI offers several variants and customizations that lead to compatibility problems. SPI implementations should always be checked between primary controllers and secondary peripherals to ensure that the combination won't have unexpected communication problems that affect the development of a product.
I2C Pros and ConsAdvantages
Supports multiple devices on the same bus without additional select signal lines through in-communication device addressing.
The official standard provides compatibility among I2C implementations and backward compatibility.
Ensures that data sent is received by the secondary device.
Can transmit off the PCB, but at low transmission speeds.
Cheaper to implement than the SPI communication protocol.
Less susceptible to noise than SPI.
Transmit data over greater distances.Disadvantages
Slower transfer speeds and data rates.
Can be locked up by one device that fails to release the communication bus.
Draws more power than SPI.
I2C is an official standard serial communication protocol that only requires two signal lines that were designed for communication between chips on a PCB. I2C was originally designed for 100 kbps communication. Still, faster data transmission modes have been developed over the years to achieve speeds of up to 3.4 Mbps. The I2C protocol has been established as an official standard, providing good compatibility among I2C implementations and good backward compatibility.
In addition to the above list of pros and cons, I2C requires only two wires. SPI requires three or four. Furthermore, SPI only supports one primary device on the bus while I2C supports multiple primary devices.
Selecting Between I2C and SPI
Overall, SPI is better for high speed and low power applications, while I2C is better suited for communication with a large number of peripherals, as well as in situations involving dynamic changing of the primary device role among peripherals on the I2C bus.