Searching \ for '[PIC]: CRC16 checksums' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/method/errors.htm?key=crc
Search entire site for: 'CRC16 checksums'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: CRC16 checksums'
2000\12\06@105231 by Mark Willis

flavicon
face
I'd really suggest using something in an 'If' test and code for each
particular polynomial you plan to use, if in assembler anyways - to cut
down resulting code size.  Probably if in C as well,  Study how & why
they work, it's not that hard to do IMHO.

 Mark

Teecy wrote:
> Anyone got a routine to calculate a CRC16 checksum.  I have tried two already but they seem to only work with their own polynomial value.  I need a routine that I can use different poly's for different communications protocols.
>
> Thanks.
> D.T.

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spam_OUTlistservTakeThisOuTspammitvma.mit.edu with SET PICList DIGEST in the body


2000\12\06@121511 by Bob Ammerman

picon face
If you can read Pascal I'll send you my universal CRC routines I have
written in that language.

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email .....listservKILLspamspam@spam@mitvma.mit.edu with SET PICList DIGEST in the body


2000\12\06@121912 by Douglas Wood

flavicon
face
I have a CRC-8 and a CRC-16 routine written in PIC assembly, if that's what
you're looking for.

Douglas Wood
Software Engineer

{Original Message removed}

2000\12\06@150313 by Olin Lathrop

face picon face
> If you can read Pascal I'll send you my universal CRC routines I have
> written in that language.

And I thought I was the only one left still using Pascal.  I have a source
to source translator that takes my portable Pascal in and emits code for
whatever the best compiler is for a particular platform, like MS Visual C on
Windows.


*****************************************************************
Olin Lathrop, embedded systems consultant in Devens Massachusetts
(978) 772-3129, olinspamKILLspamembedinc.com, http://www.embedinc.com

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email .....listservKILLspamspam.....mitvma.mit.edu with SET PICList DIGEST in the body


2000\12\06@194549 by Sam Linder

flavicon
face
How about posting the routines to the list for the rest of us who are
interested?



-----Original Message-----
From: Douglas Wood [EraseMEdouglas_woodspam_OUTspamTakeThisOuTARIUSA.COM]
Sent: Wednesday, December 06, 2000 9:17 AM
To: PICLISTspamspam_OUTMITVMA.MIT.EDU
Subject: Re: [PIC]: CRC16 checksums


I have a CRC-8 and a CRC-16 routine written in PIC assembly, if that's what
you're looking for.

Douglas Wood
Software Engineer

-----Original Message-----
From: pic microcontroller discussion list
[@spam@PICLISTKILLspamspamMITVMA.MIT.EDU]On Behalf Of Bob Ammerman
Sent: Wednesday, December 06, 2000 11:07 AM
To: KILLspamPICLISTKILLspamspamMITVMA.MIT.EDU
Subject: Re: [PIC]: CRC16 checksums


If you can read Pascal I'll send you my universal CRC routines I have
written in that language.

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email RemoveMElistservTakeThisOuTspammitvma.mit.edu with SET PICList DIGEST in the body

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spamBeGonelistservspamBeGonespammitvma.mit.edu with SET PICList DIGEST in the body

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email TakeThisOuTlistservEraseMEspamspam_OUTmitvma.mit.edu with SET PICList DIGEST in the body


2000\12\06@200229 by Andrew Warren

flavicon
face
Sam Linder <RemoveMEPICLISTspamTakeThisOuTMITVMA.MIT.EDU> wrote:

> How about posting the routines to the list for the rest of us who
> are interested?

Sam:

