CompuServe Messages

#16-bit CRC

    22-Jan-92 19:37:00
Sb: #19295-#16-bit CRC
Fm: Michael A McCormick 76046,1057
To: Don Curtis/SYSOP 76703,4321
This method seems a little to simple to me for some reason. I found a chapter on error checking using CRC-12, CRC-16, CRC-CTICC, and CRC-32 with an example of the hardware setup needed to implement the CRC-16. I wrote some code this morning that simulated the hardware method and it ends up being a bit more involved. Here is my code: UWORD calc_fcs( char ) UBYTE char; { static fcs = 0x0000; UWORD bit; UBYTE shift; /* Process each bit in the character */ for( shift=0x0001; shift; shift = shift<<1 ) { /* Determine the 'feedback' value */ bit = ( shift & char ) ? 1 : 0; bit = ( 0x0001 & fcs ) ^ bit; /* Right shift the FCS (Frame Check Sequence, the CRC end value ) */ fcs = fcs>>1; /* XOR with the 16th, 14th, and 1st bit of the FCS */ fcs = ( fcs & ~(0xA001) ) | (( fcs & 0xA001 ) ^ ( bit * 0xA001 )); } /* for */ return( fcs ); } /* calc_fcs */ You see, my function RIGHT shifts the FCS (accumulator) and reads the character from low bit to high. I wonder if these two differences cancel each other out somehow. I'm going to have to study the Dobbs example to see how they can get away with such a simple last step. I hope someone can tell me if I'm doing mine correct. A sample string with the resultant CRC value would be real helpful. Thanks, Mike McCormick