CCITT in C++ for AVR
CASTalk.com Forum Index CASTalk.com
Discussion of DSP, FPGA, storage and embedded system.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web castalk.com
CCITT in C++ for AVR
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CASTalk.com Forum Index -> Embedded System
Author Message
RadGar
Guest





Posted: Sun Nov 27, 2005 5:15 pm    Post subject: CCITT in C++ for AVR Reply with quote

Hi,

First of all - I'm a total newbie to AVR or other microcontrollers
programming so forgive any mistakes I make.

I am making a school project for PocketPC which is to send some data
to mechanic robots controlled by AVRs or other types of microcontrollers
(mostly AVR). The data I send is own designed packet, which includes its
own 16bit CRC. After some googling I found the CCITT ( poly 0x1021 with
0xFFFF init) and other types of 16bit CRCs (XModem, ARC) - I chose to go
with CCITT, but still can go with other type if it makes it easier.

To the subject now - I have no idea what type of compilers are
available for such microcontrollers (AVR etc). What I'd like to know is
there any library with CCITT (or other) calculation function. I'm aware
there are many source codes for that on the web, but I'd still would go
with the library function (just easier for the people to use it) - the
speed is not an issue. It's just easier to point other people to the lib
function in the documentation instead of making them type some code I
present in the doc.

Hope I made myself clear.
Back to top
RadGar
Guest





Posted: Sun Nov 27, 2005 5:15 pm    Post subject: Re: CCITT in C++ for AVR Reply with quote

Ian Bell napisał(a):
Quote:
I do not understand. You said you 'chose' to go with CCITT.

Ian

Well in fact I was the one to choose the CCITT, but the project manager
(let's call him that :D) told me to stick with already existing CRCs and
gave a CCITT as an example (which was in fact most common to my
understanding). So own created 16bit CRC was never an option.
Back to top
Ian Bell
Guest





Posted: Sun Nov 27, 2005 5:15 pm    Post subject: Re: CCITT in C++ for AVR Reply with quote

RadGar wrote:

Quote:
Ian Bell napisa?(a):
RadGar wrote:


Hi,

First of all - I'm a total newbie to AVR or other microcontrollers
programming so forgive any mistakes I make.

I am making a school project for PocketPC which is to send some data
to mechanic robots controlled by AVRs or other types of microcontrollers
(mostly AVR). The data I send is own designed packet, which includes its
own 16bit CRC. After some googling I found the CCITT ( poly 0x1021 with
0xFFFF init) and other types of 16bit CRCs (XModem, ARC) - I chose to go
with CCITT, but still can go with other type if it makes it easier.



Personally for this application, where the CRC only tells you if the
packet got corrupted, I would use something simpler that CCITT. Simply
sum the packet bytes and make the check 0x10000 minus this total. On
receive, total the packet bytes, add the CDR and check the result is
zero.

Ian

The simple CRC verification (since the packet is sent through the TCP)
is a good idea - but the choice of CCITT or other more complex CRCs is
not mine to make unfortunatelly.

I do not understand. You said you 'chose' to go with CCITT.

Ian
Back to top
diggerdo
Guest





Posted: Sun Nov 27, 2005 5:15 pm    Post subject: Re: CCITT in C++ for AVR Reply with quote

The CRC routine is small, simple, and available all over the web.
Its just a 512 word table and a couple of dozen lines of C code.
Try here. http://www.programmersheaven.com/zone3/cat846/index.htm

"RadGar" <radgar45@jawnet.pl> wrote in message
news:dmcl7o$1s1a$1@omega.artcom.pl...
Quote:
I see most replies miss the question I asked so rephrase:

I don't know what sort of software is used to make apps for AVRs (or
other) microcontrollers. What I want to know if any of these has a
built-in header/lib with a function to calculate CRC CCITT (or other 16bit
CRC). The reason for these is for *others* (I'm not going to write an app
for the AVR) to just use the function instead of searching for the code on
the web (the AVR apps will be tasks for the school, just as my PocketPC
sender app is). If there is no built-in function for that I'd just want to
verify that and point the people in my documentation to search for the
implementation or just hand them over what I'll use. thanks, hope this
makes things clear

Rafal Mroz
Back to top
Kurt Harders
Guest





Posted: Sun Nov 27, 2005 5:15 pm    Post subject: Re: CCITT in C++ for AVR Reply with quote

Hello,

RadGar wrote:

Quote:
To the subject now - I have no idea what type of compilers are
available for such microcontrollers (AVR etc). What I'd like to know

I decided to take the winavr gcc compiler. It nicely fits into eclipse
as IDE using the CDT. Programming the processor is actually done with
AVR studio, which also may be used as IDE for the winavr.

