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

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

Re: [avr-gcc-list] quick question!!


From: Peter N Lewis
Subject: Re: [avr-gcc-list] quick question!!
Date: Tue, 14 May 2002 11:14:35 +0800

At 14:01 -0500 11/5/02, Brandon Tolbert wrote:
Is there any way to set up a pin to be both in and out? I mean when you set the port using the DDRB or DDRD it is either in or out. I have just been changing this before I used the port in the opposite direction is there another way?

If the pin is set to INPUT, then it can be used as both input and output. Externally, pull it low with a very large resistor (100k?), and use the PORT register to set or clear the pullup which will then change the value. Be careful with what you are outputing to though, because it will need to have very high impedance to ensure it doesn't mess up your output.

Also, if my understanding is correct, PIN bits represent the phyiscal state of the pin even for outputs, so you can have a pin set to OUTPUT and drive it externally and read what the pin is being set to externally using the PIN bits.

Both these techniques are a bit dubious and I would try to avoid them if I could. The first one would make me nervous as it depends on the pullup resistor values, and the second one would make me nervous because you are driving an output. To get more details, you'd need to visit Atmel's site and find some application notes that tell you exactly how to do both of these to ensure it will work in your situation.

HTH,
   Peter.
--
<http://www.interarchy.com/>  <ftp://ftp.interarchy.com/interarchy.hqx>
avr-gcc-list at http://avr1.org



reply via email to

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