Hardware flow control RTS in UART with CTS DTR DSR DTE device and DCE device "turn"

Source: Internet
Author: User

In the low-end router using DISP interface to view the corresponding serial port status information, including DCD, DTR, DSR, RTS and CTS, such as five status indicators respectively mean? DCD (Data Carrier Detect-carrier detection) DTR (data Terminal ready, terminal prepared) DSR (data Set Ready), RTS (Request to send) CT S (Clear to send clean send) in these five control signals, DTR and RTS are DTE devices (data terminal equipment, which is the router in the actual application), DSR, CTS and DCD are DCE devices (data circuit termination devices, In practice is a variety of baseband modem) issued. This five control signal negotiation mechanism is as follows: 1, in the router serial port does not configure the Flow control command case, as long as a power, DTR and RTS will be put into effect (that is, as long as a power of the two states up, regardless of the serial port is not connected to the cable), when the router detects the end sent to the DSR, CTS and DCD Three signals, the physical state of the serial port is escalated (any one physical signal is not valid, or, as long as one of the three signals is down, the physical state of the router serial port is in the state of Down). In addition, if the No DETECT DSR-DTR command is configured on the serial port of the router, the DTE side (router) does not detect whether the headend is sent over the DSR and CTS signals, and the physical layer is reported up as soon as the DCD signal is detected. 2, if the router's serial port configuration of the Flow control command (the specific command is FlowControl Auto), RTS and CTS two signals will be used for flow control (router serial port and baseband modem between the data transmission, receive flow control). When data processing is not timely, the two control signals may be in the state of Down

Transferred from: http://blog.csdn.net/zeroboundary/article/details/8966586

Recently too busy, there is no time to write about the ucos-ii transplant, first of all the work is easy to make a mistake in the knowledge points recorded, about the CTS and RTS.

In RS232 the CTS and RTS have a clear meaning, but since Hayes (HAYES) introduced smart Cat (SmartModem) is a bit confusing, but now this meaning for the mainstream, the main chip manufacturers of the UART controller flow control basic use HAYES Modem flow control interpretation.

In RS232, the RTS and CTS are used to switch direction in half-duplex mode, this paper does not explain;

If the UART only RX, TX two signal, to flow control can only be soft-flow control, if there is rx,tx,cts,rts four signal, it is mostly support the hard-flow control of the UART, if there is rx,tx,cts, RTS, DTR,DSR six signal, The possibility of RS232 the standard is relatively large.

Simcom Company's explanation of Rts/cts:

(To note that the difference is not the serial support of the hard-flow control of the rts/cts, do not look for the benefit, and Rui-core micro-debugging hardware flow control, do not make this non-mainstream interpretation of the confusing, the following with small gray font)

RTS is the input side of the module, used for the MCU notification module, whether the MCU is ready, whether the module can send information to the MCU, RTS effective level is low.

CTS is the output of the module for the module to notify the MCU, whether the module is ready, whether the MCU can send information to the module, the effective level of the CTS is low

HAYES the RTS in modem, CTS is used for hardware flow control. The meaning of the RTC and CTS of the UART is now usually referred to as the latter, which is used for hard-flow control.

RTS, CTS for hard flow control:

(now do the serial port use rts/cts must see content, because mtk/)

RTS (Require tosend, send request) is an output signal that indicates that the device is ready to receive data, the low level is active, and the low level indicates that the device can receive data.

The CTS (Clear tosend, send allow) is an input signal that determines whether data can be sent to the other, low-level, and low-level instructions that the device can send data to each other.

Here someone will translate CTS to send permission, I feel really better than translation for clear send. Because the CTS is the other side of the RTS control whether the CTS is allowed to send the function.

Using the AP and modem to use the flow control transceiver Serial Data example:

CTS as input

RTS for output

The CTS of the AP docking the Rts;modem CTS of the modem to the RTS of the AP.

Default startup:

The CTS of the AP is high

The RTS for the AP is low

The CTS of the modem is high but very easy to be pulled low

Low RTS of Modem

Default Sleep Time

The CTS of the modem is high but very easy to be pulled low

The high RTS of modem

Where the CTS used voltmeter to measure the voltage found: in the initial measurement of about 200ms, the high level, and then the voltage is constantly declining, to become low, which indicates that the CTS should be high, this high level is only a quantitative positive charge.

Do not know the chip design, specifications why to write the CTS default is high, CTS is only input, do not need any default AH. And in the case of flow control open, do not receive CTS and RTS, can also be normal 3 lines (RXD/TXD/GND) communication, which indicates that the CTS is low level when rts/cts is not connected. Why the actual use of inconsistent with the chip specification, may be the shell metal cover interference to low level, after all, the module itself, CTS is so close to the low-level metal protection cover, and the CTS is the input port, no pull-down level capability.

The AP communicates with the modem's flow control:

AP serial port when available, will ap-rts pull low, modem-cts detected ap-rts as low, know that the AP serial port is ready to send data;