Quote:
is there any library with CCITT (or other) calculation function. I'm
aware there are many source codes for that on the web, but I'd still
would go with the library function (just easier for the people to use
it) - the speed is not an issue. It's just easier to point other
people to the lib function in the documentation instead of making
them type some code I present in the doc.

Thats where i cant help you :-). But there should be some code for this
problem in the C world.

Regards, Kurt
--
Kurt Harders
PiN -Präsenz im Netz GITmbH
mailto:news@kurt-harders.de
http://www.pin-gmbh.com
Back to top
RadGar
Guest





Posted: Sun Nov 27, 2005 5:15 pm    Post subject: Re: CCITT in C++ for AVR Reply with quote

Kurt Harders napisa³(a):
Quote:
Hello,

RadGar wrote:


To the subject now - I have no idea what type of compilers are
available for such microcontrollers (AVR etc). What I'd like to know


I decided to take the winavr gcc compiler. It nicely fits into eclipse
as IDE using the CDT. Programming the processor is actually done with
AVR studio, which also may be used as IDE for the winavr.


is there any library with CCITT (or other) calculation function. I'm
aware there are many source codes for that on the web, but I'd still
would go with the library function (just easier for the people to use
it) - the speed is not an issue. It's just easier to point other
people to the lib function in the documentation instead of making
them type some code I present in the doc.


Thats where i cant help you :-). But there should be some code for this
problem in the C world.

Regards, Kurt

Is there in the AVR studio / winavr built-in lib with such function?
If you could check that I'd appreciate. Thanks for such a fast reply,
regards

Rafal Mroz
Back to top
Ian Bell
Guest





Posted: Sun Nov 27, 2005 5:15 pm    Post subject: Re: CCITT in C++ for AVR Reply with quote

RadGar wrote:

Quote:
Hi,

First of all - I'm a total newbie to AVR or other microcontrollers
programming so forgive any mistakes I make.

I am making a school project for PocketPC which is to send some data
to mechanic robots controlled by AVRs or other types of microcontrollers
(mostly AVR). The data I send is own designed packet, which includes its
own 16bit CRC. After some googling I found the CCITT ( poly 0x1021 with
0xFFFF init) and other types of 16bit CRCs (XModem, ARC) - I chose to go
with CCITT, but still can go with other type if it makes it easier.


Personally for this application, where the CRC only tells you if the packet
got corrupted, I would use something simpler that CCITT. Simply sum the
packet bytes and make the check 0x10000 minus this total. On receive, total
the packet bytes, add the CDR and check the result is zero.

Ian
Back to top
PeteS
Guest





Posted: Sun Nov 27, 2005 5:15 pm    Post subject: Re: CCITT in C++ for AVR Reply with quote

The CRC algorithm is almost trivial to implement. This search gave over
2 million hits (of which at least some appeared useful)
http://www.google.com/search?hl=en&lr=&q=crc+implementation+c&btnG=Search

I implemented CRC16 and CRC32 some years ago - took maybe an hour once
I had the algorithm in front of me. The polynomial is irrelevant to the
fundamental implementation.

It's possible there's a free implementation for AVR - see
http://www.avrfreaks.net/

Cheers

PeteS
Back to top
RadGar
Guest





Posted: Sun Nov 27, 2005 5:15 pm    Post subject: Re: CCITT in C++ for AVR Reply with quote

Ian Bell napisał(a):
Quote:
RadGar wrote:


Hi,

First of all - I'm a total newbie to AVR or other microcontrollers
programming so forgive any mistakes I make.

I am making a school project for PocketPC which is to send some data
to mechanic robots controlled by AVRs or other types of microcontrollers
(mostly AVR). The data I send is own designed packet, which includes its
own 16bit CRC. After some googling I found the CCITT ( poly 0x1021 with
0xFFFF init) and other types of 16bit CRCs (XModem, ARC) - I chose to go
with CCITT, but still can go with other type if it makes it easier.



Personally for this application, where the CRC only tells you if the packet
got corrupted, I would use something simpler that CCITT. Simply sum the
packet bytes and make the check 0x10000 minus this total. On receive, total
the packet bytes, add the CDR and check the result is zero.

Ian

The simple CRC verification (since the packet is sent through the TCP)
is a good idea - but the choice of CCITT or other more complex CRCs is
not mine to make unfortunatelly.
Back to top
Didi
Guest





Posted: Sun Nov 27, 2005 5:15 pm    Post subject: Re: CCITT in C++ for AVR Reply with quote

Last time I wrote a PPP implementation I had little trouble
understanding both the 16 and the 32 bit CRCs, described
in rfc1662, http://www.ietf.org/rfc/rfc1662.txt .
I'd just stick with this algorithm, pretty widespread and
proven.

