[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-libc-dev] [bug #37901] CRC-CCITT calculation incorrect

From: mojo
Subject: [avr-libc-dev] [bug #37901] CRC-CCITT calculation incorrect
Date: Tue, 11 Dec 2012 13:42:24 +0000
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11


                 Summary: CRC-CCITT calculation incorrect
                 Project: AVR C Runtime Library
            Submitted by: mojo
            Submitted on: Tue 11 Dec 2012 13:42:22 GMT
                Category: Library
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: libc code
                  Status: None
        Percent Complete: 0%
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 1.8.0
           Fixed Release: None



Using _crc_ccitt_update() gives the wrong result. You can verify the result by
comparing it with known good implementations, e.g. the XMEGA CRC module, the
Boost libraries (http://www.boost.org/doc/libs/1_41_0/libs/crc/index.html), or
any number of online calculatored (e.g.
http://www.zorc.breitbandkatze.de/crc.html or

I wrote the following code that works, and allows communication between an
XMEGA with CRC module and one without when CRC functions are needed:

uint16_t inline crc16_update(uint16_t crc, uint8_t data)
        crc = (uint8_t)(crc >> 8) | (crc << 8);
        crc ^= data;
        crc ^= (uint8_t)(crc & 0xFF) >> 4;
        crc ^= (crc << 8) << 4;
        crc ^= ((crc & 0xFF) << 4) << 1;


For reference the correct CRC-CCITT value of "HELLO" (5 bytes ASCII) is
0x49D6. The _crc_ccitt_update() function gives 0x258A.


Reply to this item at:


  Message sent via/by Savannah

reply via email to

[Prev in Thread] Current Thread [Next in Thread]