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: Jamie Morken
Subject: Re: [avr-gcc-list] efficiency of assigning bits
Date: Thu, 17 Mar 2005 14:13:19 -0800

Hi,

----- 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));


cheers,
Jamie Morken






reply via email to

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