AP serial port is not available, will ap-rts pull high, modem-cts detected ap-rts as high, know that the AP serial port is not ready, will not put data.

Modem serial port can be used with the interaction is not available when the same reason.

Without serial controller, RTS and CTS functions can be realized with interrupt and normal IO port.

RTS implemented with GPIO, serial port ready to pull low level, serial port busy pull high level

CTS is implemented with interrupts, low levels are detected, serial data is sent out, and high levels are detected to retain serial data until low levels are detected.

Here is an excerpt of useful references on the Web:

Assume that a, B devices communicate, a device's RTS connection B device CTS, a device's CTS connect B device's RTS. The previous signal controls the transmission of the B device, and the rear signal controls the transmission of a device. For the transmission of the B device (a device receiving), if the a device receives the buffer is fast full of the RTS signal (meaning notification B device stop sending), B device through the CTS detected the signal, stop sending; a device receives a buffer after a period of time, issued an RTS signal, indicating that the B device began to send data. A device is sent (b device receives) similar. The above functions can also be implemented by inserting Xoff (special characters) and Xon (another special character) signal into the data stream. A device once received the Xoff sent by the B device, immediately stop sending; Conversely, if you receive the Xon sent by the B device, the data is sent back to the B device. Similarly, b devices are similar, thus achieving speed matching between the receiving and transmitting parties.

Half-duplex directional switching: RS232 uses DTR (Date Terminal ready, Data terminal preparation) to mainstream control over the DSR (data Set ready, which is well-equipped), similar to the aforementioned RTS and CTS. The DTE (Date Terminal equipment, Data terminal device) of the half-duplex communication is the default direction that the DTE receives, the DCE sends, in the case of the DCE (circuitequipment). If the DTE is to send data, an RTS signal must be issued to request the data to be sent. When the DCE is received, the CTS responds to the RTS signal, indicating a response to the request, so that the direction of communication becomes DTE->TCE, while the RTS and CTS signals must be maintained. As can be seen from here, CTS, TRS although also a bit of the meaning of flow control (such as the CTS is not issued, DTE can not send data), but mainly for the direction of switching.

The role of flow control in serial communication

The "flow" mentioned here, of course, refers to data flow. Data in the transmission between two serial ports, often the phenomenon of loss of data, or the processing speed of two computers, such as the communication between the desktop and the microcontroller, the receiving end of the data buffer is full, then continue to send the data will be lost. Now we are on the network through the modem for data transmission, this problem is particularly prominent. Flow control can solve this problem, when the receiving end of data processing, the "no longer receive" signal, the sender stopped sending, until the "can continue to send" signal to send data. Therefore, flow control can control the process of data transmission and prevent the loss of information. The two kinds of flow control commonly used in PC are hardware flow control (including Rts/cts, dtr/cts, etc.) and software flow control Xon/xoff (continuation/stop), respectively.

Hardware flow control

Hardware flow control is commonly used for rts/cts flow control and DTR/DSR (Data terminal readiness/Data Set Ready) flow control.

Hardware flow control must be connected to the corresponding cable, with rts/cts (Request send/clear Send) flow control, the communication on both ends of the RTS, CTS line corresponding to connect, data terminal equipment (such as computers) using RTS to start the modem or other data communication equipment data flow, Data communication devices, such as modems, use CTS to start and pause data streams from the computer. The process for this kind of hardware handshake is that we set a high flag (which can be 75% of the buffer size) and a low flag (which is 25% of the buffer size) at the receiving side buffer size at programming time, and when the amount of data in the buffer is high, we place the CTS line low (logic 0) at the receiving end. When the program on the sending side detects that the CTS is low, it stops sending data until the receiving side buffers the amount of data below the low level and the CTS is placed high. The RTS is used to indicate whether the receiving device is ready to receive data.

The usual flow control is also DTR/DSR (data Terminal ready/Data Set Ready). We will not dwell on it here. Due to the diversity of flow control, I personally think that when the software used flow control, should do detailed instructions, how to wire, how to apply.

Software flow control

Due to the limitation of the cable, we generally do not use the hardware flow control in the general control communication, and the software flow control. Software flow control is generally realized by Xon/xoff. The commonly used method is: when the input buffer in the receiving end of the data volume exceeds the set high, the data sent to the end of the Xoff character (19 or CONTROL-S, the device programming instructions should be elaborated), the sender received the Xoff character immediately stop sending data When the amount of data in the input buffer of the receiving end is below the set low, the Xon character (decimal 17 or control-q) is emitted to the data sender, and the sender begins to send the data immediately after receiving the Xon character. You can generally find out what characters are sent from the device companion source program.

It should be noted that if the transmission of binary data, the flag character may also appear in the data flow caused by misoperation, which is the software flow control defects, and hardware flow control does not have this problem.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Hardware flow control RTS in UART with CTS DTR DSR DTE device and DCE device "turn"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.