ARM study notes 15-basic principles of serial communication

Publisher:asa1670Latest update time:2020-02-18 Source: eefocusKeywords:ARM Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Basic theory of computer serial port

 

1. What is a serial port?

2. What is RS-232?

3. What is RS-422?

4. What is RS-485?

5. What is a handshake?

 

1. What is a serial port?

Serial ports are a very common protocol for device communication on computers (not to be confused with Universal Serial Bus or USB). Most computers contain two serial ports based on RS232. Serial ports are also a common communication protocol for instrumentation devices; many GPIB-compatible devices also have RS-232 ports. Serial port communication protocols can also be used to obtain data from remote acquisition devices.

 

The concept of serial communication is very simple. Serial ports send and receive bytes by bit. Although slower than parallel communication by byte, serial ports can send data on one line while receiving data on another line. It is simple and can achieve long-distance communication. For example, when IEEE488 defined the parallel communication state, it stipulated that the total length of the device line should not exceed 20 meters, and the length between any two devices should not exceed 2 meters; for serial ports, the length can reach 1200 meters.

 

Typically, serial ports are used to transmit ASCII characters. Communication is accomplished using three wires: (1) ground, (2) transmit, and (3) receive. Since serial communication is asynchronous, the port can send data on one wire while receiving data on another. The other wires are used for handshaking, but are not required. The most important parameters for serial communication are the baud rate, data bits, stop bits, and parity. For two ports to communicate, these parameters must match:


a. Baud rate: This is a parameter that measures the speed of communication. It indicates the number of bits transmitted per second. For example, 300 baud means 300 bits are sent per second. When we mention the clock cycle, we are referring to the baud rate. For example, if the protocol requires a 4800 baud rate, then the clock is 4800Hz. This means that the sampling rate of the serial communication on the data line is 4800Hz. Common baud rates for telephone lines are 14400, 28800 and 36600. The baud rate can be much larger than these values, but the baud rate is inversely proportional to the distance. High baud rates are often used for communication between instruments that are placed very close to each other. A typical example is the communication between GPIB devices.


b. Data bits: This is a parameter that measures the actual data bits in communication. When a computer sends a packet of information, the actual data will not be 8 bits. The standard values ​​are 5, 7, and 8 bits. How to set it depends on the information you want to transmit. For example, the standard ASCII code is 0 to 127 (7 bits). The extended ASCII code is 0 to 255 (8 bits). If the data uses simple text (standard ASCII code), then each data packet uses 7 bits of data. Each packet refers to a byte, including start/stop bits, data bits, and parity bits. Since the actual data bits depend on the choice of communication protocol, the term "packet" refers to any communication situation.


c. Stop bit: used to indicate the last bit of a single packet. Typical values ​​are 1, 1.5 and 2 bits. Since data is timed on the transmission line and each device has its own clock, it is likely that there will be a small desynchronization between the two devices during communication. Therefore, the stop bit not only indicates the end of the transmission, but also provides an opportunity for the computer to correct the clock synchronization. The more bits are applied to the stop bit, the greater the tolerance for different clock synchronization, but the data transmission rate is also slower.


d. Parity bit: A simple error detection method in serial communication. There are four error detection methods: even, odd, high and low. Of course, no parity bit is also possible. For even and odd parity, the serial port will set the parity bit (the bit after the data bit) with a value to ensure that the transmitted data has an even or odd number of logical high bits. For example, if the data is 011, then for even parity, the parity bit is 0, ensuring that the number of logical high bits is an even number. If it is odd parity, the parity bit is 1, so there are 3 logical high bits. The high and low bits do not actually check the data, and simply set the logic high or logic low check. This allows the receiving device to know the state of a bit and have the opportunity to determine whether noise interferes with communication or whether the transmission and reception of data are not synchronized.

 

2. What is RS-232?

RS-232 (ANSI/EIA-232 standard) is the serial connection standard for IBM-PC and its compatible machines. It can be used for many purposes, such as connecting a mouse, printer or modem, and can also connect industrial instruments. It is used for driver and wiring improvements. In actual applications, the transmission length or speed of RS-232 often exceeds the standard value. RS-232 is limited to point-to-point communication between PC serial ports and devices. The maximum distance of RS-232 serial communication is 50 feet.

 

