Forum Menu




 


Log in Problems?
New User? Sign Up!
AVR Freaks Forum Index

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
societyofrobots
PostPosted: Dec 06, 2007 - 04:04 PM
Hangaround


Joined: Nov 29, 2007
Posts: 134


I am trying to use the AVRlib uart code to get the uart working on my ATmega2560.

The ATmega2560 has four uarts, but AVRlib only has a two uart file called uart2.c. A quick google search did not yield any source code for ATmega2560 uart.

Normally this wouldn't be a problem, as uart2.c looks easily hackable to four uarts. Plus, I've gotten the normal uart.h to work on my ATmega644.

However, compiling the unmodified uart2.c code gives me these errors:
Quote:
uart4.c: In function 'uartSendByte':
uart4.c:167: error: 'UDRE' undeclared (first use in this function)
uart4.c:167: error: (Each undeclared identifier is reported only once
uart4.c:167: error: for each function it appears in.)
uart4.c: At top level:
uart4.c:357: warning: 'SIG_UART0_TRANS' appears to be a misspelled signal handler
uart4.c:363: warning: 'SIG_UART1_TRANS' appears to be a misspelled signal handler
uart4.c:369: warning: 'SIG_UART0_RECV' appears to be a misspelled signal handler
uart4.c:375: warning: 'SIG_UART1_RECV' appears to be a misspelled signal handler

Anyone know how to fix this?

I'm not the most skilled of programmers (actually, I'm a mechanical engineer) . . . so try to dumb down any of your comments for me =P

ps -
when I say unmodified, I only changed these lines:
Code:

bufferInit(&uartRxBuffer[0], uart0RxData, UART0_RX_BUFFER_SIZE);
bufferInit(&uartTxBuffer[0], uart0TxData, UART0_TX_BUFFER_SIZE);

to these lines:
Code:
bufferInit(&uartRxBuffer[0], (u08*) uart0RxData, UART0_RX_BUFFER_SIZE);
bufferInit(&uartTxBuffer[0], (u08*) uart0TxData, UART0_TX_BUFFER_SIZE);

to correct for an AVRlib bug (the fix works fine for uart.c)
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
clawson
PostPosted: Dec 06, 2007 - 04:30 PM
10k+ Postman


Joined: Jul 18, 2005
Posts: 71947
Location: (using avr-gcc in) Finchingfield, Essex, England

Well read the error "UDRE undeclared" then search for UDRE in your datasheet. Lo and behold - in the 2560 the UDRE bits are numbered UDRE0, UDRE1, UDRE2, UDRE3. So just fix those up.

As for the mis-spelled signal handlers. Take a look into \winavr\avr\include\avr\iom2560.h and you'll find that it just pulls in a more generic iomxx0_1.h. So take a look at that and you'll find the follwoing from which you need to pick the right spelling for the SIGNAL handler names (I guess it's too much trouble to point out that SIGNAL is deprecated and has been replaced by ISR these days - maybe best to stick with what you got, it'll still work for the time being):
Code:
C:\WinAVR-20070525\avr\include\avr>grep SIG_US iomxx0_1.h
#define SIG_USART0_RECV                 _VECTOR(25)
#define SIG_USART0_DATA                 _VECTOR(26)
#define SIG_USART0_TRANS                _VECTOR(27)
#define SIG_USART1_RECV                 _VECTOR(36)
#define SIG_USART1_DATA                 _VECTOR(37)
#define SIG_USART1_TRANS                _VECTOR(38)
#define SIG_USART2_RECV                 _VECTOR(51)
#define SIG_USART2_DATA                 _VECTOR(52)
#define SIG_USART2_TRANS                _VECTOR(53)
#define SIG_USART3_RECV                 _VECTOR(54)
#define SIG_USART3_DATA                 _VECTOR(55)
#define SIG_USART3_TRANS                _VECTOR(56)

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
societyofrobots
PostPosted: Dec 06, 2007 - 05:47 PM
Hangaround


Joined: Nov 29, 2007
Posts: 134


thanks! problem solved.

_________________
How do YOU make a robot?
http://www.societyofrobots.com
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2006 The PNphpBB Group
Credits