Hi,

Ich möchte mit meinem Atmega128 daten zum Pc senden und zwar über die RS232 schnitte.

Jetzt habe ich im Datenblatt nachgelesen wie das geht und diese Source samples in mein Programm eingebaut aber ständig kommt beim compilieren das die usart variablen "first use in this function" sind. kann mir da jemand weiterhelfen? ich habe als include dateien avr/io.h und string.h.

mein code sieht also so aus:

Code:
#include <avr/io.h>
#include <string.h>

void USART_Init (unsigned int baud)
{
/* Set baud rate */
	UBRRH = (unsigned char)(baud>>8);
	UBRRL = (unsigned char)baud;
/* Enable reciever and transmitter */
	UCSRB = (1<<RXEN)|(1<<Txen);
/* Set frame format: 8data, 2stop bit*/
	UCSRC = (1<<USBS)|(3<<UCSZ0=;
}



void USART_Transmit (unsigned char data)
{
/* Wait for empty transmit buffer */
	while(!(UCSRA & (1<<UDRE)))
;
/* Put data into buffer, sends the data '/
	UDR = data;
}


unsigned char USART_Recieve(void)
{
/* Wait for data to be recieved */
	while (!(UCSRA & (1<<RXC)))
;
/* Get and return recieved data from buffer */
	return UDR;
}
Danke schonmal für eure hilfreichen Antworten

MFG DanielSan