DB-9 pin connector

-------------

/ 1 2 3 4 5 /

/ 6 7 8 9 /

-------

The cross section of the line connected from the computer.

Functions of RS-232 pins:

 

data:

TXD (pin 3): serial port data output

RXD (pin 2): serial port data input

 

shake hands:

RTS (pin 7): Send data request

CTS (pin 8): Clear to Send

DSR (pin 6): Data send ready

DCD (pin 1): Data Carrier Detect

DTR (pin 4): Data Terminal Ready

 

Ground Wire:

GND (pin 5): ground wire

 

other

RI (pin 9): Ring Indicator

 

3. What is RS-422?

RS-422 (EIA RS-422-A Standard) is the serial port connection standard for Apple's Macintosh computers. RS-422 uses differential signals, while RS-232 uses unbalanced ground reference signals. Differential transmission uses two wires to send and receive signals. Compared with RS-232, it has better noise immunity and longer transmission distance. Better noise immunity and longer transmission distance are a great advantage in industrial environments.

 

4. What is RS-485?

RS-485 (EIA-485 standard) is an improvement over RS-422 because it increases the number of devices from 10 to 32 while defining electrical characteristics at the maximum number of devices to ensure adequate signal voltage. With multiple device capabilities, you can build a network of devices using a single RS-422 port. With excellent noise immunity and multi-device capabilities, RS-485 is the serial connection of choice when building a distributed device network connected to a PC, other data collection controller, HMI or other operation in industrial applications. RS-485 is a superset of RS-422, so all RS-422 devices can be controlled by RS-485. RS-485 can use more than 4000 feet of wire for serial communication.

 

DB-9 Pin Connection

 

-------------

/ 1 2 3 4 5 /

/ 6 7 8 9 /

-------

 

The cross section of the line connected from the computer.

 

Functions of RS-485 and RS-422 pins

Data: TXD+ (pin 8), TXD- (pin 9), RXD+ (pin 4), RXD- (pin 5)

Handshake: RTS+ (pin 3), RTS- (pin 7), CTS+ (pin 2), CTS- (pin 6)

Ground: GND (pin 1)

 

5. What is a handshake?

The RS-232 communication method allows for a simple connection of three wires: Tx, Rx, and ground. However, for data transmission, both parties must use the same baud rate for data timing. Although this method is sufficient for most applications, its use is limited in cases where the receiver is overloaded. This is when the serial port's handshake function is needed. In this section, we discuss the three most commonly used RS-232 handshake forms: software handshake, hardware handshake, and Xmodem.

 

a. Software handshake: The first type of handshake we discuss is software handshake. It is usually used when the actual data is control characters, similar to the way GPIB uses command strings. The required wires are still three: Tx, Rx and ground. Because control characters are no different from ordinary characters on the transmission line, the function SetXModem allows the user to enable or disable the use of two control characters XON and XOFF. These characters are sent by the receiver in the communication to make the sender pause.


For example: suppose the sender is sending data at a high baud rate. During the transmission, the receiver discovers that the input buffer is full because the CPU is busy with other work. To temporarily stop the transmission, the receiver sends XOFF, a typical value of decimal 19, or hexadecimal 13, until the input buffer is empty. Once the receiver is ready to receive, it sends XON, a typical value of decimal 17, or hexadecimal 11, to continue communication. When the input buffer is half full, LabWindows sends XOFF. In addition, if the XOFF transmission is interrupted, LabWindows sends XOFF at 75% and 90% of the buffer. Obviously, the sender must follow this rule to ensure that the transmission continues.

 

