[Top][All Lists]

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

Re: [avr-gcc-list] crc16.h - why inlined

From: Volkmar Dierkes
Subject: Re: [avr-gcc-list] crc16.h - why inlined
Date: Thu, 9 Jan 2003 22:29:48 +0100
User-agent: 40tude_Dialog/ Hamster/


On Thu, 9 Jan 2003 10:22:14 +0100 (MET), Joerg Wunsch wrote:

> Volkmar Dierkes <address@hidden> wrote:
>> I used these days the _crc16_update function which works very well.
>> But why it is defined as an inlined function? As I can see there is
>> no additional prologue/epilogue code if compiled without inline.
> The value of this file has already been questioned on the avr-libc
> mailing list.

I was not sure if I should send it to the avr-libc or avr-gcc list.

> We are open for any suggestions, ranging from putting
> it into an include/compat directory and maintain it for backwards
> compatibility with older avr-libc releases only, up to make it as
> useful as possible -- and then fully documented.  If you're using it,
> and find it useful, please make a stab at documenting it (and in
> particular, provide a small example for its use).

I will tell you something about my project. I am implementing a boot 
loader. I now, there are some available, but non of them meet my 
requirements. Therefore I changed an existing boot loader which I 
got from Gernot Gams. His version works very well but I wanted to 
have a check at the start of the boot loader for correct content in 
the flash. Also I found that his version has some problems if the 
hex file isn't in the right format (all page to page borders are at 
the end of a data line) I decided to include a CRC at the received 
bytes too. Than I looked for CRC algorithmens but I didn't found 
something what I am looked for. As I began my own implementation I 
had the idea to look at the gcc files. And wow, there was a crc16.h 

I like the efficient implementation of this routine. But, to come to 
my initial post, as I needed it for a boot loader, I didn't have 
much space, especially that I am using the ATmega8 with a maximum of 
2KB boot space. Therefore I had a problem with the inlined function. 
I need the function 3 times and this is for this application too 
much space. I used the crc16 also for incoming data via uart as for 
calculation of a crc for a flash block. Both are mentioned by Marek.

As Marek wrote, he thougth that the inlined usage shouldn't be a 
problem. In most application this might be, but for this it was to 
much. I didn't used it in a ISR, in this case it would be better to 
have it inlined. But on my opinion in most cases this could be done 
outside of an ISR.

The resulted code for the function increases only a little bit: 
call/ret and two movw instructions. Maybe a earlier avr-gcc version 
produced more overhead or maybe in another environment. I used the 
WINAVR of december.

Joerg, one question. what do you mean with a "stab" for documenting 
it. Maybe I can provide the bootloader itself as a example (but this 
would be a big example, and at least for the boot stuff, too), but I 
want to ask Gernot Gams before, because I got the initial code from 

avr-gcc-list at http://avr1.org

reply via email to

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