ajit_nayak87
Member level 5
I found 8 bit CRC calculation for PIC controller
I would like to how to select poly = 0xa001; value.
I undestand remaining part not Below part.
I downloaded CRC calcualtion for excel using SimplyModubus . I have attached link for reference.
I would like to how to select poly = 0xa001; value.
I undestand remaining part not Below part.
I downloaded CRC calcualtion for excel using SimplyModubus . I have attached link for reference.
Code:
unsigned int crc_fn(unsigned char *dpacket,unsigned int len) // CRC Function(Error calcualtion)
{
unsigned int crc = 0xffff,poly = 0xa001;
unsigned int i=0,j=0;
for(i=0;i<len;i++)
{
crc^= dpacket[i];
for(j=0;j<8;j++)
{
if(crc & 0x01)
{
crc >>= 1;
crc ^= poly;
}
else
crc >>= 1;
}
}
return (crc);
}