RS232/UART

  • 了解UART

1.serial communication

  Serial communication is a communication method that uses one or two transmission lines to send and receive data, and that data is continuously sent and received one bit at a time.Since it allows for connections with few signal wires, one of its merits is its ability to hold down on wiring material and relaying equipment costs.

2.Serial communication standards

  RS-232C/RS-422A/RS-485 are EIA (Electronic Industries Association) communication standards.Of these communication standards, RS-232C has been widely adopted in a variety of applications, and it is even standard equipment on computers and is often used to connect modems and mice.Sensors and actuators also contain these interfaces, many of which can be controlled via serial communication.
在这里插入图片描述
这三种通讯端口区别:

  • RS232是全双工的,RS485是半双工的,RS422是全双工的。

  • 通讯距离:RS232口最大通讯距离是15米,而RS422/485最大通讯距离是1200米。

  • 所连接设备个数:RS232是为点对点(即只用一对收、发设备)通讯而设计的,适合本地设备之间的通信。 而RS485可以连接多个设备。

  • 端口的定义:RS232是标准接口,为D形9针头,所连接设备的接口的信号定义是一样的。而RS422/RS485为非标准接口,一般为15针串行接口(也有使用9针接口的),每个设备的引脚定义也不一样。

3.RS-232C

  RS232 is a standard protocol used for serial communication, it is used for connecting computer and its peripheral devices to allow serial data exchange between them. As it obtains the voltage for the path used for the data exchange between the devices. It is used in serial communication up to 50 feet with the rate of 1.492kbps. As EIA defines, the RS232 is used for connecting Data Transmission Equipment (DTE) and Data Communication Equipment (DCE).

3.1.Signal assignments and connectors

  In RS-232C, the connectors to use and the signal assignments have been defined and are standardized.The figure to the right describes the D-sub 9-pin signal assignments and signal lines.

在这里插入图片描述
在这里插入图片描述

3.2.Equipment type

  • DCE
    Data communication equipment.This term indicates equipment that passively operates such as modems, printers, and plotters.

  • DTE
    Data terminal equipment.This term indicates equipment that actively operates such as computers.
    在这里插入图片描述

3.3.Half-duplex communication and full-duplex communication

  • Full-duplex communication
    A method where send and receive both have their own transmission line so data can be simultaneously sent and received.

  • Half-duplex communication
    method where communication is performed using one transmission line while switching between send and receive.For this reason, simultaneous communication cannot be performed.

3.4.RS-232缺点

  • 接口的信号电平值较高,易损坏接口电路的芯片。RS232接口任何一条信号线的电压均为负逻辑关系。即:逻辑“1”为-3—-15V;逻辑“0”:+3—+15V,噪声容限为2V。即要求接收器能识别高于+3V的信号作为逻辑“0”,低于-3V的信号作为逻辑“1”,TTL电平为5V为逻辑正,0为逻辑负。与TTL电平不兼容故需使用电平转换电路方能与TTL电路连接。

  • 传输速率较低,在异步传输时,比特率为20Kbps;因此在51CPLD开发板中,综合程序波特率只能采用19200,也是这个原因。

  • 接口使用一根信号线和一根信号返回线而构成共地的传输形式,这种共地传输容易产生共模干扰,所以抗噪声干扰性弱。

  • 传输距离有限,最大传输距离标准值为50英尺,实际上也只能用在15米左右。

4.UART

  通用异步收发传输器通常称作UART,UART是一种通用串行数据总线,用于异步通信。该总线双向通信,可以实现全双工传输和接收。在嵌入式设计中,UART用于主机与辅助设备通信,如汽车音响与外接AP之间的通信,与PC机通信包括与监控调试器和其它器件,如EEPROM通信。

  UART stands for Universal Asynchronous Receiver/Transmitter. It’s not a communication protocol like SPI and I2C, but a physical circuit in a microcontroller, or a stand-alone IC. A UART’s main purpose is to transmit and receive serial data.

  One of the best things about UART is that it only uses two wires to transmit data between devices. In UART communication, two UARTs communicate directly with each other. The transmitting UART converts parallel data from a controlling device like a CPU into serial form, transmits it in serial to the receiving UART, which then converts the serial data back into parallel data for the receiving device. Only two wires are needed to transmit data between two UARTs. Data flows from the Tx pin of the transmitting UART to the Rx pin of the receiving UART.
在这里插入图片描述

4.1.UART 通讯

  UARTs transmit data asynchronously, which means there is no clock signal to synchronize the output of bits from the transmitting UART to the sampling of bits by the receiving UART. Instead of a clock signal, the transmitting UART adds start and stop bits to the data packet being transferred. These bits define the beginning and end of the data packet so the receiving UART knows when to start reading the bits.

  When the receiving UART detects a start bit, it starts to read the incoming bits at a specific frequency known as the baud rate. Baud rate is a measure of the speed of data transfer, expressed in bits per second (bps). Both UARTs must operate at about the same baud rate. The baud rate between the transmitting and receiving UARTs can only differ by about 10% before the timing of bits gets too far off.

  Both UARTs must also must be configured to transmit and receive the same data packet structure.
