![background image](http://html.mh-extra.com/html/phoenix/ds-series/ds-series_instruction-manual_1551179033.webp)
8-2 CRC GENERATION
The function takes two arguments:
unsigned char puchMsg; /* A pointer to the message buffer */
unsigned short usDataLen; /* The quantity of bytes in the message buffer */
The function returns the CRC as a type unsigned short.
CRC Generation Function
unsigned short CRC16 (puchMsg, usDataLen)
unsigned char *puchMsg; /* message to calculate CRC upon */
unsigned short usDataLen; /* quantity of bytes in message */
{
unsigned char uchCRCHi = 0xFF; /* high CRC byte initialized */
unsigned char uchCRCLo = 0xFF; /* low CRC byte initialized */
unsigned uIndex; /* will index into CRC lookup */
while( usDataLen--) /* pass through message buffer */
{
uIndex = uchCRCHi ^ *+; /* calculate the CRC */
uchCRCHi = uchCRCLo ^ auchCRCHi[ uIndex};
uchCRCLo = auchCRCLo[ uIndex];
}
return( uchCRCHi << 8 | uchCRCLo);
}
Summary of Contents for DS Series
Page 5: ...1 2 INTRODUCTION END OF INTRODUCTION SECTION ...
Page 8: ...HARDWARE INTERFACE 2 3 Figure 2 3 Figure 2 2 Figure 2 1 ...
Page 13: ...2 8 HARDWARE INTERFACE END OF HARDWARE INTERFACE ...
Page 19: ...3 6 MODBUS RTV PROTOCAL DESCRIPTION END OF MODBUS RTU PROTOCAL DESCRIPTION ...
Page 23: ...5 2 MODBUS FUNCTION FORMATS END OF MODBUS FUNCTION FORMATS ...
Page 29: ...6 6 PHOENIX AC DRIVE FUNCTION FORMATS END OF PHOENIX AC DRIVE FUNCTION FORMATS ...
Page 31: ...7 2 EXCEPTION RESPONSE END OF EXCEPTION RESPONSE ...
Page 37: ...9 2 PARAMETER CONVERSION END OF PARAMETER CONVERSION ...
Page 43: ...A 6 APPENDIX BASIC TCP IP DESCRIPTION THIS PAGE INTENTIONALLY LEFT BLANK ...