On Tue, 20 Aug 2002, Dave Dribin wrote: > On Tue, Aug 20, 2002 at 01:28:02PM +0200, Tony K|bek wrote: > > > http://www.digitalnemesis.com/ash/projects/EmbeddedCRC16/default.htm > > > > > >It doesn't use a reflected table, so I'm trying to get it work with a > > >reflected CRC. > > > > :) then you'll like the snippet Scott did (same poly as Ashley's code): > > http://www.infosite.com/~jkeyzer/piclist/2002/May/0966.html > > > > > > 17 instructions, hard to beat > > Hard to understand, too. :) I'm gonna start at the beginning with > Ashley's code and a new poly. Once I get that working, I'll see if I > can optimize from there. That snippet is optimized for the particular Polynomial Ashley was using (0x1021). AFAIK this is not common polynomial. The other night I was looking at: http://www.geocities.com/SiliconValley/Pines/8659/crc.htm#r19 And in particular here: http://www.geocities.com/SiliconValley/Pines/8659/crcsrc17.htm (There's an html error in this page causing it be rendered incorrectly - if you view the .html source you can see all of the code). and hre: http://www.geocities.com/SiliconValley/Pines/8659/crcsrc19.htm Mid way through the latter URL is: #define TB_FILE "crctable.out" #define TB_WIDTH 4 #define TB_POLY 0x04C11DB7L #define TB_REVER TRUE You can change the Polynomial, whether it's reversed or not, and table width. I never could replicate the tables Ashley had created nor could I get the crc code on the above web pages to generate the same CRC's for the 0x1021 polynomial. Either the above crc code is wrong, Ashley's code is wrong, or I'm wrong. I strongly suspect that I'm missing something. Scott -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads