Crc-16


Results 1 to 3 of 3

Thread: Crc-16

Threaded View

  1. #1
    Join Date
    Jun 2009
    Location
    Cambridge, England
    Posts
    9

    Default Crc-16

    Hello

    I'm using Darrel's CRC routine to calculate a CRC but the results are not as expected.

    Here is Darrel's routine -
    Code:
    CRC       VAR WORD
    CRC_IN    VAR BYTE
    Idx       VAR BYTE
    CRC_Len   CON 16
    CRC_Poly  CON $1021  ; x16 + x12 + x5 + 1
    
    ;-----CRC-16 -----------------------------------------------------
    CRC16:
      CRC.HighByte = CRC.HighByte ^ CRC_IN
      FOR Idx = 0 to 7
        IF CRC.0(CRC_Len-1) THEN
          CRC = (CRC << 1) ^ CRC_Poly
        ELSE
          CRC = CRC << 1
        ENDIF
      NEXT Idx
    RETURN
    The eight bytes I'm using are "F2 AA 4C D4 60 F6 00 80"

    The result I get is B2D5 rather than E23E as it should be.

    Using an online calculator I get the same result, but if I tick the box "bit reflected", I get the correct result.

    I'm sure I'm missing something really simple but I have tried many things without success.

    Any Ideas?
    Last edited by Darrel Taylor; - 18th June 2013 at 17:32. Reason: added [code][/code] tags

Similar Threads

  1. Help with CRC checksums
    By brid0030 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 25th February 2013, 23:25
  2. how to specific crc ?
    By phoenix_1 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 17th March 2010, 10:31
  3. CRC Calculations
    By timmers in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 16th June 2009, 17:10
  4. Crc
    By grich in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 7th May 2008, 09:51
  5. CRC Calculation - Need a little help
    By Steve43 in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 13th March 2005, 01:23

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts