User Manual of SY5000 series AC Drive MODBUS communication protocol
~110~
Step 6
:
Repeat Step
2~
Step
5,
take next 8-bit message command until
all message command calculation completes. After all, get the value of CRC
register, namely CRC check code. It is worth noting that CRC check code must
be swapped to place in the confirmation code.
The following is calculation example of CRC check code which is written by C
language: unsigned char *data
//message command pointer
unsigned char length //message command length
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) reg_crc=(reg_crc>>1)^0xA001;
else reg_crc=reg_crc>>1;
}
}
}
return reg_crc;
// return CRC register