avr-gcc-list
[Top][All Lists]
Advanced

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

Re: [avr-gcc-list] 163 avr-gcc program problem - resend


From: sue and clay wispell
Subject: Re: [avr-gcc-list] 163 avr-gcc program problem - resend
Date: Wed, 22 May 2002 02:46:52 -0400
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0rc2) Gecko/20020510

hi eric,

thank you for the idea. i have tried your suggestion, but without success. the headers in the new version sound great. i will have to track it down.

in case anyone else is interested, i have attached a tarred, bz2 file that contains my test code. it will expand into a directory called test. run "make work" for a working example and "make hose" for the problematic code.

thanks,

clay


' wrote:

<snipped>
>>// main loop
>>while(1)
>>{
>>//if(bit_is_set(UCSRA,RXC)) outp(inp(UDR),UDR); // read in character
>>cmd();
>>}
>>
>>return 0;
>>}
>>
>>void cmd(void)
>>{
>>if(bit_is_set(UCSRA,RXC)) outp(inp(UDR),UDR); // read in character
>>}
>>
If you take a look at the outp and inp macros in iomacros.h, you'll notice that they're pretty gnarly. Try unnesting the calls: void cmd(void)
{
    volatile unsigned char ch;
if(bit_is_set(UCSRA,RXC))
    {
        ch = inp(UDR);
        outp(ch, UDR);
    }
    return;
}
This code is untested; however, with convoluted macros such as those, it is always best to use them in the most simplest manner. I put in the volatile just in case the optimizer decided to do something flaky with the variable. I downloaded the Beta 2 version of AVR GCC for the ATmega128 which includes an optional set of new headers to allow direct assignment to the registers instead of the inp() and outp() macros. These headers are great! This is the standard way to access registers on practically all other compilers and I'm surprised that they weren't done this way until now (I'm relatively new to the GCC compiler, but have been doing embedded software for over 7 years). HTH, Eric Weddington



____________________________________________________
<http://www.incredimail.com/redir.asp?ad_id=309&lang=9> /IncrediMail/ - *Email has finally evolved* - *_Click Here_* <http://www.incredimail.com/redir.asp?ad_id=309&lang=9>


Attachment: test.bz2
Description: Binary data


reply via email to

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