[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 |
URL:
<http://savannah.nongnu.org/bugs/?37901>
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
_______________________________________________________
Details:
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
http://www.lammertbies.nl/comm/info/crc-calculation.html).
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;
return(crc);
}
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:
<http://savannah.nongnu.org/bugs/?37901>
_______________________________________________
Message sent via/by Savannah
http://savannah.nongnu.org/
- [avr-libc-dev] [bug #37901] CRC-CCITT calculation incorrect,
mojo <=
- [avr-libc-dev] [bug #37901] CRC-CCITT calculation incorrect, Joerg Wunsch, 2012/12/11
- [avr-libc-dev] [bug #37901] CRC-CCITT calculation incorrect, mojo, 2012/12/11
- Re: [avr-libc-dev] [bug #37901] CRC-CCITT calculation incorrect, Weddington, Eric, 2012/12/11
- Re: [avr-libc-dev] [bug #37901] CRC-CCITT calculation incorrect, Joerg Wunsch, 2012/12/11
- Re: [avr-libc-dev] [bug #37901] CRC-CCITT calculation incorrect, Weddington, Eric, 2012/12/11
- Re: [avr-libc-dev] [bug #37901] CRC-CCITT calculation incorrect, Joerg Wunsch, 2012/12/11
- Re: [avr-libc-dev] [bug #37901] CRC-CCITT calculation incorrect, Weddington, Eric, 2012/12/11
- Re: [avr-libc-dev] [bug #37901] CRC-CCITT calculation incorrect, Joerg Wunsch, 2012/12/11
- Re: [avr-libc-dev] [bug #37901] CRC-CCITT calculation incorrect, Weddington, Eric, 2012/12/11
- Re: [avr-libc-dev] [bug #37901] CRC-CCITT calculation incorrect, Erik Walthinsen, 2012/12/11