Dimiter

------------------------------------------------------
Dimiter Popoff Transgalactic Instruments

http://www.tgi-sci.com
------------------------------------------------------
Back to top
RadGar
Guest





Posted: Sun Nov 27, 2005 5:15 pm    Post subject: Re: CCITT in C++ for AVR Reply with quote

I see most replies miss the question I asked so rephrase:

I don't know what sort of software is used to make apps for AVRs (or
other) microcontrollers. What I want to know if any of these has a
built-in header/lib with a function to calculate CRC CCITT (or other
16bit CRC). The reason for these is for *others* (I'm not going to write
an app for the AVR) to just use the function instead of searching for
the code on the web (the AVR apps will be tasks for the school, just as
my PocketPC sender app is). If there is no built-in function for that
I'd just want to verify that and point the people in my documentation to
search for the implementation or just hand them over what I'll use.
thanks, hope this makes things clear

Rafal Mroz
Back to top
RadGar
Guest





Posted: Sun Nov 27, 2005 11:17 pm    Post subject: Re: CCITT in C++ for AVR Reply with quote

diggerdo napisa³(a):
Quote:
The CRC routine is small, simple, and available all over the web.
Its just a 512 word table and a couple of dozen lines of C code.
Try here. http://www.programmersheaven.com/zone3/cat846/index.htm


I'm know it's small because I've seen implementations (not only table
driven), but it's also my task to ensure if there are any ready to use
functions for that (in STL, built-in libs). That's the only thing I want
to know (if there's no such lib which has such a function I just need to
know there isn't). Thanks for the link though - it seems there's no
built-in implementation of CCITT calculation. regards,

RadGar
Back to top
Ian Bell
Guest





Posted: Mon Nov 28, 2005 12:33 am    Post subject: Re: CCITT in C++ for AVR Reply with quote

RadGar wrote:

Quote:
Ian Bell napisa?(a):
I do not understand. You said you 'chose' to go with CCITT.

Ian

Well in fact I was the one to choose the CCITT, but the project manager
(let's call him that :D) told me to stick with already existing CRCs and
gave a CCITT as an example (which was in fact most common to my
understanding). So own created 16bit CRC was never an option.

Now I understand. However, the CRC I described is very common - it would not
be your own creation. Furthermore an even simpler version which just uses a
single byte CRC is almost certainly available for the AVR as it is the one
often used when programming these devices.

ian
Back to top
David Kelly
Guest





Posted: Mon Nov 28, 2005 1:15 am    Post subject: Re: CCITT in C++ for AVR Reply with quote

In article <dmcctj$1dkq$1@omega.artcom.pl>, RadGar <radgar45@jawnet.pl>
wrote:

Quote:
Hi,

First of all - I'm a total newbie to AVR or other microcontrollers
programming so forgive any mistakes I make.

#1 mistake is the thought of using C++ in an embedded application such
as you describe.

Quote:
To the subject now - I have no idea what type of compilers are
available for such microcontrollers (AVR etc). What I'd like to know is
there any library with CCITT (or other) calculation function. I'm aware
there are many source codes for that on the web, but I'd still would go
with the library function (just easier for the people to use it) - the
speed is not an issue. It's just easier to point other people to the lib
function in the documentation instead of making them type some code I
present in the doc.

If you must use a solution from a can then at least the 16 bit version
comes in avr-libc, the most common library used with avr-gcc.
http://www.nongnu.org/avr-libc/user-manual/group__util__crc.html

Avr-gcc (including the Windows package of avr-gcc called WinAVR) is a
very good C compiler and environment for AVR development.
Back to top
RadGar
Guest





Posted: Mon Nov 28, 2005 9:15 am    Post subject: Re: CCITT in C++ for AVR Reply with quote

David Kelly wrote:
Quote:
#1 mistake is the thought of using C++ in an embedded application such
as you describe.

Not my choice.

Quote:

If you must use a solution from a can then at least the 16 bit version
comes in avr-libc, the most common library used with avr-gcc.
http://www.nongnu.org/avr-libc/user-manual/group__util__crc.html

Avr-gcc (including the Windows package of avr-gcc called WinAVR) is a
very good C compiler and environment for AVR development.

On comp.lang.c++ I got the link to the avr-libc, but thanks. That's what
I was looking for. IMO C is also good, as the OO stuff that comes with
C++ is not necessary. Thanks for the info, regards

RadGar
Back to top
 
Post new topic   Reply to topic    CASTalk.com Forum Index -> Embedded System All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




VoIP Electronics Powered by phpBB