在这里插入图片描述
4.2.HOW UART WORKS

  The UART that is going to transmit data receives the data from a data bus. The data bus is used to send data to the UART by another device like a CPU, memory, or microcontroller. Data is transferred from the data bus to the transmitting UART in parallel form. After the transmitting UART gets the parallel data from the data bus, it adds a start bit, a parity bit, and a stop bit, creating the data packet. Next, the data packet is output serially, bit by bit at the Tx pin. The receiving UART reads the data packet bit by bit at its Rx pin. The receiving UART then converts the data back into parallel form and removes the start bit, parity bit, and stop bits. Finally, the receiving UART transfers the data packet in parallel to the data bus on the receiving end.
在这里插入图片描述

4.3.数据传输协议

  UART transmitted data is organized into packets. Each packet contains 1 start bit, 5 to 9 data bits (depending on the UART), an optional parity bit, and 1 or 2 stop bits:

在这里插入图片描述
在这里插入图片描述

1>.START BIT

  The UART data transmission line is normally held at a high voltage level when it’s not transmitting data. To start the transfer of data, the transmitting UART pulls the transmission line from high to low for one clock cycle. When the receiving UART detects the high to low voltage transition, it begins reading the bits in the data frame at the frequency of the baud rate.

2>.DATA FRAME

  The data frame contains the actual data being transferred. It can be 5 bits up to 8 bits long if a parity bit is used. If no parity bit is used, the data frame can be 9 bits long. In most cases, the data is sent with the least significant bit first.

3>.PARITY

   describes the evenness or oddness of a number. The parity bit is a way for the receiving UART to tell if any data has changed during transmission. Bits can be changed by electromagnetic radiation, mismatched baud rates, or long distance data transfers. After the receiving UART reads the data frame, it counts the number of bits with a value of 1 and checks if the total is an even or odd number. If the parity bit is a 0 (even parity), the 1 bits in the data frame should total to an even number. If the parity bit is a 1 (odd parity), the 1 bits in the data frame should total to an odd number. When the parity bit matches the data, the UART knows that the transmission was free of errors. But if the parity bit is a 0, and the total is odd; or the parity bit is a 1, and the total is even, the UART knows that bits in the data frame have changed.

4>.STOP BITS

  To signal the end of the data packet, the sending UART drives the data transmission line from a low voltage to a high voltage for at least two bit durations.

4.4.STEPS OF UART TRANSMISSION

1>.The transmitting UART receives data in parallel from the data bus:
在这里插入图片描述
2>. The transmitting UART adds the start bit, parity bit, and the stop bit(s) to the data frame:
在这里插入图片描述
3>. The entire packet is sent serially from the transmitting UART to the receiving UART. The receiving UART samples the data line at the pre-configured baud rate:
在这里插入图片描述
4>. The receiving UART discards the start bit, parity bit, and stop bit from the data frame:
在这里插入图片描述
5>. The receiving UART converts the serial data back into parallel and transfers it to the data bus on the receiving end:
在这里插入图片描述
4.5.ADVANTAGES/DISADVANTAGES

ADVANTAGES

  • Only uses two wires
  • No clock signal is necessary
  • Has a parity bit to allow for error checking
  • The structure of the data packet can be changed as long as both sides are set up for it
  • Well documented and widely used method

DISADVANTAGES

  • The size of the data frame is limited to a maximum of 9 bits
  • Doesn’t support multiple slave or multiple master systems
  • The baud rates of each UART must be within 10% of each other

5.ITOP4412

  A Universal Asynchronous Receiver and Transmitter (UART) in Exynos 4412 SCP provide four independent channels with asynchronous and serial input/output (I/O) ports for general purpose (Ch0 to 3). It also provides a dedicated channel for communication with Global Positioning System (GPS) (Ch4). All the ports operate either in an interrupt-based or a DMA-based mode. UART generates either an interrupt or a DMA request to transfer data to and from CPU and UART. UART supports bit rates up to 4 Mbps. Each UART channel contains two First In First Outs (FIFOs) to receive and transmit data as in:

  • 256 bytes in Ch0
  • 64 bytes in Ch1 and Ch4
  • 16 bytes in Ch2 and Ch3

UART includes:

  • Programmable Baud rates
  • Infrared (IR) transmitter/receiver
  • One or two stop bit insertion
  • 5-bit, 6-bit, 7-bit, or 8-bit data width and parity checking

As shown in Figure 28-1, each UART contains:

  • Baud-rate generator
  • Transmitter
  • Receiver
  • Control unit

  The Baud-rate generator uses SCLK_UART. The transmitter and the receiver contain FIFOs and data shifters.The data to be transmitted is written to Tx FIFO, and copied to the transmit shifter. The data is then shifted out by the transmit data pin (TxDn). The received data is shifted from the receive data pin (RxDn), and copied to Rx FIFO from the shifter.
在这里插入图片描述

refer to
https://www.arcelect.com/rs232.htm
https://circuitdigest.com/article/rs232-serial-communication-protocol-basics-specifications

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值