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: E. Weddington
Subject: Re: [avr-gcc-list] efficiency of assigning bits
Date: Mon, 14 Mar 2005 12:38:19 -0700
User-agent: Mozilla Thunderbird 0.7.3 (Windows/20040803)

Jamie Morken wrote:

Hi,

----- Original Message -----
From: "E. Weddington" <address@hidden>
Date: Monday, March 14, 2005 8:52 am
Subject: Re: [avr-gcc-list] efficiency of assigning bits

Jamie Morken wrote:


Not quite. Do this:

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

That will clear the two bits at the same time.

How can you set 3 bits and clear 1 bit on the same port with one line like 
above?  I read through your tutorial below but I couldn't figure out this still 
:)

Forgive me if I don't have the correct bits that you want; this is just an example.

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

Use the bit operator truth tables in the tutorial and work out each operation.

Eric

PS: Please reply to the list and not me personally. Thanks.




reply via email to

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