Embedded Learning Notes UART Communication Protocol

The UART is a chip for controlling computers and serial devices. One thing to note is that it provides a data terminal device interface so that the computer can communicate with a modem or other serial device that uses an RS-232C interface. As part of the interface, the UART also provides the following features:

1. Converting parallel data transferred from the computer to an output serial data stream;

2. Convert serial data from outside the computer to bytes for use by devices that use parallel data within the computer;

3. Adding a parity bit to the output serial data stream and performing parity check on the data stream received from the outside;

4. Add a start and stop mark to the output data stream, and delete the start and stop mark from the received data stream;

5. Handling interrupt signals issued by the keyboard or mouse (the keyboard and mouse ticket are also serial devices);

6. Can handle the synchronization management problem between the computer and the external serial device;

7. Asynchronous serial communication protocol, the working principle is to transfer each character of the transmitted data one by one in serial mode. As shown below:

Embedded Learning Notes UART Communication Protocol

The meaning of each bit is as follows:

Start bit: A signal of logic "0" is sent first to indicate the beginning of the transmitted character.

Data bit: Immediately after the start bit. The number of data bits can be 4, 5, 6, 7, 8, etc., forming one character. Usually ASCII code is used. The transmission starts from the lowest bit and is located by the clock.

Parity: After the data bit is added to this bit (following the end of the data bit), the number of bits in the "1" should be even (even parity) or odd (odd parity) to verify the data. The correctness of the transmission.

Stop bit: It is the end of a character data. It can be a high level (logic "1") of 1 bit, 1.5 bits, and 2 bits.

Idle bit: In the logic "1" state, indicating that there is no data transfer on the current line.

Baud rate: A pointer to measure the data transfer rate. Expressed as the number of bits (bits) transmitted per second. For example, if the data transfer rate is 120 characters/second and each character is 10 bits, the baud rate of the transfer is:

10&TImes; 120%20=%201200 characters/second=1200 baud.

The above data bits, parity bits, baud rate, etc. can all be set in the COM interface. It is also possible to set the bits of the UART register in the code, and the meaning of each bit of the UART register.

Here are a few small programs to understand the process of data transmission by the UART communication protocol:

Embedded Learning Notes UART Communication Protocol

Here we use the uart_init function to complete the UART bit settings, now let's see how uart_init is defined in the system:

Embedded Learning Notes UART Communication Protocol

UART0 --- UART2 is the three registers provided by the development board. The UART register is set by the assignment of pins such as rUFCON, rUMCON, rULCON, rUCON, rUBRDIV.

Air Glow

original Air glow vape, many new style ,direct factory wholesale,High quality,new design.
popular in many maofferrtket.
offer sample for you check,please contact with me.

Air Glow Blastoff

Shenzhen Ousida Technology Co., Ltd , https://www.osdvape.com