CRC8 vs Checksum

The EnoCean Radio Protocol

QUESTION

ESP2 uses checksum and ESP3 uses CRC but what is the difference?

Checksums and Cyclic Redundancy Checks (CRC) are both methods of error detection, used when transmitting or storing data. A calculation is performed on the data when it is transmitted or stored and again when it is received or read. The two results are compared to check if the data has become corrupted. If the results are the same it is very likely that the data has been transmitted correctly.

A checksum is calculated using an additive process. Data is split in to chunks of bits and added together to calculate a check sequence. Using a checksum, it may not be possible to detect errors if bits are switched or there are multiple errors that cancel each other out.

Polynomial division is used to calculate CRCs and they are much more robust than checksums. Using CRCs, a higher number of bit errors and different error patterns can be detected.

The disadvantage of using CRCs instead of checksums is that they use more complicated algorithms. This means that they are more complicated to implement and more time is required to calculate them. However, there are well known methods to reduce the complexity of the calculations so that the effort is not much greater than using a checksum and the performance is much better.

How to calculate a checksum

Below is a very simple example to demonstrate how a checksum can be calculated.

The message to be transmitted represented as a hexadecimal value:

0x6C77B30A

This is split in to 16Byte blocks which are added together.

0x6C77 + 0xB30A = 0x11F81

The carry bit of the sum is wrapped around and added to the result to ensure that the checksum is a 16-bit number.

0x1F81 + 0x1 = 0x1F82

Finally, the one’s compliment of the number is taken to give the checksum.

0001 1111 1000 0010 (0x1F81) -> 1110 0000 0111 1101 (0xE07D)

The final checksum is 0xE07D and this is transmitted along with the message.

How to calculate a crc

Below is a very simple example to demonstrate how a crc can be calculated.

The message to be transmitted represented as a binary value:

10011010

A polynomial is selected for the calculation and this determines the size of the crc. In the example, a crc of size three is used.

X^3 + X^2 + 1

The polynomial is represented as a binary number; this is called the polynomial key.

1101

To calculate the crc, the message is first appended with zeros and then divided by the polynomial key. The number of zeros appended to the message is equal to the size of the crc. The appended message:

10011010000

Next the polynomial division is performed and the remainder of the operation is the crc value. The crc for this calculation is 101 and this is transmitted with the message.