1. CRC code
If we add the dividend 10110010000 to the remainder 1010, the result is 10110011010, and then divide it by (XOR) 11001, the remainder is 0000 (no specific calculation is done here).
Similarly, let the dividend 1111000 in this example plus the remainder 110 be 1111110, and divide it by (XOR) the divisor 100 to get a remainder of 000.
Reference address:C language: CRC check
CRC: Cylic Reduancy check is translated into Chinese as cyclic redundancy check code.
2. XOR
XOR: Logical operator exclusive OR. I don’t know how to write it with the symbol, but the operation rule is that different is 1 and the same is 0.
3. Two examples of using XOR to replace division in arithmetic operations.
1. 10110010000/11001
The first XOR (division) gives a quotient of 1 and a remainder of 1111. Add the next 0 and proceed
The second XOR operation gives a quotient of 1 and a remainder of 111. Add the next digit 1 and the remainder is 1111. The four digits and the divisor 5 digits cannot be XORed, so the quotient is 0. Add the next digit 0 and continue.
The third XOR operation yields a quotient of 1 and a remainder of 111. Similarly, the quotient of the fifth digit is 0, and the remainder continues to be added to the next 0 of the dividend.
The fourth XOR operation yields a quotient of 1 and a remainder of 101. Adding the last digit of the dividend, 0, yields a quotient of 0, a remainder of 1010, and a final quotient of 1101010. The calculation process is shown in the figure below:
If we add the dividend 10110010000 to the remainder 1010, the result is 10110011010, and then divide it by (XOR) 11001, the remainder is 0000 (no specific calculation is done here).
2. 1111000/1001
After three XOR (division), the quotient is 1110 and the remainder is 110. The specific routine is as follows:
Similarly, let the dividend 1111000 in this example plus the remainder 110 be 1111110, and divide it by (XOR) the divisor 100 to get a remainder of 000.
4. CRC Verification Principle
From the above two examples, we can see that during the communication process, the data to be transmitted is added as the "dividend", and then the remainder is added before transmission. After the receiving party receives the complete data, it is divided by the divisor. If the remainder is 0, it means that the transmitted data is correct. If it is not 0, it means that the transmitted data is incorrect. Because for a certain "divisor", there will be a unique remainder corresponding to it. This process is actually a CRC verification process. However, the name can be changed and it cannot be called dividend or divisor. It can be stipulated that the above divisor is called a generating polynomial or generating term, represented by g(x). The remainder is called a CRC check code. From the above, we know that for different generating terms, there will be a unique CRC check code corresponding to it. For the data to be transmitted, a polynomial with coefficients of only 0 and 1 can also be used to correspond one by one. For example, the polynomial corresponding to the code 1010111 is x^6+x^4+x^2+x+1. And the code corresponding to the polynomial x^5+x^3+x^2+x+1 is 101111.
In fact, the dividend is not the real data to be transmitted. The real data to be transmitted is a code after the polynomial is shifted left by the number of CRC check code bits. The number of bits of the CRC check code is defined to represent its width.
In addition, regarding the generated item, it is not difficult to find that its highest bit is 1. In fact, it will be eliminated every time XOR is performed in division, so the first 1 is generally not used as a reference, and the following bits are the most important. This is why the number of bits in the generated item is 1 greater than the CRC width. And the last bit of the generated item must also be 1 at the same time. Generally, the highest bit 1 is not written when the generated item is abbreviated. The following are various commonly used generated item expressions:
CRC-4: x^4+x+1;-------------------------------->0x03
CRC-8:x^8+x^5+x^4+1;-------------------------->0x31
CRC-8:x^8+x^2+x^1+1;-------------------------->0x07
CRC-8:x^8+x^6+x^4+x^3+x^2+x;------------------->0x5E
CRC-12:x^12+x^11+x^4+x^3+x+1;------------------>0x80
CRC-16:x^16+x^15+x^2+1;------------------------>0x80005
CRC-16:x^16+x^12 +x^5+1;------------------------>0x1021
CRC-32:x^32+x^26 +x^23+.... +x^2+x+1;------------>0x04C11DB7
CRC-32:x^32+x^28 +x^27+.... +x^8+x^6+1;---------->0x1EDC6F41
5. Implementation of C language
appendix:
Previous article:Usage of const in C language
Next article:Programming of wireless RF chip CC1100e
Latest Microcontroller Articles
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
He Limin Column
Microcontroller and Embedded Systems Bible
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
MoreSelected Circuit Diagrams
MorePopular Articles
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
MoreDaily News
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
Guess you like
- msp clock setting program
- Rigol Oscilloscope and Micsig Oscilloscope
- Parameters of terminal blocks
- [New version of Zhongke Bluexun AB32VG1 RISC-V development board] - 7: Using RT-Thread in VS Code on Ubuntu
- Analysis of Factors Affecting WiFi RF EVM
- Transistor replacement
- How GaN FETs with integrated drivers and self-protection enable next-generation industrial power supply designs
- [Sipeed LicheeRV 86 Panel Review] - 3 Waft Development Environment Establishment
- [Voice and vision module based on ESP32S3] Hardware design, debugging and progress - after 4 versions of iterative hardware design completed
- It’s like face to face with real people. What do you think of this black technology?