From: Jim Brain (brain_at_jbrain.com)
Date: 2007-05-09 19:07:42
Marko Mäkelä wrote:
> I think you confused PIN and PORT. I didn't say anything about PORT,
> and I previously wrote that you should set PORT=0 for open-collector
> operation. We have the following truth table:
>
> PORT=0,PIN=0,DDR=0: input, high-Z ("disconnected")
> PORT=0,PIN=0,DDR=1: output 0
> PORT=0,PIN=1,DDR=0: output weak 1 with a pull-up resistor
> PORT=0,PIN=1,DDR=1: output 0
>
> The first line is equivalent to outputting 1 if there
> is a pull-up resistor somewhere else in the circuit, like I believe
> there is in the joystick port.
>
Can you point to some documentation, as I just checked the AVR
datasheet, and PIN is read-only:
"Three I/O memory address locations are allocated for each port, one
each for the Data
Register – PORTx, Data Direction Register – DDRx, and the Port Input
Pins – PINx. The
Port Input Pins I/O location is read only, while the Data Register and
the Data Direction
Register are read/write."
As well, the pullup is only active when PORT is HI and DDR is LO:
"If PORTxn is written logic one when the pin is configured as an input
pin, the pull-up
resistor is activated. To switch the pull-up resistor off, PORTxn has to
be written logic
zero or the pin has to be configured as an output pin. The port pins are
tri-stated when a
reset condition becomes active, even if no clocks are running."
PORT=0,DDR=0 is input, HiZ
PORT=1,DDR=0 is input, pullup
PORT=X, DDR=1, X is output.
Are you talking about a different uC, or the some MOS part?
Jim
--
Jim Brain, Brain Innovations (X)
brain@jbrain.com
Dabbling in WWW, Embedded Systems, Old CBM computers, and Good Times!
Home: http://www.jbrain.com
Message was sent through the cbm-hackers mailing list
Archive generated by hypermail pre-2.1.8.