> When code was compiled for atmega8 AND ran on an atmega8, > it simply did not work (until I hacked iom8.h). When you (incorrectly) modified iom8.h, you disguised the problem. The addresses that you changed to in iom8 refer to the TWI hardware on the mega8 but they do refer to UCSRC and UBRRH (separate registers) in the tiny2313. With that change, your code compiled for the mega8 is no longer clobbering the UBBRH register. That is probably why it appears to be working correctly. You should always take the example code in the datasheets as a general suggestion rather than guaranteed-to-work code. Further research is always necessary to confirm that the code is correct and complete. I've seen many complaints about cases where it appears that example code was simply copied from one datasheet to another without consideration for differences in the underlying hardware or was simply incorrect due to human error. Reading the special sub-section of the mega8 datasheet USART section entitled "Accessing UBRRH/UCSRC Registers" reveals what you need to do: UCSRC = (1<<URSEL) | flags; Without the URSEL bit, you'd actually be writing to the UBBRH register rather than the UCSRC register as desired. Don Kinzer ZBasic Microcontrollers http://www.zbasic.net
Message
Re: avr-gcc ATMega8 USART trouble, was: Compile problem
2009-12-06 by Don Kinzer
Attachments
- No local attachments were found for this message.