|
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:
Forgive me if I don't have the correct bits that you want; this is just an example.Hi, ----- Original Message ----- From: "E. Weddington" <address@hidden> Date: Monday, March 14, 2005 8:52 am Subject: Re: [avr-gcc-list] efficiency of assigning bitsJamie 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 :)
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.
[Prev in Thread] | Current Thread | [Next in Thread] |