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

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

Re: [avr-gcc-list] UART transmitting problem


From: Joerg Wunsch
Subject: Re: [avr-gcc-list] UART transmitting problem
Date: Thu, 27 Nov 2003 22:11:38 +0100 (MET)

As "Laurence Anderson" <address@hidden> wrote:

>Could somebody tell me if the following code should work on an
>AT90S8515?

As far as I could tell without actually testing it myself, yes.

Please allow me a few recommendations:

>#include <io.h>

#include <avr/io.h>

We've moved all AVR-specific include files into the avr/ subdir, so
the top-level is supposed to only be used for those include files that
are either described in the C standard, or are commonly found there in
other C implementations (like POSIX).

>       outp( BV(TXEN), UCR );

Don't use inp() and outp() anymore.  Just write:

        UCR = _BV(TXEN);

>       while ( ( c = *(buf++) ) != '\0' ) {

No need for the extra parens:

        while ((c = *buf++) != '\0') ...

is a very common construct that can frequently be found in C code,
including in the K&R ``bible''.

>       while(1); // Loop forever

Not needed either.  If you "return 0;" from main(), the library code
will run in an infinite loop anyway.  Of course, it's nothing you'd do
in a real application...
-- 
J"org Wunsch                                           Unix support engineer
address@hidden        http://www.interface-systems.de/~j/


reply via email to

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