4 - 12
PN 074-550-P1C
SQC-310 Operating Manual
4.2.3 Calculating the CRC
The following algorithm is used to computer the Cyclic Redundancy Check (CRC):
NOTE: The Sync character and CRC are not included in the CRC calculation. All
other characters should be included.
1 The CRC is initialized to hexadecimal(0x) 3FFF.
2 Each character in the packet is examined, bit by bit, and added to the CRC in
the following manner:
The character is exclusive OR’d with the CRC.
The CRC shifts one bit position to the right.
If bit position 0 has a value of 1 before each shift, the CRC is exclusive OR’d
with 0x2001. This is done a total of 8 times per message character.
3 Step 2 is repeated for each character in the message (excluding the sync and
length characters).
4 Mask the contents of the CRC by logical AND with 0x3FFF.
5 The CRC contains 14 significant bits. This is split into two pieces of 7 bits each.
A decimal 34 (0x22) is added to each CRC in order to avoid there being an
embedded sync character.
Extract bits 0 to 6 of the CRC and add a decimal 34 (0x22). This is CRC1.
Extract bits 7 to 13 of the CRC and add a decimal 34 (0x22). This is CRC2.
CRC code examples can be found in section 4.4, CRC Examples, on page 4-34.