ajit_nayak87
Member level 5
Dear all,
I am looking for CRC calculation . I have found code and its working fine.
I found few question Here
Below polynomial calculation for 8 bit , if i like to change for 16 bit and 32 bit controller how can change same below code.
How
Here length is 30 how can select polynomial value is there any excel sheet and how to read it and how to put below values.
I am looking for CRC calculation . I have found code and its working fine.
I found few question Here
- How to selected polynomial value??
- if i want to extend range how can change
Below polynomial calculation for 8 bit , if i like to change for 16 bit and 32 bit controller how can change same below code.
How
Here length is 30 how can select polynomial value is there any excel sheet and how to read it and how to put below values.
Code:
unsigned int crc_fn(unsigned char *dpacket,unsigned int len) // CRC Function(Error calcualtion)
{
unsigned int crc = 0xffff,poly = 0xa001;
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);
}