avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] efficiency of assigning bits


From: Royce & Sharal Pereira
Subject: Re: [avr-gcc-list] efficiency of assigning bits
Date: Fri, 18 Mar 2005 09:00:39 +0530
User-agent: Opera M2(BETA3)/8.0 (Win32, build 7522)

Hi,

On Fri, 18 Mar 2005 03:43:19 +0530, Jamie Morken <address@hidden> wrote:
----- Original Message -----
From: "E. Weddington" <address@hidden>
Date: Monday, March 14, 2005 11:38 am
Subject: Re: [avr-gcc-list] efficiency of assigning bits


To clear bit 0 and set bits 1,2,3 without disturbing the other bits:

PORTD = (PORTD & ~(_BV(0))) | (_BV(1)|_BV(2)|_BV(3));


Thanks that is working!

I noticed this in the avr-libc usermanual FAQ:

"http://www.nongnu.org/avr-libc/user-manual/FAQ.html#faq_intpromote";

So would it be a good idea (for saving uC time) to convert that above line to this:

PORTD = (PORTD & (unsigned char)~(_BV(0))) | (unsigned char)_BV(1)|_BV(2)|_BV(3));

Whew! What a long winded way to do things! This takes less time/energy to enter:

PORTD &= ~(1 | (1<<1) | (1<<2));

And is quite readable. It also has the same effect as the (unsigned char) attribute above.

--Royce.


--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]