Gast
#853865
hallo,
wo liegt der Fehler? hab die Usart Funktionen aus dem Datenblatt
übernommen aber es wird nichts gesendet...
bitte mal meinen Quellcode anschauen :)
#include <avr/io.h>
#include <stdint.h>
#include "main.h"
// F_CPU is defined by makefile
#define BAUD 9600
#define MYUBRR F_CPU/16/BAUD-1 // Asynchronous Normal mode
int main(void)
{
USART_Init(MYUBRR);
while(1) { // Mainloop
USART_Transmit("hello");
USART_Transmit("\r\n");
}
return 0;
}
void USART_Init( unsigned int ubrr)
{
/* Set baud rate */
UBRRH = (unsigned char) (ubrr>>8);
UBRRL = (unsigned char)ubrr;
/* Enable receiver and transmitter */
UCSRB = (1<<RXEN)|(1<<TXEN);
/* Set frame format: 8data, 2stop bits*/
UCSRC = (1<<URSEL)|(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;
}