ok diese programm ist für den mega128 zumindest habe ich diesen code aus dem datenblatt des mega128.
Code:#include <inttypes.h> #include <avr/io.h> #include <avr/signal.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; }
und wenn ich das compile kommen folgende fehlermeldungen:
Build started 7.2.2006 at 11:14:26
avr-gcc -mmcu=atmega128 -Wall -gdwarf-2 -DF_CPU=16000000 -O0 -fsigned-char -Wp,-M,-MP,-MT,usart.o,-MF,dep/usart.o.d -c ../usart.c
../usart.c: In function `USART_Init':
../usart.c:11: error: `UBRRH' undeclared (first use in this function)
../usart.c:11: error: (Each undeclared identifier is reported only once
../usart.c:11: error: for each function it appears in.)
../usart.c:12: error: `UBRRL' undeclared (first use in this function)
../usart.c:14: error: `UCSRB' undeclared (first use in this function)
../usart.c:14: error: `Txen' undeclared (first use in this function)
../usart.c:16: error: `UCSRC' undeclared (first use in this function)
../usart.c:16: error: parse error before ';' token
../usart.c:34: error: `UCSRA' undeclared (first use in this function)
../usart.c:37: error: `UDR' undeclared (first use in this function)
../usart.c:37: warning: `return' with a value, in function returning void
make: *** [usart.o] Error 1
Build failed with 10 errors and 1 warnings...
MFG Danielsan
Lesezeichen