147
AT94KAL Series FPSLIC
Rev. 1138G–FPSLI–11/03
I/O Ports
All AVR ports have true read-modify-write functionality when used as general I/O ports. This
means that the direction of one port pin can be changed without unintentionally changing the
direction of any other pin with the SBI and CBI instructions. The same applies for changing
drive value (if configured as output) or enabling/disabling of pull-up resistors (if configured as
input).
PortD
PortD is an 8-bit bi-directional I/O port with internal pull-up resistors.
Three I/O memory address locations are allocated for the PortD, one each for the Data Regis-
ter – PORTD, $12($32), Data Direction Register – DDRD, $11($31) and the Port D Input Pins
– PIND, $10($30). The Port D Input Pins address is read only, while the Data Register and the
Data Direction Register are read/write.
The PortD output buffers can sink 20 mA. As inputs, PortD pins that are externally pulled Low
will source current if the pull-up resistors are activated.
PortD Data Register – PORTD
PortD Data Direction Register – DDRD
PortD Input Pins Address – PIND
The PortD Input Pins address – PIND – is not a register, and this address enables access to
the physical value on each PortD pin. When reading PORTD, the PortD Data Latch is read,
and when reading PIND, the logical values present on the pins are read.
PortD as General
Digital I/O
PDn, General I/O pin: The DDDn bit in the DDRD register selects the direction of this pin. If
DDDn is set (one), PDn is configured as an output pin. If DDDn is cleared (zero), PDn is con-
figured as an input pin. If PDn is set (one) when configured as an input pin the MOS pull-up
resistor is activated. To switch the pull-up resistor off the PDn has to be cleared (zero) or the
pin has to be configured as an output pin. The port pins are input with pull-up when a reset
condition becomes active, even if the clock is not running, see Table 46.
Bit
7
6
5
4
3
2
1
0
$12
PORTD7
PORTD6
PORTD5
PORTD4
PORTD3
PORTD2
PORTD1
PORTD0
PORTD
Read/Write
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Initial Value
1
1
1
1
1
1
1
1
Bit
7
6
5
4
3
2
1
0
$11
DDD7
DDD6
DDD5
DDD4
DDD3
DDD2
DDD1
DDD0
DDRD
Read/Write
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Initial Value
0
0
0
0
0
0
0
0
Bit
7
6
5
4
3
2
1
0
$10
PIND7
PIND6
PIND5
PIND4
PIND3
PIND2
PIND1
PIND0
PIND
Read/Write
R
R
R
R
R
R
R
R
Initial Value
Pull1
Pull1
Pull1
Pull1
Pull1
Pull1
Pull1
Pull1