|
From: | E. Weddington |
Subject: | Re: [avr-gcc-list] efficiency of assigning bits |
Date: | Mon, 14 Mar 2005 09:52:48 -0700 |
User-agent: | Mozilla Thunderbird 0.7.3 (Windows/20040803) |
Jamie Morken wrote:
Hi, I am trying to turn two bits off on a port as quickly as possible, how do these two methods compare: PORTD = (PORTD & ~PD1) & ~PD4; or:cbi(PORTD, PD1); cbi(PORTD, PD4);
cbi is deprecated and no longer exists in the latest release of avr-libc.
I am assuming these are equivalent.
Not quite. Do this: PORTD &= ~(_BV(PD1) | _BV(PD4)); That will clear the two bits at the same time.Take a look at this thread at the AVR Freaks website for a quick tutorial on bit operators in C:
<http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&p=40348&highlight=programming+101#40348>
[Prev in Thread] | Current Thread | [Next in Thread] |