Rockwell Automation 1770, D17706.5.16 Ref Mnl DF1 Protocol Command User Manual

Page 79

Advertising
background image

5–7

Data-link Layer Message Frames

Publication 1770Ć6.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 linkĆlayer 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 2Ćbyte CRC field (low byte, high byte)

Half-duplex master protocol

data_byte = STN, STX, all linkĆlayer 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

B9

11

00

41

10

02

07

00 00 00 00 00 00 00 00 00 00 00 00 10

03 6B 4C

Advertising