[Top][All Lists]

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

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

From: '
Subject: Re: [avr-gcc-list] 163 avr-gcc program problem - resend
Date: Tue, 21 May 2002 09:35:44 -0600 (Mountain Daylight Time)

>>// main loop
>>//if(bit_is_set(UCSRA,RXC)) outp(inp(UDR),UDR); // read in character
>>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;
        ch = inp(UDR);
        outp(ch, UDR);
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).
Eric Weddington
  IncrediMail - Email has finally evolved - Click Here

reply via email to

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