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 Alex Shepherd

> Thanks for the quick response, I understand what the code 
> does, just not why a bit wise AND is performed and what 
> (1<<UDRE) "means". In my baby-C, I would probably have written 

(1<<UDRE)

Means:

	The integer value 1, bit shifted left by the integer value of UDRE
(5) as defined in the header file.

This will give a binary value of 00010000 or 0x10 which is then ANDed with
the UCSRA port to mask off the value of the UDRE bit, then loop while it is
not set.

> while (UCSRA.x != 0); 
> 
> where x is the UDRE bit. Any advantages to the way it's done below ?

Well, I think some other compilers may do this sort of thing and there was
some discussion a while ago about this approach with AVR-GCC but AFAICT the
(1<<UDRE) approach is the current preferred way of doing this with AVR-GCC.

Alex

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.