UART vs SPI vs I2C | Difference between UART, SPI and I2C

This page compares UART vs SPI vs I2C interfaces and mentions difference between UART, SPI and I2C in tabular format. It provides comparison between these interfaces based on various factors which include interface diagram, pin designations, data rate, distance, communication type, clock, hardware and software complexity, advantages, disadvanatages etc.

UART Interface

UART interface diagram

Following are the features of UART interface.
• The full name is Universal Asynchronous Receiver/Transmitter.
• UART supports lower data rate.
• Receiver need to know baudrate of the transmitter before initiation of reception i.e. before communication to be established.
• UART is simple protocol, it uses start bit (before data word), stop bits (one or two, after data word), parity bit (even or odd) in its base format for data formatting. Parity bit helps in one bit error detection.
➨UART Packet = 1 start bit(low level), 8 data bits including parity bit, 1 or 2 stop bit(high level)
• Data is transmitted byte by byte.
• UART generates clock internally and synchronizes it with data stream with the help of transition of start bit.
• It is also referred by RS232 .
• For long distance communication, 5V UART is converted to higher voltages viz. +12V for logic 0 and -12V for logic 1.
• The figure-1 depicts UART interface between two devices.
• Refer difference between UART vs USART >>.

SPI Interface

SPI interface diagram

As shown in the figure one slave is connected with one master device. Clock is generated by master device for synchronization of data transfer. It is also possible to connected more than one slave device with single master for communication. SPI interface operates in either half or full duplex mode. SPI is the short form of Serial Peripheral interface. The figure-2 depicts SPI interface between master and slave devices.

It has four main lines as described below.
MOSI - Master Output Slave Input, it is used to transfer data from master device to slave device.
MISO - Master Input Slave Output, it is used to transfer data from slave device to master device.
SCLK - Serial Clock, it is clock output from master and used for synchronization.
SS - Slave Select, it is used by master device to select one slave out of multiple slaves. It inserts active low signal to select the particular slave device.

I2C Interface

I2C interface diagram

• I2C stands for "inter-IC bus". It is also used as I2C for simplicity.
• I2C is a low speed and two wire serial data connection bus used in IC(Integrated Circuit).
• It is used to run signals between ICs mounted on the same PCB (Printed Circuit Board).
• It uses only two lines between multiple masters and multiple slaves viz. SDA (Serial Data) and SCL (Serial Clock).
• I2C supports various data rates as per versions from 100 Kbps, 400 Kbps, 1 Mbps to 3.4 Mbps
• It is synchronous communication like SPI and unlike UART. Hence there is common clock signal between masters and slaves.
• It uses start and stop bits and ACK bit for every 8 bits of data transfer.
The figure-3 depicts UART interface between master and slave devices. Also refer difference between I2C vs I2S >>.

Tabular difference between UART, SPI and I2C

Let us compare UART vs SPI vs I2C and summarize difference between UART, SPI and I2C in tabular format.

Features UART SPI I2C
Full Form Universal Asynchronous Receiver/Transmitter Serial Peripheral Interface Inter-Integrated Circuit
Interface Diagram UART interface diagram SPI interface diagram I2C interface diagram
Pin Designations TxD: Transmit Data
RxD: Receive Data
SCLK: Serial Clock
MOSI: Master Output, Slave Input
MISO: Master Input, Slave Output
SS: Slave Select
SDA: Serial Data
SCL: Serial Clock
Data rate As this is is asynchronous communication, data rate between two devices wanting to communicate should be set to equal value. Maximum data rate supported is about 230 Kbps to 460kbps. Maximum data rate limit is not specified in SPI interface. Usually supports about 10 Mbps to 20 Mbps I2C supports 100 kbps, 400 kbps, 3.4 Mbps. Some variants also supports 10 Kbps and 1 Mbps.
Distance Lower about 50 feet highest Higher
Type of communication Asynchronous Synchronous Synchronous
Number of masters Not Application One One or more than One
Clock No Common Clock signal is used. Both the devices will use there independent clocks. There is one common serial clock signal between master and slave devices. There is common clock signal between multiple masters and multiple slaves.
Hardware complexity lesser less more
Protocol For 8 bits of data one start bit and one stop bit is used. Each company or manufacturers have got their own specific protocols to communicate with peripherals. Hence one needs to read datasheet to know read/write protocol for SPI communication to be established. For example we would like SPI communication between microcontroller and EPROM. Here one need to go through read/write operational diagram in the EPROM data sheet. It uses start and stop bits. It uses ACK bit for each 8 bits of data which indicates whether data has been received or not. Figure depicts the data communication protocol.
I2C data communication protocol
Software addressing As this is one to one connection between two devices, addressing is not needed. Slave select lines are used to address any particular slave connected with the master. There will be 'n' slave select lines on master device for 'n' slaves. There will be multiple slaves and multiple masters and all masters can communicate with all the slaves. Upto 27 slave devices can be connected/addressed in the I2C interface circuit.
Advantages • It is simple communication and most popular which is available due to UART support in almost all the devices with 9 pin connector. It is also referred as RS232 interface.  •It is simple protocol and hence so not require processing overheads.
 •Supports full duplex communication.
 •Due to separate use of CS lines, same kind of multiple chips can be used in the circuit design.
 •SPI uses push-pull and hence higher data rates and longer ranges are possible.
 •SPI uses less power compare to I2C
 •Due to open collector design, limited slew rates can be achieved.
 •More than one masters can be used in the electronic circuit design.
 •Needs fewer i.e. only 2 wires for communication.
 •I2C addressing is simple which does not require any CS lines used in SPI and it is easy to add extra devices on the bus.
 •It uses open collector bus concept. Hence there is bus voltage flexibity on the interface bus.
 •Uses flow control.
Disadvantages • They are suitable for communication between only two devices.
• It supports fixed data rate agreed upon between devices initially before communication otherwise data will be garbled.
 • As number of slave increases, number of CS lines increases, this results in hardware complexity as number of pins required will increase.
 • To add a device in SPI requires one to add extra CS line and changes in software for particular device addressing is concerned.
 •Master and slave relationship can not be changed as usually done in I2C interface.
 •No flow control available in SPI.
 •Increases complexity of the circuit when number of slaves and masters increases.
 •I2C interface is half duplex.
 •Requires software stack to control the protocol and hence it needs some processing overheads on microcontroller/microprocessor.
Reference RS232 Interface>> SPI Interface>> I2C vs I2S Interface>>

what is difference between

difference between UART vs SPI vs I2C
Difference between 100Base-T1 and 1000Base-T1
RS232 vs RS422 vs RS485 interface
LIN vs CAN vs FlexRay vs MOST
Difference between MOST25,MOST50,MOST150

RF and Wireless Terminologies