Searching \ for 'CRC program for PIC 16CXX' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page:
Search entire site for: 'CRC program for PIC 16CXX'.

Truncated match.
PICList Thread
'CRC program for PIC 16CXX'
1995\10\05@115052 by Falstaff

picon face
Thanks for all those who responded.  In return, here I present a
debugged and tested CRC routine for y'all.

Program to calculate CRC-16 on a 16Cxx.  The resulting CRC value is
identical to that calculated by common archive programs, such as ZOO.
Fast table-based CRC calculators for this polynomial are available
as C source.

Note that the resulting CRC has its bits reversed in comparison to
the sources posted yesterday; this is to be compatible with ZOO and
ARC and others (most of all, with the CRC16 routine in my standard
library), and also is compatible with serial transmission if the
least significant bit is sent first.

----- C source --------------------------------------------------------

unsigned CRC;

unsigned crc_16(char c)
  int i,j;


  return CRC;

----- 16CXX source ----------------------------------------------------

               Temp     = 0x20
               Count    = 0x21
               CRC_High = 0x22
               CRC_Low  = 0x23

loop            macro   reg,label
               decfsz  reg
               goto    label

               movlw   "h"
               call    CalcCRC
               movlw   "e"
               call    CalcCRC
               movlw   "l"
               call    CalcCRC
               movlw   "l"
               call    CalcCRC
               movlw   "o"
               call    CalcCRC
Halt            goto    Halt

               ; result=0x34d2 (you can check that with ZOO)

----- CRC subroutine --------------------------------------------------

CalcCRC         movwf   Temp                ; about 125 cycles on average
               movlw   8
               movwf   Count

CRC_Loop        movf    CRC_Low,w
               xorwf   Temp,w
               rrf     CRC_High
               rrf     CRC_Low
               andlw   1
               bz      CRC_Skip

               movlw   0xa0
               xorwf   CRC_High
               movlw   0x01
               xorwf   CRC_Low

CRC_Skip        rrf     Temp
               loop    Count,CRC_Loop


Share And Enjoy.


"It's justice, Jim, but not as we know it."
Frank A. Vorstenbosch        +31-(70)-355 5241

More... (looser matching)
- Last day of these posts
- In 1995 , 1996 only
- Today
- New search...