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

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

Re: [avr-gcc-list] Using AVR Tools


From: Dan Lyke
Subject: Re: [avr-gcc-list] Using AVR Tools
Date: Thu, 22 Jan 2004 11:21:46 -0800

ks_347 writes:
>  1) So basically I am trying to write a simple program so that I can
>     put "hi" through serial communication.


You'll want to look through the datasheet and understand all of this,
but yes, with the standard includes on the right chip (this is clipped
from some code I wrote for the AtMega8515, compiled with avr-gcc on
Debian Linux, "unstable" distribution), your code would look something
like:

        // initialization
        // Set up the USART for 9600,n,8,1 with 8MHz clock
        UBRRH = 0;
        UBRRL = 51;
        UCSRA = 0;
        UCSRB = (1<<RXEN)|(1<<TXEN);
        UCSRC = 0x80 | (1<<URSEL)|(1<<UCSZ0)|(1<<UCSZ1);

        // pump out them characters.
        while (1)
        {       
                while (!(UCSRA & (1 << UDRE)));
                UDR = 'h';
                while (!(UCSRA & (1 << UDRE)));
                UDR = 'i';
        }

Dan



reply via email to

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