[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [avr-chat] ATMega UART question
From: |
Sid Price |
Subject: |
RE: [avr-chat] ATMega UART question |
Date: |
Sat, 20 Dec 2008 18:23:53 -0700 |
This is the code I have:
UBRRL = (XTAL / (16L * BAUDRATE)) - 1; //set baud rate;
UCSRB = 0x18; // Rx enable Tx Enable
UCSRC = 0x06; // Asyn,NoParity,1StopBit,8Bit
As soon as the RX, Tx enable line executes I see a character sent, the PC
listening to that UART also receives a byte of zeroes,
Sid.
-----Original Message-----
From: Preston Wilson [mailto:address@hidden
Sent: Saturday, December 20, 2008 5:19 PM
To: address@hidden; AVR-CHAT
Subject: Re: [avr-chat] ATMega UART question
"Sid Price" wrote:
> I am working on a design using the one UART0 on a mega164p and I am having
> an issue with initialization of the UART. I notice that when I enable the
TX
> a byte of all zeros is transmitted. I even see this if I assert the TX
> enable bit with the debugger. Is this normal? Is there a way to avoid it?
> Thanks,
> Sid.
I have used UART0 on both the ATmega164P and ATmega324P and never seen the
behavior you describe. My uart init routine does the following:
... initialize head and tail pointers, and set baud rate
// Enable rx, tx, and rx complete interrupt
UCSR0B = (1<<RXCIE0)|(1<<RXEN0)|(1<<TXEN0);
// Set async 8N1
UCSR0C = (1<<UCSZ01)|(1<<UCSZ00);
In the UDRE interrupt routine, I assign the byte to transmit to UDR0.
-Preston