1
\$\begingroup\$

I'm trying to calculate the CRC-16 in hex form using a seed of 0x0000. For your convenience, here's the polynomial for CRC-16

\$ x^{16} + x^{15} + x^2 + 1 \$

I have the following packet sequence that I want to compute the CRC-16 for:

f0 f0 03 01 b4 04 01 67 40 17

The CRC is calculated to be 7a 8b by the hardware that I'm working with. I'm having trouble connecting the dots between the data byte sequence, the polynomial, and the final results even after reading a few search results regarding CRC-16. I've also noticed the OpenCores community, and I'm wondering if there are any of you who used the libraries to calculate checksums?

\$\endgroup\$
  • 2
    \$\begingroup\$ There are other things that could have been said, but since you accepted the first answer after only 18 minutes I guess they won't be. \$\endgroup\$ – Olin Lathrop Jul 11 '11 at 23:23
  • 3
    \$\begingroup\$ @Olin The OP is free to change to a better answer if one is posted. \$\endgroup\$ – Toby Jaffey Jul 11 '11 at 23:27
  • 4
    \$\begingroup\$ @Joby, that may be, but it happens rarely. Many people won't bother post if a answer has already been accepted. I usually skip over questions with accepted answers. I got here by a accident of not paying attention when clicking and didn't waste my time posting when I saw the green check. \$\endgroup\$ – Olin Lathrop Jul 11 '11 at 23:37
  • \$\begingroup\$ @Olin, I wish you were still at a state in your career where you could learn from answers to gain value from visiting answered questions. You are an exception though, not the rule. I still read answers just to see if there is A)something to learn or B)something wrong. I wish people checked back and updated their accept, but 15 rep is all an accept is worth, so why not make the easy 30-50 rep from the great answers you always post! Just as often someone does not go back and accept better they never come back, at least they accepted in this case. \$\endgroup\$ – Kortuk Jul 12 '11 at 1:37
  • \$\begingroup\$ There's a meta thread about this quick answer here \$\endgroup\$ – Kevin Vermeer Jul 12 '11 at 12:18
5
\$\begingroup\$

Looks like you got it right actually, just swap the bytes. When I run your data sequence

F0F00301B40401674017

through this online CRC calculator I get a calculated CRC-16 of:

0x8B7A

which is just you calculated answer with the bytes swapped. Congrats friend, looks like you've got yourself a reusable CRC-16 module!

\$\endgroup\$
  • 2
    \$\begingroup\$ I am not even sure how this answered his question, but I guess it must have. I thought he was looking for someone to step him through how to take the hex and plug into the polynomial. \$\endgroup\$ – Kellenjb Jul 12 '11 at 10:46
  • \$\begingroup\$ @Kellenjb - I agree, that would be a far better answer. I'm not sure why this one got so many upvotes! \$\endgroup\$ – Kevin Vermeer Jul 12 '11 at 12:17
  • 1
    \$\begingroup\$ To be honest, the OP didn't do a good job of clarifying what exactly he was asking. I agree that it would be nice to walk through a CRC VHDL implementation, but from his cryptic post it seemed like he already had one (or borrowed one from OpenCores) that worked. Without source code it's going to be hard to explain to this person what is going on, so I gave him some tools to help him in his debug (the website) as well as any insight I had based upon what I could infer from his post. \$\endgroup\$ – Joel B Jul 12 '11 at 14:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.