CRC or cyclic redundancy check is a checksum algorithm to detect errors in data transmission.
A checksum is appended to the data to help the receiver detect errors.
AD4134/AD7134 uses CRC-6 with polynomial x^6 + x^5 + x^2 + x + 1 and default seed value of 0x25
Below are the steps in calculating the checksum
Generating CRC checksum
- Initialize the output code by performing bitwise XOR on the first 6 bits with the seed value, in our case 0x25
- Append 6 zero bits for CRC-6
- Compute the CRC checksum by
- Polynomial Division
- Bitwise XOR
Verifying the CRC checksum
- Initialize the output code by performing bitwise XOR on the first 6 bits with the seed value: 0x25
- Divide the received data by the known polynomial - 1100111
- The remainder should be 0 for valid data
Example:
Generating CRC checksum
- Initialize the output code by performing bitwise XOR on the first 6 bits with the seed value, in our case 0x25
24 bits data + 2 bits header:
0011 0000 0000 1000 0110 1011 11
Default seed value: 0x25 = 100101
First 6 bits: 001100
XOR this first 6 bits with the seed à 100101 ^ 001100 = 101001 <-- Use this as first 6-bits of message data
2.Append 6 zero bits for CRC-6
Initialized message data: 10100100000010000110101111000000
3. Compute the CRC checksum by
-
- Polynomial Division
- Bitwise XOR
Initialized message data: 10100100000010000110101111000000
Polynomial (P(x)): 1100111
Compute the CRC
Remainder = 01011 = 0x13
Transmitted data:
24 bits data + 2 bits header + 6 bit CRC
0011 0000 0000 1000 0110 1011 + 11 + 01 0011
Verifying the CRC checksum
- Initialize the output code by performing bitwise XOR on the first 6 bits with the seed value: 0x25
Initialized message data: 10100100000010000110101111010011
2. Divide the received data by the known polynomial - 1100111
Initialized message data: 10100100000010000110101111010011
Polynomial (P(x)): 1100111
Remainder = 0
3. The remainder should be 0
Data received is correct!