32
MAS7.1 Suplemental Guide, Rev 1.1, 9/28/07
K.I.S.S.™
Keep It Simple Serial
Source Code Example of Calculating a CRC-8 Checkcode (Continued)
int main( void)
{
char TestString[] = "LI 3,2,80";
unsigned char crc8;
int index;
char token = ':';
crc8 = CRC8_INIT; // initialize checkcode
// CRC8 all of TestString[]
index = 0;
while (TestString[index] != 0)
crcByte( &crc8, TestString[index++]);
// Add the CRC-8 token character ':' to CRC-8
crcByte( &crc8, token);
// Finish with CRC8 by doing a one's compliment
crc8 = ~crc8;
// Print the results
printf( "%s%c%u", TestString, token, (unsigned char)crc8);
return (0);
}