Analysis and Comparison of UART SPI and I2C
Analysis and Comparison of UART SPI and I2C
Abstract—Nowadays there are many hardware characterized by low power consumption and strong anti-
communications protocols to choose from, UART, SPI, I2C interference ability. Through the working principle and
three protocols are the most representative, they are widely used. characteristics of the above protocols, we get a better solution
They have different characteristics, and how to choose the right in the specific working environment or the general working
choice is a problem that has been bothering people for a long environment and provide new solutions for the application of
time. In this article, the composition of the three protocols, how the protocol in different scenarios, in the pursuit of low-
they work, and their advantages or disadvantages are described power environment solutions or the choice of long-distance
separately. And through the comparison of their transmission transmission, or the pursuit of excellent choices under high-
distance, it will be found that today's SPI protocol can transmit
speed transmission. The entire article aims to offer fresh
a longer distance, in the comparison of transmission rates SPI
protocol has a faster rate but many limited conditions, UART
suggestions for protocol collocation and selection.
has a more stable performance, SPI has a variety of II. UART
transmission modes to choose from. In terms of transmission
power consumption, UART has a huge advantage, Universal Asynchronous Receiver/Transmitter is an
outperforming the other two protocols. Through the article, we Asynchronous serial communication protocol. It is one of the
hope to provide a new way of thinking from the purpose most widely used hardware-to-hardware communication
required for the design. This leads to a new perspective on protocols. Nowadays UART has been used in many
protocol selection applications such as various types of environmental sensors,
wireless communication modules, and so on [1].
Keywords--UART, SPI, I2C
A. Working principle of UART
I. INTRODUCTION UART is a serial communication protocol, that differs
Various communication protocols are available from parallel communication, transmissions in that the
nowadays, each protocol has its own advantages and transmitted data does not reach the receiver at the same time
disadvantages, and the choice of hardware transmission [2]. It is transmitted bit by bit to the receiver via a data line.
protocol is also different in different situations. The topic to This means that its transfer rate may be slower than the
be covered in this post is how to pick a suitable protocol. The transfer rate of the parallel transfer protocol. The
following article discusses a few of the most well-liked transmitter’s TX pin is directly connected with the receiver’s
communication protocols now in use and examines RX pin. Data travels to and from a UART in parallel to the
numerous protocols' properties to determine which are control device, such as microcontrollers and microprocessors.
preferable and superior. UART is a widely used hardware When sending on the TX pin, the transmitter’s UART needs
communication protocol that requires only two data lines to to translate parallel information into serial and transmit it to
complete bidirectional data transmission and does not require the receiver. The receiver receives this data and translates it
clock signals for synchronous operation. It transfers data in back to parallel, then communicate with its controller.
packets, each with a variable size of data. A check digit can Another feature that distinguishes UART from other
be included in the package to guarantee security and integrity communication protocols is that the transmitter and receiver
during data transmission. Synchronization between the are not synchronized through the clock signal. Instead, the
transmitter and receiver is achieved by bit rate, which allows transmitter and receiver synchronize with each other at the
two devices operating at different frequencies to same baud rate. The baud rate is expressed in bits per second
communicate. The SPI protocol is a very fast transmission or bps, it is usually 9600 or 115200.
protocol that allows the master to communicate with the slave
at a higher frequency. The SPI protocol allows only one B. Structure of the UART
master to exist, but multiple slaves can exist. The master is UART transmitted data is organized into packets. Each
responsible for generating a clock signal that is used to packet contains 1 start bit, 5 to 9 data bits, a parity bit (ability
synchronize with its slave. The SPI saves pins by occupying to choose whether to use or not), 1 or 2 or 1/2 stop bits.
only 4 wires in the chip, which also benefits saving PCB START BIT: The UART protocol is in a high-level state
layout space. The I2C protocol is a two-wire serial bus that when the data line is idle. When data transfer starts, the
requires only two bidirectional lines, a serial data line, and a transmitter will change the level of the transmission line from
serial clock line. The bus interface is formed within the chip, high to low for one clock. It is added before the actual data.
optimizing space and cost. It supports multi-master and The receiver detects this change from high to low on the data
multi-slave devices, but only one host is allowed at a time. line and starts receiving the actual data.
The number of I2C protocols connected to the bus is limited
only by the maximum capacitance of the bus. It is DATA BITS: The data bits are the actual data that is
273
Authorized licensed use limited to: BRAC UNIVERSITY. Downloaded on March 18,2024 at 15:58:04 UTC from IEEE Xplore. Restrictions apply.
three SPI buses, one CS, one CLK, and one MOSI/MISO, output since they are on the same signal line as the slave
which means that the input and output of data are the same machine's MISO pins.
data line. The SCLK, SDIO, and CS wires are the only ones
present. A bidirectional port for half-duplex communication Daisy chain configuration is SPI's second connecting
is the SDIO. For instance, ADI's numerous ADC chips enable option. Daisy chaining is the process of serially transmitting
bidirectional transmission. Bidirectional ports should be signal wires from one device to the next until the data reaches
operated by FPGAs with high resistance state Z set when the destination device [6].
utilized as input. The primary drawback of the Daisy chain is that it will
disconnect the slave machine that has a lower priority than
C. Additional information
the device if the slave machine has a single point of failure.
There are several special characteristics shown through The priority for service will be lower for the slave machine
the SPI bus, not only limit to its high-frequency that is further away from the host machine. If necessary,
communication speed but also the daisy chain connection configure the priority going forward and the slave line
type can be shown that SPI is a superior communication detector [6].
protocol.
To avoid a single point of failure causing the entire link
1) Different connection structure to fail, respond quickly if a slave server times out.
SPI has two types of connections. The traditional The SPI shift register is fully utilized in daisy-chain mode
independent slave setup is the first. Each slave requires their when each slave copies input data to output in the subsequent
own CS line. The matching CS signal line is brought down clock cycle. The difference comparison diagram is shown in
while the other CS signal lines are kept high when the host Figure 3.
wants to talk to a certain slave. The MISO pins of the
unselected slave machine must be set up with high-resistance
274
Authorized licensed use limited to: BRAC UNIVERSITY. Downloaded on March 18,2024 at 15:58:04 UTC from IEEE Xplore. Restrictions apply.
there are several addresses with special purposes, which are distance is about 200mm to 300mm without the use of
“0000000 0, 0000000 1, 0000001 X, 0000010 X, 0000011 X, repeaters. As can be seen in the above transmission
00001XX X, 11110XX X, 11111XX X”, has been noted as characteristics, the SPI protocol can be used under the
binary, 10-bit addresses [7]. requirements of the application environment that requires
long-distance transmission. The UART protocol operates at
The i2c simulation and concepts are based on the square different rates under different standards at different transfer
wave oscillation, in which electromagnetic or other rates, with a transfer rate of 20Kbps under RS-232 standards.
interference has not been considered. By using capacitors on Under the RS-422 standard, its transmission rate can reach
both SCL and SDA wire could reduce and filter the noise of 10Mbps. And the longer the transmission distance, the
the wave. However, the character of the capacitor and the smaller the maximum transmission rate. The transfer rate of
charging period would affect by the size of the capacitor. It the I2C protocol has different maximum transfer rates in
is extremely important to consider what size of the capacitor different modes, and its transfer rate is up to 100Kbps in
to use since the clock and data line should reach the logical standard mode. In ultra-fast mode it has a maximum transfer
high voltage, or the massage wouldn’t be recognized [8]. rate of 5Mbps. [10] The transmission rate of the SPI protocol
From Texas Instruments’ suggestion, the capacitor used for can reach up to 50Mbps, but its maximum transmission rate
the I2C bus of each device should follow the 400 pF for both is subject to three conditions: 1. System clock frequency 2.
Standard Mode and Fast Mode and specifies 550 pF for Fast CPU processing SPI data capability 3. Maximum signal
Mode Plus [9]. The following figure 4 shows the waveform. transmission rate allowed by the PCB. If the design requires
high-speed transmission, the SPI protocol's high rate is an
option. If the design requires simple connections and a
streamlined layout, I2C can do it. If the design is designed to
save energy, then UART is the best choice, it consumes much
less power than the other two protocols at 0.0135W.[11]
Figure 4. Operation waveform diagram
VI. CONCLUSION
B. Structure of the I2C
In this experiment, after studying the working principle,
As the I2C bus is resting, both SCL and SDA wires are format description and personality characteristics of UART,
keeping HIGH. When the device is planning to transfer data, we found that: The transmission rate of UART may be lower
SDA would switch to LOW and start transferring data than some parallel protocols, and the transmitter and receiver
through the SDA wire, and the clock wire would provide the are synchronized with each other without any medium. And
clock message to each of the devices. When the device is use packet form in transmission. The most important thing is
planning to stop transferring data, the SDA would switch that UART data transmission only requires two data lines,
from LOW to HIGH while the SCL is in HIGH condition. and it is a full duplex system, although it can only be one-to-
For writing data, the device first sends the stop signal to one, it can have multiple slave machines to achieve one-to-
the bus, reduces the condition of failing to write; then sends many.
the rest signal, the start signal. Send the address of 7 bits, and Then, we analyse all aspects of the SPI protocol and
the slave device would send back a feedback signal. Then conclude that SPI as a full-duplex and high-speed
start transferring data with 8 bits, getting back a feedback communication line can simplify the layout and the host can
signal from the slave as a period. For ending, send a stop change the controller by itself. The fourth line is a full duplex,
signal to the I2C bus, and release the bus in an idle state. while the third line is only half a duplex. It can be configured
C. Flaws of I2C to set the main transmission mode, and the rate is constantly
For several reasons, there are some disadvantages that changing. Chrysanthemum link is undoubtedly a very good
I2C is not suggested to be applicated in long-distance way of application, but the disadvantage is easy to cause the
communication. Though there are some ways that can solve failure of the point.
the bit flip issues, the parasitic capacitance from the PCB or Finally, we reviewed the relevant literature on I2C and
wire cannot be solved as a physical defect. If the material of made a self-perception. I2C can connect multiple Settings
the wire is inferior, the fluctuation of the parasitic with two lines, its characteristics can be changed, and the
capacitance and the resistance of the wire will further affect wave noise can be reduced to a certain extent. Finally, it has
the stability of the i2c bus. If the resistance is too large, the high requirements on wire material, because it will affect the
master cannot parse the data of the slaves, which will lead to stability of the bus, and too much resistance will affect the
a series of unreliable problems. analysis of server data.
V. COMPARISON REFERENCES
The previous chapters describe the working principles [1] Kashyap, B., & Ravi, V. (2020). Universal Verification Methodology
and features of the three protocols, and in this chapter they Based Verification of UART Protocol. Journal of Physics:Conference
Series, 1716(1), 012040.
will be compared in a single direction. In terms of
transmission distance, each of the three protocols has its own [2] Sharma, R., Pandey, B., Jha, V., Saurabh, S., & Dabas, S. (2018).
Input–Output Standard-Based Energy Efficient UART Design on
limited length, and the transmission distance of the UART 90 nm FPGA. System and Architecture, 139–150.
protocol is 15m in general. However, in the design based on [3] Haripriya, D., Kumar, K., Shrivastava, A., Al-Khafaji, H. M. R., Moyal,
RS-485, it is possible to achieve a long-distance transmission V., & Singh, S. K. (2022). Energy-Efficient UART Design on FPGA
of 100m. The SPI protocol is typically a short-range Using Dynamic Voltage Scaling for Green Communication in
transmission protocol that can achieve transmission distances Industrial Sector. Wireless Communications and Mobile Computing,
of more than 1200m in a specially designed environment. I2C 2022, 1–9.
is a short-range transmission protocol whose transmission [4] Slee, V. N. (1976). 27. CPHA Patient Care Data System for Long-Term
275
Authorized licensed use limited to: BRAC UNIVERSITY. Downloaded on March 18,2024 at 15:58:04 UTC from IEEE Xplore. Restrictions apply.
Care Facilities. Medical Care, 14(Supplement), 209–212. [8] Chyre Tuang Sng, T. (2010). Galvanic Isolation Strengthens I2C
[5] Tan Xian-jun & Jin Yan. (2011).I/O Port Software Simulation of three- Communications. Electronic Design, 58(5), 53–57.
wire SPI communication timing. Journal of Zhejiang University of [9] Houde, F. (2018). Why, When, and How to use I2C Buffers. Texas
Technology (05),571-573+585. Instruments. https://www.ti.com/lit/an/scpa054/scpa054.pdf
[6] Whipple, T. (2019). Automated Daisy Chain Generation and [10] Semiconductors, P. (2003). I2c manual. 2003-01. [2015-12-01]
Verification. Additional Conferences (Device Packaging, HiTEC, https://www.nxp.com/docs/en/application-note/AN10216.pdf
HiTEN, and CICMT), 2019(DPC), 001005–001027. [11] Murali, A., Kakarla, H. K., & Anitha Priyadarshini, G. M. (2021).
[7] Leens, F. (2009). An introduction to I2C and SPI protocols. IEEE Improved design debugging architecture using low power serial
Instrumentation &Amp; Measurement Magazine, 12(1), 8–13. communication protocols for signal processing applications.
https://doi.org/10.1109/mim.2009.4762946 International Journal of Speech Technology, 24(2), 291302.
276
Authorized licensed use limited to: BRAC UNIVERSITY. Downloaded on March 18,2024 at 15:58:04 UTC from IEEE Xplore. Restrictions apply.