Differences and Connections Between SPI, UART, and I2C Buses

Welcome FPGA engineers to join the official WeChat technical group.

Clickthe blue textto follow us at FPGA Home – the best and largest pure FPGA engineer community in China

Differences and Connections Between SPI, UART, and I2C Buses

Differences and Connections Between SPI, UART, and I2C Buses

SPI Bus

SPI (Serial Peripheral Interface) is a high-speed, full-duplex, synchronous, serial communication bus that uses 3 to 4 lines and operates in a master-slave mode, allowing multiple SPI devices to connect with each other.

The SPI device providing the serial clock is referred to as the SPI master, while the other devices are referred to as SPI slaves.

The SPI bus consists of three signal lines: SCLK (serial clock), SDI (serial data input), and SDO (serial data output). When there are multiple slave devices, a chip select line (CS) can be added to control whether a chip is selected, enabling multiple SPI devices to connect on the same bus.

If simulating the SPI bus using GPIO pins, there must be one output pin (SDO), one input pin (SDI), and the other pin depends on the type of device being implemented. If implementing a master-slave device, both input and output pins are needed; if only a master device is to be implemented, only the output pin is necessary; if only a slave device is to be implemented, only the input pin is needed.

SDI – Data input to the master, data output from the slave; SDO – Data output from the master, data input to the slave; SCLK – Clock signal generated by the master; CS – Slave enable signal controlled by the master.

SPI is a protocol that allows one master device to initiate synchronized communication with a slave device, thereby completing data exchange. SPI is a serial protocol, meaning data is transmitted one bit at a time, which is why the SCLK clock line exists to provide clock pulses, with SDI and SDO completing data transmission based on these pulses.

Data output occurs via the SDO line, with data changing on the rising or falling edge of the clock, and being read on the subsequent falling or rising edge. A single bit of data transmission is completed in this manner, and the input follows the same principle.

Thus, at least 8 clock signal changes (one change for both the rising and falling edges) are needed to complete the transmission of 8 bits of data.

This transmission method has an advantage; unlike ordinary serial communication, which continuously transmits at least 8 bits of data at a time, SPI allows for the transmission of data one bit at a time and even allows for pauses. This is because the SCLK clock line is controlled by the master device; when there is no clock transition, the slave device does not collect or transmit data. In other words, the master device can control communication by controlling the SCLK clock line.

SPI is also a data exchange protocol: because the data input and output lines of SPI are independent, it allows for simultaneous data input and output. Different implementations of SPI devices may vary, primarily in the timing of data changes and sampling, with different definitions for sampling on the rising or falling edges of the clock signal. Please refer to the relevant device documentation for specifics.

Lastly, a drawback of the SPI interface is that it lacks designated flow control and acknowledgment mechanisms to confirm whether data has been received.

In point-to-point communication, the SPI interface does not require addressing operations and is simple and efficient due to its full-duplex communication. In systems with multiple slave devices, each slave device requires an independent enable signal, making the hardware slightly more complex than I2C systems. The SPI interface is primarily used in EEPROMs, FLASH, real-time clocks, AD converters, as well as between digital signal processors and digital signal decoders.

Differences and Connections Between SPI, UART, and I2C Buses

UART Bus

UART (Universal Asynchronous Receiver Transmitter) bus is a two-wire, full-duplex, asynchronous serial port with a slower speed. Its structure is much more complex than the synchronous serial ports SPI and I2C, generally consisting of a baud rate generator (which generates a baud rate equal to 16 times the transmission baud rate), a UART receiver, and a UART transmitter, with two wires, one for sending and one for receiving.
Data is transmitted asynchronously, with strict timing requirements for both parties, and the communication speed is not very fast, making it most commonly used in multi-machine communications. If simulating the UART bus using GPIO pins, one input pin and one output pin are required.
UART is a chip used to control the communication between a computer and serial devices, providing an RS-232C data terminal device interface, allowing the computer to communicate with modems or other serial devices using the RS-232C interface.
Most computers contain two RS232-based serial ports. Serial ports are also a common communication protocol for instruments and devices; many GPIB-compatible devices also come with RS-232 ports. Additionally, serial communication protocols can be used to acquire data from remote collection devices.
The concept of serial port communication is very simple, with the serial port sending and receiving bytes bit by bit. Although slower than parallel communication that sends data by byte, serial communication can send data on one wire while receiving data on another. It is straightforward and capable of achieving long-distance communication.
As part of the interface, UART also provides the following functions:
  • Converts parallel data sent from within the computer into an output serial data stream;

  • Converts serial data coming from outside the computer into bytes for use by devices within the computer that use parallel data;

  • Adds parity bits to the output serial data stream and performs parity checks on the incoming data stream;

  • Adds start and stop markers to the output data stream and removes start and stop markers from the received data stream;

  • Handles interrupt signals sent from the keyboard or mouse;

  • Can manage synchronization issues between the computer and external serial devices;

  • Some high-end UARTs provide input and output data buffers; the more recent UART is the 16550, which can store 16 bytes of data in its buffer before the computer needs to process it.

