EasyManua.ls Logo

TPG CA-202A - Page 87

Default Icon
200 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
The following example of using C language to create a sample program for CRC
checksum algorithm
Example: C language sample program
unsigned char *data; // Message pointer
unsigned char length; // Message length
unsigned int crc_chk(unsigned char *data,unsigned char length)
{
int i;
unsigned int reg_crc=0xffff;
while(length--)
{
reg_crc^=*data++;
for(i=0;i<8;i++)
if(reg_crc&0x01)
reg_crc=(reg_crc>>1)^0xa001;
else
reg_crc=reg_crc>>1;
}
}
87

Table of Contents

Related product manuals