[Top][All Lists]

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

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

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:


I am trying to turn two bits off on a port as
quickly as possible, how do these two methods

PORTD = (PORTD & ~PD1) & ~PD4;


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:

reply via email to

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