Differences and Connections Between SPI, UART, and I2C Buses

IIC Bus

IIC (Inter-Integrated Circuit) bus is a bidirectional, two-wire (SCL, SDA), synchronous, serial, multi-master interface standard that features collision detection and bus arbitration mechanisms, making it very suitable for short-distance, infrequent data communication between devices.
In the IIC protocol system, when transmitting data, the device address of the destination device is always included, allowing for device networking.
If simulating the IIC bus using GPIO pins and implementing bidirectional transmission, an input/output pin (SDA) is required, along with an output pin (SCL).
The main advantages of the IIC bus are its simplicity and effectiveness. I2C can replace standard parallel buses and connect various integrated circuits and functional modules. It only requires two bus lines: one serial data line (SDA) and one serial clock line (SCL).
IIC is a multi-master bus, where each device on the bus has a unique address. Depending on the capabilities of the device, any device capable of sending and receiving can operate as a master and control the bus. Of course, only one master can operate at any given time; if two or more masters attempt to initiate data transmission simultaneously, collision detection and arbitration prevent data corruption.
A master can control the transmission of signals and clock frequency. The synchronous clock allows devices to communicate over the bus at different baud rates. The synchronous clock can serve as a handshake method for stopping and restarting serial port transmissions.
Since the interface is directly on the components, the I2C bus occupies very little space, reducing the space on the circuit board and the number of chip pins, thus lowering interconnection costs. The bus length can reach up to 25 feet and can support up to 40 components at a maximum transmission rate of 10Kbps.
Serial 8-bit bidirectional data transmission bit rate
Up to 100kbit/s in standard mode
Up to 400kbit/s in fast mode
Up to 3.4Mbit/s in high-speed mode
On-chip filters can eliminate glitches on the bus data line to ensure data integrity. IIC uses pull-up resistors and has weak anti-interference capabilities, generally used for communication between chips on the same board, and less frequently for long-distance communication. The number of ICs connected to the same bus is limited only by the maximum capacitance of the bus, which is 400pF.
—— END ——
Join the development circle and learn together!
Differences and Connections Between SPI, UART, and I2C Buses

Scanto follow

FPGA Home

Differences and Connections Between SPI, UART, and I2C Buses

Welcome FPGA, Embedded, Signal Processing engineers to follow our public account.

Follow me!Engineers!

Differences and Connections Between SPI, UART, and I2C Buses

The largest FPGA technology community in the country

Differences and Connections Between SPI, UART, and I2C Buses

Welcome everyone to join the largest and strongest FPGA WeChat technical group, which has tens of thousands of engineers and a group of engineers who love technology. FPGA engineers here help and share with each other, creating a strong technical atmosphere! Hurry and invite your friends to join!

Differences and Connections Between SPI, UART, and I2C Buses

Press and hold to join the national FPGA technical group!

Differences and Connections Between SPI, UART, and I2C Buses

One of the best Xilinx and Altera chip suppliers in the country!

Platform self-operated, guaranteed quality of imported original products!

Continuously supplying multiple military research institutes and listed companies!

The best FPGA chip prices and the best after-sales service!

With the industry’s top service reputation!

Backed by global top supplier quality standards!

Full range of XILINX orders or stock advantages!

XCVU9P-2FLGB2104I 200PCS

XCVU9P-2FLGA2104I 500PCS

XCVU13P-2FLGB2104I 300PCS

XC7K325T-2FFG900I 1500PCS

XC7K325T-2FFG676I 950PCS

XC7K160T-2FFG676I 850PCS

XC7VX690T-2FFG1927I Coming soon, please reserve!

XC7VX690T-2FFG1761I Coming soon, please reserve!

For more Xilinx model inquiries, please consult us! Thank you! Scan the QR code to get in touch!

Differences and Connections Between SPI, UART, and I2C Buses

Official thanks to brands supporting the FPGA technical group: Xilinx, Intel (Altera), Microsemi (Actel), Lattice, Vantis, Quicklogic, Lucent, and others for their support of the technical group!

Leave a Comment