b. Hardware handshake: The second is to use hardware line handshake. Like Tx and Rx lines, RTS/CTS and DTR/DSR work together, one as output and the other as input. The first set of lines is RTS (Request to Send) and CTS (Clear to Send). When the receiver is ready to receive data, it sets the RTS line high to indicate that it is ready. If the sender is also ready, it sets CTS high to indicate that it is about to send data. The other set of lines is DTR (Data Terminal Ready) and DSR (Data Set Ready). These lines are mainly used for Modem communication. It allows the serial port and Modem to communicate their status. For example: When the Modem is ready to receive data from the PC, it sets the DTR line high to indicate that the connection with the telephone line has been established. Reading the DSR line high, the PC starts to send data. A simple rule is that DTR/DSR is used to indicate that the system is ready for communication, while RTS/CTS is used for the transmission of a single data packet.

 

In LabWindows, the function SetCTSMode enables or disables the use of hardware handshaking. If CTS mode is enabled, LabWindows uses the following rules:

[1] [2]
Keywords:ARM Reference address:ARM study notes 15-basic principles of serial communication

Previous article:ARM CPU big and small endian
Next article:ARM study notes 14 - C language and assembly are applied to each other

Recommended ReadingLatest update time:2024-11-16 10:37

ARM processor learning--GPIO operation
In the previous article, we explained in detail the construction of the ARM development environment. We chose the X86-linux platform to cross-compile ARM programs, and the cross-compilation chain selected the arm-linux-series. In addition, we also explained some basic knowledge required for development. For the above
[Microcontroller]
Comparison of the performance of Cortex-M3 and ARM7TDMI-S cores
Since STM32 was launched, I have been very interested in it. Since it uses ARM's Cortex-M3 core, I want to know how its performance compares with ARM7. By chance, I got to know EDNCHINA and participated in EDN's group buying event. I got an STM32 development board, which gave me the opportunity to test the performance
[Microcontroller]
Comparison of the performance of Cortex-M3 and ARM7TDMI-S cores
ARM architecture—ARMv7-A processor modes and registers
1. ARMv7-A processor mode The ARMv7 architecture supports security extensions. If security extensions are enabled, the ARMv7-A architecture is divided into two worlds: secure mode (Secure State) and non-secure mode (Non-secure State). In non-secure mode, there are three operating privileges PL0, PL1 and PL2 (privile
[Microcontroller]
ARM architecture—ARMv7-A processor modes and registers
GNU-ARM Assembly
Part 1 ARM assembly syntax under Linux Although it is convenient to write programs in C or C++ under Linux, the assembly source program is used for the most basic initialization of the system, such as initializing the stack pointer, setting up the page table, operating the ARM coprocessor, etc. After the initializatio
[Microcontroller]
Holtek's new generation Cortex-M0+ brushless DC motor dedicated MCU
Holtek has launched the new generation of Arm® Cortex®-M0+ brushless DC motor control dedicated single chip HT32F65232, which is suitable for Hall sensor or Sensor-less 1-shunt FOC and square wave Sensorless control. The frequency can reach up to 60MHz, with a wide voltage operation range of 2.5V~5.5V. The system vo
[Microcontroller]
ARM Notes: Application of timer interrupts
There are 5 16-bit timers in the s3c2440 chip, 4 of which (timer 0 to timer 3) have pulse width modulation function, that is, they all have an output pin, and the timer can be used to control the periodic high and low level changes of the pin. Timer 4 has no output pin. This was used in the last offline PWM test progr
[Microcontroller]
ARM's 37 registers
1. ARM's 7 working modes The instruction sets of ARMv4 and ARMv5 define seven operating modes of ARM, which are determined by register CPSR (see the table below). User mode: the normal program execution state of the ARM processor System mode: runs privileged operating system tasks Fast Interrupt (FIQ) mode: used to ha
[Microcontroller]
ARM's 37 registers
Design of touch screen touch point data acquisition system based on ARM7 LPC2210
This paper proposes the design of a touch screen touch point data acquisition system based on the ARM7 series LPC2210 microcontroller and the embedded operating system μC/OS-II, and completes the physical layer circuit conversion between the microcontroller and the host computer, realizing Data communication based on
[Microcontroller]
Design of touch screen touch point data acquisition system based on ARM7 LPC2210
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号