Yahoo Groups archive

AVR-Chat

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

Message

RE: [AVR-Chat] Re: help problem in uart

2005-07-01 by Robert Adsett

At 10:34 PM 7/1/05 +0200, Lasse Madsen wrote:

>IAR s compiler also does this on the same line & so I think it has nothing 
>to do with hardware references but simply that it s a while without content
>
>----------
>From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On Behalf 
>Of arhodes19044
>Oh, wait.... I see.  It gets optimized away because the while loop
>does not do anything.  Therefore the need to insert a nop.
>
>-got it....
>
>-Tony
>
>--- In AVR-Chat@yahoogroups.com, "arhodes19044" <spamiam@c...> wrote:
> > If the compiler optimizes it away, then it thinks that USCRA is
>not
> > volatile.  So.... can you declare somehow that UCSRA is volatile?
> >
> > However, I have never had the problem with references to hardware
> > registers being optimized away....
> >
> > -Tony
> >
> > --- In AVR-Chat@yahoogroups.com, "Lasse Madsen"
><lasse.madsen@e...>
> > wrote:
> > > Hi.
> > >
> > > Your problem is most likely that the compiler optimizes the line
> > > while(!(UCSRA&(1<<UDRE))); away.
> > >

Hmm, I'd consider that a compiler bug.  Whether the loop is empty or not if 
the expression contains volatile references it and by extension the while 
expression should not be optimized away.

Robert

" 'Freedom' has no meaning of itself.  There are always restrictions,   be 
they legal, genetic, or physical.  If you don't believe me, try to chew a 
radio signal. "  -- Kelvin Throop, III
http://www.aeolusdevelopment.com/

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.