[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Butterfly RS232?
From: |
Daniel O'Connor |
Subject: |
Re: [avr-gcc-list] Butterfly RS232? |
Date: |
Wed, 30 Nov 2005 11:27:13 +1030 |
User-agent: |
KMail/1.8.2 |
On Wed, 30 Nov 2005 10:54, Mike Young wrote:
> // Set baud rate
>
> UBRRH = (unsigned char)(baudrate>>8);
>
> UBRRL = (unsigned char)baudrate;
>
> // Enable 2x speed
>
> UCSRA = (1<<U2X);
>
> // Enable receiver
>
> UCSRB = (1<<RXEN)|(0<<TXEN)|(0<<RXCIE)|(0<<UDRIE);
This line turns the transmitter off..
I'm not sure why you have 0<<TXEN and others. I would write it as..
UCSRB = _BV(RXEN);
> // Async. mode, 8N1
>
> UCSRC = (0<<UMSEL)|(0<<UPM0)|(0<<USBS)|(3<<UCSZ0)|(0<<UCPOL);
This line has the same issue as the previous one, plus if you actually want to
modify UCSRC and not UBRRH (they are at the same address - at least on
ATMega32's) you need to set the MSB (URSEL), eg
UCSRC = _BV(URSEL) | _BV(UCSZ0) | _BV(UCSZ1);
--
Daniel O'Connor software and network engineer
for Genesis Software - http://www.gsoft.com.au
"The nice thing about standards is that there
are so many of them to choose from."
-- Andrew Tanenbaum
GPG Fingerprint - 5596 B766 97C0 0E94 4347 295E E593 DC20 7B3F CE8C
pgpAZ02YOSFtX.pgp
Description: PGP signature