Here's a CRC-16 implementation from my web page
(http://home.netcom.com/~fastfwd/answers.html#PIC00076):

   CRCHI   EQU     some register
   CRCLO   EQU     another register

           CLRF    CRCHI
           CLRF    CRCLO

           ;Append 16 "0" bits to your message here.

   LOOP:   ;If there are no more bits in your message, go to
           ;"DONE".  Otherwise, left-shift the next bit of your
           ;message into the carry here.

           RLF     CRCLO
           RLF     CRCHI

           SKPC                ;X^16
           GOTO    LOOP

           MOVLW   00010000B   ;X^12
           XORWF   CRCHI       ;

           MOVLW   00100001B   ;X^5 + 1
           XORWF   CRCLO       ;

           GOTO    LOOP

   DONE:   ;The CRC is in "CRCHI" and "CRCLO".

This isn't the fastest possible implementation, but it should be
quick enough for most purposes. It uses the standard X.25 (and
XMODEM) polynomial: x^16+x^12+x^5+1.

-Andrew


=== Andrew Warren --- aiwEraseMEspam.....cypress.com
=== Staff Systems Engineer, IPD
=== Cypress Semiconductor Corporation
===
=== The opinions expressed above do
=== not necessarily represent those of
=== Cypress Semiconductor Corporation.

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email EraseMElistservspammitvma.mit.edu with SET PICList DIGEST in the body


2000\12\07@033116 by dr. Imre Bartfai

flavicon
face
part 1 575 bytes content-type:TEXT/PLAIN; charset=US-ASCIIHi,
attached here a CRC16 generator for your convenience. The polynomial is
poly0 & poly1, respectively.

Regards,
Imre

On Wed, 6 Dec 2000, Bob Ammerman wrote:

{Quote hidden}


part 2 1091 bytes content-type:TEXT/PLAIN; charset=US-ASCII; name="crc16.inc"
(decoded base64)

;This subroutine calculates a 16-bit CRC

;--------

; CrcUpd: update using

;

;

       CBLOCK     crcblk

          crch

          crcl

          saved

          oldcch

          i

       ENDC

CrcUpd  movwf   saved           ; j = W

       movlw   d'8'            ; W = 8

       movwf   i               ; i = W

_loop   movfw   crch

       movwf   oldcch          ; temporary save

       clrc                    ; clear carry for rlf

       rlf     crcl            ; crc << 1

       rlf     crch

       movfw   saved           ; the char read

       xorwf   oldcch,F        ; test with old high

       btfss   oldcch,7        ; if bit set, apply mask

       b       _notset         ; otherwise skip

       movlw   poly0

       xorwf   crcl,F

       movlw   poly1

       xorwf   crch,F

_notset clrc                    ; for rlf

       rlf     saved,F         ; next bit of saved

       decfsz  i,F

       b       _loop

       return

;

; End CrcUpd




part 3 105 bytes
--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestspam_OUTspamKILLspammitvma.mit.edu


2000\12\07@034818 by Teecy

flavicon
face
Thanks Bob, but what's Pascal? (only joking)

David Teece


----- Original Message -----
From: Bob Ammerman <RemoveMERAMMERMANTakeThisOuTspamspamPRODIGY.NET>
To: <EraseMEPICLISTspamspamspamBeGoneMITVMA.MIT.EDU>
Sent: Wednesday, December 06, 2000 5:07 PM
Subject: Re: [PIC]: CRC16 checksums


{Quote hidden}

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestSTOPspamspamspam_OUTmitvma.mit.edu


2000\12\07@035034 by Teecy

flavicon
face
Thanks mark, your'e right but i would most likely just change the polly as
and when needed.

David Teece

{Original Message removed}

2000\12\07@120439 by Sam Linder

flavicon
face
Thanks to both of you for posting the CRC code. I'm sure it will be helpful
to not only myself, but others on the list that have a need for CRC
checksums.


> {Original Message removed}

2000\12\07@123731 by Bill Westfield

face picon face
RFC1549 (PPP in HDLC Framing) contains a fast (bytewise) CRC generator as
well as several references on the issue.  Code is in C and includes the
part that generates the appropriate table (256*16bits - not particularly
PIC-friendly) for any polynomial.

BillW

--
http://www.piclist.com hint: To leave the PICList
spamBeGonepiclist-unsubscribe-requestSTOPspamspamEraseMEmitvma.mit.edu


2000\12\07@133932 by Ray Gardiner

flavicon
face
If someone is collecting these things, here is one I have been using
for a fair while, The 0xa001 poly is standard for modbus.


static unsigned int crc16;

void InitCrc ( void )
{    crc16=0xffff;
}

void AddToCrc ( unsigned char k)    /* call for each character */
{
   char n;
   for (n=0; n<8; n++)
   {
       if (((crc16^k) & 0x01 )==1)
       {
           crc16 = (crc16>>1) ^ 0xa001;  /* polynomial */
       }
       else
       {
           crc16 = crc16>>1;
       }
       k = k >>1;
   }
}



>RFC1549 (PPP in HDLC Framing) contains a fast (bytewise) CRC generator as
>well as several references on the issue.  Code is in C and includes the
>part that generates the appropriate table (256*16bits - not particularly
>PIC-friendly) for any polynomial.
>

That's more space for the table than I generally have space for code :-)

Ray Gardiner KILLspamrayspamBeGonespamdsp.com.au
mail from: dsp systems

--
http://www.piclist.com hint: To leave the PICList
EraseMEpiclist-unsubscribe-requestspamEraseMEmitvma.mit.edu


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