[Top][All Lists]

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

Re: [avr-gcc-list] AVR GCC compiler for win98

From: Larry Barello
Subject: Re: [avr-gcc-list] AVR GCC compiler for win98
Date: Thu, 18 Apr 2002 14:18:45 -0700

GCC doesn't know how to access I/O directly.  You have to do the
following (i may have the order backwards - check iomacros.h)

    outb(sw4_dir, inp(sw4_dir) & ~sw4_pin);
    outb(sw4_port, inp(sw4_port | sw4_pin);

The sbi and cbi assembly instructions (which the macros reduce to) are
only one cycle each.  Much faster than in-modify-out that you were

----- Original Message -----
From: "Rob Ward" <address@hidden>

> Hi. I am using GCC under w2k. I tried using this code from
> #define sw4_pin (1<<4) //this could be (1<<PD4)
> #define sw4_port PORTD
> #define sw4_dir DDRD
> #define sw4_in PIND
> Then the following to toggle the pin / i/o direction...
> sw4_dir &= ~sw4_pin;//set port as input
> sw4_port |= sw4_pin; //switch on pull up
> however, I get "Invalid lvalue in assignment" for both the last two
lines when compiling. Could anyone tell my why this is?
> I don't want to use the __sbi and __cli macros as they take two
clock cycles to execute, whereas and'ing and or'ing the registers
directly only takes one clock cycle (as far as I understand it).

avr-gcc-list at http://avr1.org

reply via email to

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