[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: |
Nils Kristian Strom |
Subject: |
Re: [avr-gcc-list] AVR GCC compiler for win98 |
Date: |
18 Apr 2002 23:23:38 -0400 |
On Thu, 2002-04-18 at 16:19, Rob Ward wrote:
>Hi. I am using GCC under w2k. I tried using this code from avrfreaks...
>
>#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?
If you look deeper into the header files, which declare PORTD and DDRD,
you will se that they look like this:
#define PORTD 0x12
#define PIND 0x10
So what you are writing, is in fact
0x12 |= 0x10;
So the compiler complainst Invalid lvalue (lvalue = left side value).
The compiler error makes prefect sense ;-)
The reason for this, is that IO registers (PORTB etc) are different from
normal registers (r0 through r31). You need to use in/out instructions
to move the contents of the IO registers to normal registers, then do
your arithmetic on these. Most people use the macros inp(), outp(),
sbi() and cbi() for this.
You must use these macros.
outp( sw4_pin, sw4_dir ); /* output */
foo = ~(inp( sw4_in ) ); /* read and invert */
outp( foo, sw4_port ); /* output */
Regards
Nils
avr-gcc-list at http://avr1.org
- [avr-gcc-list] AVR GCC compiler for win98, sreelakshmi, 2002/04/28
- Re: [avr-gcc-list] AVR GCC compiler for win98, Peter Bosscha, 2002/04/28
- Re: [avr-gcc-list] AVR GCC compiler for win98, Paulo Abreu, 2002/04/28
- Re: [avr-gcc-list] AVR GCC compiler for win98, Nils Kristian Strom, 2002/04/28
- Re: [avr-gcc-list] AVR GCC compiler for win98, Rob Ward, 2002/04/28
- Re: [avr-gcc-list] AVR GCC compiler for win98, Valéry Florimond \(Thought Technology Ltd\), 2002/04/28
- Re: [avr-gcc-list] AVR GCC compiler for win98, Larry Barello, 2002/04/28
- Re: [avr-gcc-list] AVR GCC compiler for win98,
Nils Kristian Strom <=
- Re: [avr-gcc-list] AVR GCC compiler for win98, Rob Ward, 2002/04/28
- Re[2]: [avr-gcc-list] AVR GCC compiler for win98, Andreas Schwarz, 2002/04/28
- Re: [avr-gcc-list] AVR GCC compiler for win98, Rob Ward, 2002/04/28
- RE: [avr-gcc-list] AVR GCC compiler for win98, PE, 2002/04/28
- RE: [avr-gcc-list] AVR GCC compiler for win98, Sander Pool, 2002/04/28
- RE: [avr-gcc-list] AVR GCC compiler for win98, Panther Electronics, 2002/04/28
- RE: [avr-gcc-list] AVR GCC compiler for win98, Marc R. Wetzel, 2002/04/28
- Re: [avr-gcc-list] AVR GCC compiler for win98, webmaster, 2002/04/28
- Re: [avr-gcc-list] AVR GCC compiler for win98, Marc Wetzel, 2002/04/28
Re: [avr-gcc-list] AVR GCC compiler for win98, Sander Pool, 2002/04/28