avr-gcc-list
[Top][All Lists]
Advanced

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

Re: [avr-gcc-list] Heli reding inputs from PORTC


From: J.C. Wren
Subject: Re: [avr-gcc-list] Heli reding inputs from PORTC
Date: Mon, 02 Feb 2004 18:16:48 -0500
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6b) Gecko/20040110 Thunderbird/0.4

If you're trying to read the I/O pins, you need to read PINC. PORTC is the value that will be output on the port pins for any pins that are outputs, or control whether the pullups are enabled for pins that are inputs. Read and writing PORTC is perfectly legal, just probably not what you want.

   --jc

Helix wrote:

Hello,
I am trying to use an input, but seems thatI'm doing something wrong here.
I tried to turn on some ouput (where I connected a led thatI already tested
as output)
when I read an input high.
My output is always off (seems that I'm unable to read input from portc.
What am I doing wrong here ?
TIA

My CPU is AT90S8515

int main()
{
unsigned int i;
unsigned char c ;

// enable all bits of PORTA as outputs
DDRA = 0xff;

// enable all bits of PORTC as inputs
DDRC = 0x00;

   while (1) {

 if (PORTC)
  PORTA = 0xFF ;
 else
  PORTA = 0 ;
}

return 0;
}


_______________________________________________
avr-gcc-list mailing list
address@hidden
http://www.avr1.org/mailman/listinfo/avr-gcc-list



reply via email to

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