Yahoo Groups archive

AVR-Chat

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

Message

Re: [AVR-Chat] Re: Some C help please !

2007-03-13 by Dennis Clark

See below:

kernels_nz wrote:
> Hi Alex,
> 
> Thanks for the quick response, I understand what the code does, just
> not why a bitwise AND is performed and what (1<<UDRE) "means". In my

   It means shift the '1' to the left UDRE places.  It is common short 
hand in C.

> baby-C, I would probably have written 
> 
> while (UCSRA.x != 0); 

   Which is perfectly fine if UCSRA is defined to work that way.  I 
often define structs for SFRs so that I'd do something like:

while (UCSRAbits.UDRE != 0)

> where x is the UDRE bit. Any advantages to the way it's done below ?

Do it each way and see which one compiles to a smaller assembly block, 
and use that one. :)

DLC

> cheers
> Hein B
> 
> 
> --- In AVR-Chat@yahoogroups.com, "Alex Shepherd" <lists06@...> wrote:
> 
>>>while ((UCSRA & (1<<UDRE))==0);
>>
>>Loop around checking the state of the UDRE bit in the UCSRA port
> 
> until the
> 
>>bit value is NOT 0
>>
> 
> 
> 
> 
> 
> 
>  
> Yahoo! Groups Links
> 
> 
> 

-- 
---------------------------------------
Dennis Clark    TTT Enterprises
---------------------------------------

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.