This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Keil's CRC-16 for SDLC kb help

I see there was a thread exactly like the one I'm about to make here posted over a decade ago: http://www.keil.com/forum/989/

My company has the example code in the keil kb page (http://www.keil.com/support/docs/488.htm) implemented. I tried the code with the message "123456789". I expect 0x29B1 as the result, but I don't get that at all. It doesnt seem to match other implementations of X^16+X^12+X^5+1

--Using the tool at this website: www.piclist.com/.../crccalc.htm
and using CRC-CCITT with the message "12345679" I do get the expected result.

I must not be understanding something, but I've tried a lot of combinations of endianness reversals, initial values, and I'm just not coming to a clear answer. Maybe the kb example isnt the same as CCITT? I expected the polynomial to be 0x1021 (from X^16+X^12+X^5+1) so I concluded theyre supposed to be the same.

Does anyone have any info on that kb page? Is it correct? Is it something else entirely? Is it a good CRC? Thanks for any info you can provide.

  • There are two common CRC-16 polynomials - the CCITT version is one of them.

    Next thing is that both polynomials can often be found in two versions depending on if the data is processed least or most significant bit first. Remember that CRC is traditionally used on serially transmitted data and consumes data one bit at a time - so the correct polynomial form allows an intelligent serial port to compute CRC in real time.

    Next variant that you need to know is if original data is 0 and you use the final result directoy, or if initial data is 0xffff and you invert the result before use.