Delta Electronics VFD-G manual Command message ADR CMD Data starting address Number of data word

Models: VFD-G

1 183
Download 183 pages 30.97 Kb
Page 131
Image 131
Command message:

Chapter 4 ParametersManual background

Command message:

ADR

CMD

Data starting address

Number of data

(word)

CRC CHK Low

CRC CHK High

01H

03H

02H

02H

00H

02H

6FH

F7H

The following is an example of CRC generation using C language. The function takes two

arguments:

Unsigned char* data Å a pointer to the message buffer

Unsigned char length Å the quantity of bytes in the message buffer

The function returns the CRC values as a type of unsigned integer.

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

int j;

unsigned int reg_crc=0xFFFF;

while(length--){

reg_crc ^= *data++;

for(j=0;j<8;j++){

if(reg_crc & 0x01){ /* LSB(b0)=1 */

reg_crc=(reg_crc>>1) ^ 0xA001;

}else{

reg_crc=reg_crc >>1;

}

}

}

return reg_crc;

}

4-80

Revision July 2008, EG03, SW V1.06

Page 131
Image 131
Delta Electronics VFD-G manual Command message ADR CMD Data starting address Number of data word