
5–7Data-link Layer Message Frames
Publication
17706.5.16 - October 1996
The full-duplex and half-duplex slave and master protocol examples
below provide you with procedures for determining the CRC-16
value.
Full-duplex and half-duplex slave protocol
data_byte = all linklayer data, ETX
CLEAR CRC_REGISTER
FOR each data_byte
GET data_byte
XOR (data_byte, right eight bits of CRC_REGISTER)
PLACE RESULT in right eight bits of CRC_REGISTER)
DO 8 times (on CRC register_
Shift bit right, shift in 0 at left
IF bit shifted = 1
XOR (CONSTANT, CRC_REGISTER)
PLACE RESULT in CRC_REGISTER
END IF
END DO
END FOR
TRANSMIT CRC_REGISTER as 2byte CRC field (low byte, high byte)
Half-duplex master protocol
data_byte = STN, STX, all linklayer data, ETX
CLEAR CRC_REGISTER
For each data_byte
GET data_byte
XOR (data_byte, right 8 bits of CRC_REGISTER)
PLACE RESULT in right 8 bits of CRC_REGISTER
DO 8 times
Shift bit right, shift in 0 at left
IF bit shifted = 1
XOR (CONSTANT, CRC_REGISTER)
PLACE RESULT in CRC_REGISTER
END IF
END DO
END FOR
TRANSMIT CRC_REGISTER as 2 byte CRC field
Below is an actual frame that you can use to validate your CRC
routine:
Use this frame to validate the CRC
53 B911 004110 02 07 00 00 00 00 00 00 00 00 00 00 00 00 10 03 6B 4C
Kommentare zu diesen Handbüchern