Which CRC?

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi all,

What CRC would you suggest for serial transmission? All I need to do it test whether a 240 byte stream turns up a a host system ok. I've looked at:

http://www.nongnu.org/avr-libc/u... ... __crc.html

Seems like the IrDA's a good one to go for? Or are the all much of a muchness?

Thanks

Mark

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Much of a muchness. Not sure if the Wikipedia details help or not?

http://en.wikipedia.org/wiki/Cyc...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'd suggest to stick to any one of the many CRC models out there (see for example http://www.tty1.net/pycrc/crc-models.html).

Some polynomials are better some are worse, but most of the established ones are equally good.

The path of least resistance (and IMHO by far not the worst choice) would be just to stick to the CRC routines that come with avr-libc.

My 2 pence,
Thomas

[Edit: If you really want to go into the details of checking the 'best' polynomial, then look for Koopman's article "Cyclic Redundancy Code (CRC) Polynomial Selection For Embedded Networks" (linked in Wikipedia)]

pycrc -- a free CRC calculator and C source code generator

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Think I'll go with the disk controller after all...

To use the method do I:

1) Initialise CRC to 0XFFFF
2) Call crc16_update(uint16_t crc, uint8_t a) with CRC and first byte of data
3) Repeat 2 with previous CRC result and subsequent byte of data

Is that right?

Thanks

Mark

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

That's right.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for your advice all :o)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

MarkWod wrote:
Hi all,

What CRC would you suggest for serial transmission? All I need to do it test whether a 240 byte stream turns up a a host system ok. I've looked at:

http://www.nongnu.org/avr-libc/u... ... __crc.html

Seems like the IrDA's a good one to go for? Or are the all much of a muchness?

Thanks

Mark


I'd use CRC8 for that small volume of data.
CCITT defines standard polynomials for CRC-8 and CRC16 which ware widely used and for which you can get code and lookup tables on the 'net.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you want to go more in depth, here is a good starting point:

http://www.ece.cmu.edu/~koopman/...
http://www.ece.cmu.edu/~koopman/...