The algorithm to compute the checksum to validate the RS485 transmission is the CRC polynomial
standardized by CCITT:
Bn=N^16+N^12+N^5+Bn-1
Where N^16 means that N is elevated to the sixteenth power of 2 (i.e. it is shifted left of 16 bit)
and where the symbol ‘+’ represents the XOR bit by bit.
Practically, if New is the byte to process , Tmp is a swap byte and BccLo and BccHi are the low
and high parts of the validation word, the following algorithm must be followed:
A. Initialize BccLo=0xFF, BccHi=0xFF
B. For each byte to transmit or receive repeat the following steps:
1. New = New XOR BccLo
2. Tmp=New << 4
3. New=Tmp XOR New
4. Tmp=New >> 5
5. BccLo=BccHi
6. BccHi= New XOR Tmp
7. Tmp= New << 3
8. BccLo= BccLo XOR Tmp
9. Tmp= New >> 4
10. BccLo= BccLo Xor Tmp
C. Negate bit by bit BccLo e BccHi : CRC_L=~BccLo CRC_H=~BccHi
Lesezeichen