[PIC] CRC check Function calculation

Status
Not open for further replies.

ajit_nayak87

Member level 5
Joined
Oct 30, 2017
Messages
86
Helped
1
Reputation
2
Reaction score
1
Trophy points
8
Activity points
981
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.


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);	  
}
 

I would like to how to select poly = 0xa001

You are not posing any specific question at all. By the way, there are some standardized CRC polynomials and you cannot select any other which do not meet requirements.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…