The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,860 other subscribers

Calculating CRC with a tiny (32 entry) lookup-table | Lentz family blog

Posted by jpluimers on 2019/06/27

For my archive:

I happened to notice that the Arduino OneWire library uses a 256 entry lookup table for its CRC calculations.

I did some research on this topic in 1992-1993, while working on Bulletin Board Systems, FidoNet code and file transfer protocols.

These days memory is not at a premium on most computers, however on Arduino and microcontroller environments it definitely is, and I happen to know that table-lookup CRC can be done using two 16-entry tables!

So I’ve dug up my documentation and code from the time, and applied it to the CRC-8 calculation for the Maxim (Dallas Semiconductor) OneWire bus protocol.

I think this provides a neat trade-off between code size and speed.

License For any of the below code, apply the following license (2-clause “simplified” BSD license), which should suffice for any use. If you do require another license, just ask.

Source: [WayBack/Archive.isCalculating CRC with a tiny (32 entry) lookup-table | Lentz family blog

The example on the page is for the CRC-8 implementation used in the [WayBack] 1-Wire Communication protocol – Wikipedia.

The generator works for CRC-8, CRC-16 and CRC-32 polynomials and can be downloaded here:

–jeroen

 

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.