RFC 1331 contains the C code (and the required fcs look-up table) used to generate the CCITT 'CRC' A/K/A the 16-bit FCS (Frame Check Sequence) as described in RFC1331 appendix B: "The HDLC polynomial: x**0 + x**5 + x**12 + x**16 (0x8408)." as used in the PPP protocol: http://www.armware.dk/RFC/rfc/rfc1331.html Here are the simple test cases I sent through their code to verify it's operation: #define PPPINITFCS 0xffff /* Initial FCS value */ // Test, 1 of 3: Process_Buffer[0] = 0x00; Process_Buffer[1] = 0x00; PPP_TempUInt = pppfcs(PPPINITFCS, Process_Buffer, 2 ); // Result: 0xf0b8 // Test, 2 of 3: // Process_Buffer[0] = 0xFF; // Process_Buffer[1] = 0xFF; // PPP_TempUInt = pppfcs( 0, Process_Buffer, 2 ); // Result: 0xf0b8 // Test, 3 of 3: // Process_Buffer[0] = 0xb8; // LSByte // Process_Buffer[1] = 0xf0; // MSByte // PPP_TempUInt = pppfcs( 0xf0B8, Process_Buffer, 2 ); // Result: 0x0000 One thing that is not mentioned (at least in RFC 1331) is that this fcs must be COMPLEMENTED before inclusion (or comparison with) the fcs value sent in the PPP packet. I spent a day, maybe two chasing that rabbit to find out why PPP packets I was receiving (from commercial equipment) didn't agree with the FCS I was calculatating ... Also be sure to respect ENDIAN-ness when generating and comparing these values with values picked out of a byte stream. Feeding your ASCII test string "12...89"in Process_Buffer into the FCS code results in: PPP_TempUInt = pppfcs(PPPINITFCS, Process_Buffer, 9 ); Result in PPP_TempUInt: 0x6F91 Complementing this gives: 0x906E Hope this helps - and sorry, I have nothing on the "CRC-16" code. Jim (seemingly ex-RF guru now doing S/W and hopelessly addicted to PICLIST) PS. I coded this up in Borland C ver. 4.5 and ran it on a PC under DOS. I've got a bit more code (including the Borland C version of the FCS C code) if you're interested. Let me know. ----- Original Message ----- From: "bernard wood" To: Sent: Saturday, July 28, 2001 6:02 AM Subject: [EE]: verify CRC-16 on "123456789" is BB3Dh?? Hi all, I've coded routines but need to verify that they do indeed produce the correct CRC. To do this, I need 2 known CRC check values. These are obtained by running thru the "standard" check string "123456789" of your algorithm and obtaining the result. I think that the check with CRC-16 on "123456789" is BB3Dh (can someone verify this?) Can someone (with known good code) please tell me what the 2 check CRC's are for both CRC-CCITT (x^16+x^12+x^5+1, or POLY=1021h) and CRC-16 (x^16+x^15+x^2+1, or POLY=8005h) or alternatively, send me known good code in C or VB6? Thanks in advance, Bernard Wood New Zealand -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details. -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.