beautypg.com

3 crc chk (check sum), Crc chk (check sum) -9 – Delta DVP-ES2 User Manual

Page 611

background image

4 . C o m m u n i c a t i o n s

Field Name

Example (Hex)

Data Lo (T24)

05

Data Hi (T25)

00

Data Lo (T25)

06

Data Hi (T26)

00

Data Lo (T26)

07

Data Hi (T27)

00

Data Lo (T27)

08

CRC CHK Low

72

CRC CHK High

98

END

No data input ≥ 10 ms


4.3.3 CRC CHK (check sum)

The CRC Check starts from “Slave Address” and ends in “The last data content.” Calculation of CRC:

Step 1: Set the 16-bit register (CRC register) = FFFFH.

Step 2: Operate XOR on the first 8-bit message (Address) and the lower 8 bits of CRC register. Store

the result in the CRC register

Step 3: Right shift CRC register for a bit and fill “0” into the highest bit.

Step 4: Check the lowest bit (bit 0) of the shifted value. If bit 0 is 0, fill in the new value obtained at step

3 to CRC register; if bit 0 is NOT 0, operate XOR on A001H and the shifted value and store the result in

the CRC register.

Step 5: Repeat step 3 – 4 to finish all operation on all the 8 bits.

Step 6: Repeat step 2 – 5 until the operation of all the messages are completed. The final value

obtained in the CRC register is the CRC checksum. Care should be taken when placing the LOW byte

and HIGH byte of the obtained CRC checksum.

Calculation example of the CRC Check using the C language:

unsigned char* data

Å // index of the command message

unsigned char length

Å // length of the command message

unsigned int crc_chk(unsigned char* data, unsigned char length)

{

int j;

unsigned int reg_crc=0Xffff;

while(length--)

4 - 9

This manual is related to the following products: