-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Since I had plenty of RAM and ROM (512 bytes each) and 2 FSRs free, I ended up going with the following 7-cycle table-driven code sequence: xorwf crc_low, W movff crc_high, crc_low movff PLUSW1, crc_high movf PLUSW0, W xorwf crc_low, F which uses the lookup table found in /usr/src/linux/lib/crc-ccitt.c, broken into two separate tables, one for the low bytes and one for the high bytes. PLUSW treats WREG as signed, so the FSRs have to be initialized to point 128 bytes into the tables and the tables have to be rotated to match. I actually store the original Linux table in ROM and do the breaking up into low and high bytes and rotation for signed PLUSW in the bootup code that loads the table into RAM. One could also leave the table in ROM at the cost of rather more instruction cycles to get at it. Chris On Sun, 27 Dec 2009 08:34:11 -0800 (PST) "Scott Dattalo" wrote: > Christopher Head wrote: > > > I implemented what Linux calls the CRC-CCITT (I translated from the > > Linux source), which is a 16-bit CRC, on a PIC18F4550. My > > implementation takes 24 instruction cycles and 24 words of Flash > > for the basic "add one byte to accumulated CRC" operation. > > There are two 17 word versions of the CRC-CCITT here: > > http://www.dattalo.com/technical/software/pic/crc_1021.asm > > Both can be reduced to 16 words for the 18F family by replacing the > two consecutive RLF's with one RLNCF. > > There are some other PIC CRC routines here: > > http://www.dattalo.com/technical/software/pic/crc.php > > Scott -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.11 (GNU/Linux) Comment: GnuPT 2.7.2 iEYEARECAAYFAktr4pMACgkQXUF6hOTGP7c6nACdGFLB3fsExaAGADBysMxnmW5e zEkAoIxDC2Q81Cao0HEMPwjlXBtHkQr3 =Ub16 -----END PGP SIGNATURE----- -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist