Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

RE: [AVR-Chat] avr-gcc ATMega8 USART trouble, was: Compile problem

2009-12-06 by Steven Holder

Jims right,
 
these 2 defines do share the same location, when accessing the UCSRC Reg you
set the the ursel bit in the register when writing to the UCSRC else you are
writing to the UBBRH register .
 
Regards

  _____  

From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On Behalf
Of Marc R.J. Brevoort
Sent: 06 December 2009 18:31
To: AVR-Chat@yahoogroups.com
Subject: Re: [AVR-Chat] avr-gcc ATMega8 USART trouble, was: Compile problem


  

On Sun, 6 Dec 2009, Jim Wagner wrote:

>> #define UCSRC _SFR_IO8(0x20)
>> #define UBRRH _SFR_IO8(0x20)
> If I recall correctly, those two DO share the address and require a
> data bit to distinguish which is which. It is NOT a compiler error.

Thanks for your input, Jim.

I originally used the USART C code from the data sheet,
which worked fine with ATtiny2313.

The C code in the data sheet for the ATmega8 is identical,
and as such I'd expect the program to port cleanly between
these microcontrollers by simply specifying a different
-mmcu flag.

Strangely, the code didn't work on atmega8 as soon as I
specified -mmcu=atmega8, but it did when I specifield
-mmcu=attiny2313.

After the changes that I outlined in my previous post,
the code ports and works transparantly on either uC, as
I would have expected.

If the ATmega8 would need setting a data bit to
distinguish between UCSRC and UBRRH, then my proposed
change to the header file would not have made it work;
this evidence suggests that there was, in fact, a bug
in the mentioned header file.

As the ATmega8 *does* send data through the USART now,
I wonder if I'm overlooking something trivial?

Best,
Marc





[Non-text portions of this message have been removed]

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.