Dynatronix LT1200X SERIES Specifications Page 102

  • Download
  • Add to my manuals
  • Print
  • Page
    / 126
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 101
Page 102 of 126 198-0853-02 Rev F
B.1.7 CRC Calculation
The CRC is used for error detection. The following is C code for the CRC calculation.
/////////////////////////////////////////////////////////////////////////////
// FUNCTION: CRC_Calc()
// DESCRIPTION: Calculate the CRC value for a string.
// PARAMETERS: Pointer to the string to perform the CRC calculation on.
// RETURNS: CRC word, 00000 to 65535.
// NOTES: The CRC calculation used by all Dynatronix units.
/////////////////////////////////////////////////////////////////////////////
uint16_t CRC_Calc (char * szData)
{
uint16_t uiCRC = 0xFFFF;
int16_t iCount = (int16_t)strlen(szData);
int16_t iIndex;
char cShiftCnt;
for(iIndex = 0; iIndex < iCount; iIndex ++)
{
cShiftCnt = 8;
uiCRC = (uint16_t)(uiCRC ^ (szData[iIndex] & 0xFF));
while (cShiftCnt != 0)
{
if ((uiCRC & 0x0001) == 0x0001)
{
uiCRC = (uint16_t)((uiCRC >> 1) ^ (uint16_t)0xA001);
}
else
{
uiCRC = (uint16_t)(uiCRC >> 1);
}
cShiftCnt--;
}
}
return uiCRC;
} //CRC_Calc
Page view 101
1 2 ... 97 98 99 100 101 102 103 104 105 106 107 ... 125 126

Comments to this Manuals

No comments