Dec 21, 2017 #1 A ajit_nayak87 Member level 5 Joined Oct 30, 2017 Messages 86 Helped 1 Reputation 2 Reaction score 1 Trophy points 8 Activity points 981 Dear all, 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); }
Dear all, 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); }
Dec 21, 2017 #2 Easyrider83 Advanced Member level 5 Joined Oct 11, 2011 Messages 1,608 Helped 374 Reputation 748 Reaction score 364 Trophy points 1,363 Location Tallinn, Estonia Activity points 8,575 https://github.com/Virviglaz/MyLibraries/blob/master/Common/CRC.c
Dec 21, 2017 #3 FvM Super Moderator Staff member Joined Jan 22, 2008 Messages 53,033 Helped 14,788 Reputation 29,863 Reaction score 14,268 Trophy points 1,393 Location Bochum, Germany Activity points 300,732 Below polynomial calculation for 8 bit , if i like to change for 16 bit and 32 bit controller how can change same below code. Click to expand... The calculation scheme mainly depends on the used CRC polynomial, in this case CRC-16. The same code would be used with 16 or 32 bit processors. A big performance improvement can be achieved by using table method instead of bitwise calculation.
Below polynomial calculation for 8 bit , if i like to change for 16 bit and 32 bit controller how can change same below code. Click to expand... The calculation scheme mainly depends on the used CRC polynomial, in this case CRC-16. The same code would be used with 16 or 32 bit processors. A big performance improvement can be achieved by using table method instead of bitwise calculation.
Apr 6, 2018 #4 A ajit_nayak87 Member level 5 Joined Oct 30, 2017 Messages 86 Helped 1 Reputation 2 Reaction score 1 Trophy points 8 Activity points 981 @easyrider **broken link removed** I have gone through link. Is there any ccode where i can use function 3 & function 1 modbus RTU
@easyrider **broken link removed** I have gone through link. Is there any ccode where i can use function 3 & function 1 modbus RTU