[SOLVED] How to init USART on ATMEGA128?

Status
Not open for further replies.

bianchi77

Advanced Member level 4
Joined
Jun 11, 2009
Messages
1,313
Helped
21
Reputation
44
Reaction score
20
Trophy points
1,318
Location
California
Visit site
Activity points
9,442
Guys,

I tried to init USART on ATMEGA128 by following this tutorial:

https://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=45341


but I got this message
../mainV5.c:49:2: error: 'UCSRB' undeclared (first use in this function)


Did I miss a library here ?
I put
#include <avr/io.h> already...

Thanks

- - - Updated - - -

I got it :
Code:
void usart_Init( unsigned int ubrr )
{
/* Set baud rate */

	UBRR0H = (unsigned char)(ubrr>>8);
	UBRR0L = (unsigned char)ubrr;
	/* Enable receiver and transmitter */
	UCSR0B = (1<<RXEN)|(1<<TXEN);
	/* Set frame format: 8data, 2stop bit */
	UCSR0C = (1<<USBS)|(3<<UCSZ0);
}
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…