crccrc8

How to calculate CRC8 of incoming 32bit data


I need to implement CRC-8 with a specific polynomial of 32bit data. Here is my result from a transmitter:

Data:12586966
CRC-8: 22(0x16)
Polynomial:0x97
Initial data:0x00
No final XOR calculation

What is the algorithm to check the incoming data is equal to its CRC-8?


Solution

  • If the CRC is appended to the data, and there is no final XOR, then a recalculated CRC will be zero.

    In hex, the 4 bytes of data are: 00 C0 0F D6. The CRC8 calculation effectively appends a 00 to create a dividend and generates the remainder using 197 as the divisor: {00 C0 0F D6 D6} % 197 = 16. Then the remainder is "subtracted" from the dividend, but in this case both addition and subtraction are the same, XOR, so the CRC is just appended to the data: {00 C0 0F D6 16}. Repeating the process with the appended CRC (and the implied appended 00), {00 C0 0F D6 D6 16 00} % 197 = 00.