Basic UART, I2C, SPI, CAN, and USB Serial Communication Interfaces

Follow+Star Public Account, don’t miss exciting content

Basic UART, I2C, SPI, CAN, and USB Serial Communication Interfaces

Author | strongerHuang

WeChat Official Account | Embedded Column

This article mainly describes the basic knowledge of communication interfaces such as UART, I²C, SPI, CAN, and USB for beginners.

1Overview

Why talk about serial communication?

Because parallel communication is relatively rare now, it’s basically all serial communication.Today, I will give you a brief overview of common serial communication and related basic principles.Includes: UART, I²C, SPI, CAN, USB, etc.

2Basic Concepts

2.1 UART

UART:Universal Asynchronous Receiver/Transmitter, a universal asynchronous transceiver.

USART:Universal Synchronous/Asynchronous Receiver/Transmitter, a universal synchronous/asynchronous serial receiver/transmitter.

USART can be understood as a communication interface that combines UART and USART, one for synchronous communication and the other for asynchronous communication.

2.2 I²C

I²C:Inter-Integrated Circuit, literally meaning between integrated circuits, it is actually a shorthand for I²C Bus, so it should be called Integrated Circuit Bus in Chinese, which is a type of serial communication bus.

2.3 SPI

SPI:Serial Peripheral Interface, a high-speed, full-duplex, synchronous communication bus.

QSPI is an abbreviation for Queued SPI, an extension of the SPI interface introduced by Motorola, which has a wider application than SPI.

QSPI adds a queuing transmission mechanism based on the SPI protocol, allowing the transmission process to occur without CPU intervention, greatly improving transmission efficiency.

2.4 CAN

CAN:Controller Area Network, a controller area network.

CAN bus is a widely used field bus with great application prospects in industrial measurement and control and industrial automation.

2.5 USB

USB:Universal Serial Bus, a universal serial bus.

USB is an external bus standard that regulates the connection and communication between computers and external devices, and is an interface technology used in the PC field.

3Communication Principles (Basic)

The basic communication principles of these common serial methods are not difficult, and there are many tutorials online. Here, I will consolidate them for you.

3.1 UART

UART communication generally uses 3 lines, although there is also a single-line half-duplex mode.

UART Connection Method:

Basic UART, I2C, SPI, CAN, and USB Serial Communication Interfaces

UART Communication Data Format:

Basic UART, I2C, SPI, CAN, and USB Serial Communication Interfaces

For more detailed content in this section, please refer to the serial communication chapter in “Communication Tutorial 01”.

3.2 I²C

I²C is a serial synchronous communication method, generally using 2 lines (SDA data line, SCL clock line), with one master and multiple slaves.

I2C Wiring Method:

Basic UART, I2C, SPI, CAN, and USB Serial Communication Interfaces

SDA (serial data line) and SCL (serial clock line) are both bidirectional I/O lines, and the interface circuit is an open-drain output. They need to be connected to the power supply VCC through pull-up resistors.When the bus is idle, both lines are at a high level, and the external devices connected to the bus are all CMOS devices, and the output stage is also an open-drain circuit, consuming very little current on the bus.

I2C generally uses an address + data + ACK method, with the basic data format:

Basic UART, I2C, SPI, CAN, and USB Serial Communication Interfaces

3.3 SPI

SPI is widely used, typically as an interface bus for sending data between microcontrollers and small peripherals (such as shift registers, sensors, and SD cards).

SPI communication mainly uses 3 lines (SCK, MOSI, MISO) for communication:

Basic UART, I2C, SPI, CAN, and USB Serial Communication Interfaces

However, SPI is also used for multi-slave communication, in which case an additional CS chip select signal line is added.

Basic UART, I2C, SPI, CAN, and USB Serial Communication Interfaces

Multi-Slave Wiring Method:

Basic UART, I2C, SPI, CAN, and USB Serial Communication Interfaces

Of course, there are also similar multi-slave addressing methods like I2C:

Basic UART, I2C, SPI, CAN, and USB Serial Communication Interfaces

SPI communication protocol is much simpler than I2C, with less data processing.

3.4 CAN

CAN communication is relatively more complex than the previous three types of local networks, both in hardware and software protocols.

I won’t go into detail here; you can follow my public account ‘strongerHuang’ and reply with 【CANOpen Series Tutorial】 for detailed information about CAN from the bottom hardware, protocols, to the upper software.

3.5 USB

I recently wrote about USB-related content:USB4 Specification Officially Released, Transmission Bandwidth Up to 40Gbps

USB is a common type of serial communication interface in life, mainly using 4 lines (D+ D- VCC GND):

Basic UART, I2C, SPI, CAN, and USB Serial Communication Interfaces

The D- or D+ data line of the USB device is connected to a 1.5K ohm pull-up resistor.When the device is plugged into the PC, it will pull up the voltage of the D- or D+ end of the PC. When the PC detects a high level at the D- or D+ end, it knows that a device has been inserted.

If the PC D- end is pulled high, the connected device is a USB low-speed device;If the PC D+ end is pulled high, the connected device is a USB full-speed or high-speed device. Whether it is a full-speed or high-speed device will be determined by the handshake between the PC and the USB device.

Basic UART, I2C, SPI, CAN, and USB Serial Communication Interfaces

USB transmission speeds include: low speed 1.5Mbps (USB1.0 protocol), full speed 12Mbps (USB1.1 protocol), high speed 480Mbps (USB2.0 protocol), and super speed 5Gbps (USB3.0 protocol), etc.

———— END ————

Reply ‘ Communication ‘ or ‘ Embedded Software and Hardware Comprehensive Content ‘ in the backend to read more related articles.

Welcome to follow my public account, reply “Join Group” to join the technical exchange group according to the rules, reply “1024” to see more content.Welcome to follow my video account:

Basic UART, I2C, SPI, CAN, and USB Serial Communication Interfaces

Click “Read Original” to see more shares, and feel free to share, bookmark, like, and view.

Leave a Comment