Embedded Learning Notes UART Communication Protocol

The UART (Universal Asynchronous Receiver/Transmitter) is a crucial chip used for communication between computers and serial devices. One key feature of the UART is that it provides a data terminal interface, enabling the computer to interact with modems or other serial devices that use an RS-232C standard. As part of this interface, the UART offers several important functions: 1. It converts parallel data from the computer into a serial data stream for transmission. 2. It also receives serial data from external devices and converts it back into parallel data for the computer to process. 3. It adds a parity bit to the outgoing data stream and checks the parity of incoming data to ensure accuracy. 4. It includes start and stop bits in the transmitted data and removes them when receiving data. 5. It manages interrupt signals from devices like keyboards and mice, which are also serial peripherals. 6. It handles synchronization between the computer and external serial devices. 7. It supports asynchronous serial communication, where each character is sent one bit at a time over a single line. As shown in the diagram below, the UART communication protocol works as follows:

Embedded Learning Notes UART Communication Protocol

Here's what each bit represents: - **Start Bit**: A logic "0" signal that marks the beginning of a data frame. - **Data Bits**: These follow the start bit and typically consist of 5 to 8 bits, forming a single character. ASCII is commonly used, and the data is transmitted starting from the least significant bit. - **Parity Bit**: Added after the data bits to check for errors. It can be even or odd parity, depending on the number of "1" bits. - **Stop Bit**: A logic "1" that indicates the end of a character. It can be 1, 1.5, or 2 bits long. - **Idle Bit**: A high-level signal ("1") indicating no data is being transmitted. **Baud Rate** refers to the speed of data transfer, measured in bits per second. For example, if a system sends 120 characters per second, and each character is 10 bits long, the baud rate would be 1200 bps. All these settings—data bits, parity, baud rate, etc.—can be configured through the COM interface or directly by programming the UART registers. Understanding how these registers work is essential for implementing UART communication in embedded systems. Below is a simple example illustrating the UART data transmission process:

Embedded Learning Notes UART Communication Protocol

In the code, the `uart_init` function is used to configure the UART settings. Let’s look at how this function is defined in the system:

Embedded Learning Notes UART Communication Protocol

The UART0 to UART2 registers are available on the development board, and their configuration involves setting various control and status registers such as `rUFCON`, `rUMCON`, `rULCON`, `rUCON`, and `rUBRDIV`. Proper initialization of these registers ensures reliable serial communication between devices.

Handheld Barcode Scanner

Handheld Barcode Scanner,Handheld Scanner,Zebra Handheld Scanner,Honeywell Handheld Scanner

Guangzhou Winson Information Technology Co., Ltd. , https://www.barcodescanner-2d.com

This entry was posted in on