0 Introduction
For the 8051 chip structure based on the flash controller, generally, when performing data transmission, the data is first transmitted to the buffer of the flash controller through the serial port. Since the buffer size is 512 bytes, the maximum amount of data transmitted each time is 512 bytes. The transmission data amount of the three error detection methods discussed in this article is all 512 bytes.
1 Error detection method
The block diagram of the hardware development platform of the serial data communication system based on 8051 is shown in Figure 1. When using this platform for data transmission, there are usually three data error detection methods.
1.1 Parity Check
Parity check is a common method in error detection. It uses the number of 1s in the data as the error detection flag. If the number of 1s is an odd number, the error detection flag is 1, and if the number of 1s is an even number, the error detection flag is 0. The parity bit is detected at the sending and receiving ends at the same time. If the same result is obtained, it means that there is no error in the data transmission process; if different results are obtained, it means that an error has occurred in the data transmission process. At this time, 8051 will send an error retransmission signal to let the PC send data again.
1.2 Cyclic Redundancy Check (CRC)
CRC uses the principle of division and remainder for error detection. If the original data is a polynomial JP(x), P(x) is divided modulo 2 by the generated polynomial G(x), and the remainder R(x) is used as the generated CRC check code, which can be expressed by the formula:
P(x)=Q(x)·G(x)+R(x)
In the above formula, Q(x) is the quotient obtained by division. The sender sends the original data P(x) and the generated CRC check code R(x) to the receiver. The receiver calculates another CRC check code R'(x) based on the received data P'(x), and then compares the two CRC check codes to determine whether an error occurred during the transmission process. If an error occurs, the sender retransmits. The polynomial G(x) generated by the CRC8 used in this article is: x2+x5+x4+1.
1.3 Hamming Code
Hamming code is to add a certain amount of redundancy to a set of codes to form a new set of data. The newly added redundant data is called the check bit. If an information bit is wrong, it will cause several groups of parity check results to be wrong. Therefore, according to the error detection of the parity group, the information bit and nature of the error can be determined. Hamming code has the following characteristics:
Code length: N = 2m-1
Information code bit: k = 2m-m-1
Supervisory code bit: r = Nk = m, where m ≥ 2 positive integers
Since the error detection object in this article is serial port transmission, 8 bits of data are sent at a time, so the required redundant bits are 4 bits. The Hamming code used in this article is (12, 8), and its encoding consists of 8 bits of data and 4 bits. Let the data be a0, a1, a2, a3, a4, a5, a6, a7 respectively. The check bits are a8, a9, a10, a11, which can be determined according to the following formula:
2 Test environment and principle
The test platform of this article is divided into two parts, namely the PC serial port sending part and the 8051 serial port receiving part. The PC sends data through the serial port, and the unit of each serial port transmission is 8 bits. The 8051 receives the data sent by the PC through the serial port. Due to hardware limitations, the maximum buffer for storing data in the 8051 is 512 bytes. Therefore, the data on the PC side is only sent 512 bytes each time. The total test data size is 8 K bytes, and it takes 16 times to transmit 8 K bytes of data. The baud rate of the serial port transmission is 57600. The 8051 receives data from the PC, 512 bytes of data each time, and performs error detection. If an error is detected, a retransmission request is sent to the PC. If no error is detected, a command to continue transmission is sent to the PC.
In order to improve the transmission efficiency, different data transmission structures can be used for parity check, CRC check, and Hamming code check without affecting error detection.
Parity check calculates 1 bit of parity for every 8 bits of data sent. After calculating the 8 bits of parity, the parity bit is sent to 8051. The data D is 512 bytes, the group is 64 bytes, and the data is 8 bits. The data structure is shown in Figure 2.
During CRC check, 1 byte of check bit is generated for every 512 bytes of data and sent to 8051. Its data structure is shown in Figure 3. Among them, D is 512 bytes, data is 512 bytes, and CRC byte is 8 bits. That is, a CRC check value is obtained for every 512 bytes. Since the Hamming code uses (12, 4), 4 bits of check bits are generated for every 8 bits of data. Therefore, its data structure is shown in Figure 4. In the figure, D is 512 bytes of data and data is 8 bits of data.
3 Test result analysis
This paper comprehensively compares the actual efficiency of three error detection methods in the same environment. The experimental results are listed in Table 1.
Table 1 is the theoretical value calculated based on the length of the sent data and the baud rate. The actual test value is tested by calling the time function on the PC. In order to improve the decoding efficiency of the Hamming code, this paper decodes it on the 8051 through assembly language. By analyzing the data in the table, it can be seen that CRC check has the best error detection efficiency, low error rate, and moderate time consumption.
4 Conclusion
This paper compares a large amount of data of three error detection methods in serial port transmission and analyzes their error detection results and efficiency. In parity check, in order to improve the error detection speed, the 8051 end can use assembly language to directly read the parity flag in the flag register. In Hamming code, C language and assembly language can be used for programming respectively. Among the three error detection methods, parity check takes the least time and has the fastest error detection speed, followed by CRC8, and the slowest error detection is Hamming code. CRC8 has the lowest error rate, followed by Hamming code, and the probability of error in parity check is relatively high.
Because it is serial communication, the probability of error is relatively small. Therefore, when transmitting large files, parity check is generally used for error detection. CRC is only used in situations where the error rate is required to be higher. Hamming code is generally rarely used in error detection occasions.
Previous article:Chinese Character Input in 51 Single-Chip Microcomputer Display and Control System
Next article:Interface Design between 51 Single Chip Microcomputer and A/D Converter MAX195
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- Rambus Launches Industry's First HBM 4 Controller IP: What Are the Technical Details Behind It?
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- Transfer idle STM32 development boards, etc.
- EEWORLD University ---- How does high voltage isolation technology work - Capacitor structure
- [RVB2601 Creative Application Development] 3. WiFi network communication
- Rookie Learning Manual
- Can it replace the human arm?
- Analysis of spike hazards and absorption circuits in switching power supply modules
- What is the baud rate register used for? The documentation seems to be somewhat contradictory. It says baud rate register first and counter later.
- TMS320VC5502EMIF external flash configuration problem
- 【ST NUCLEO-H743ZI Review】——by Sodium Citrate
- What is the link for gift exchange?