atmega161-4pi ATMEL Corporation, atmega161-4pi Datasheet - Page 100

no-image

atmega161-4pi

Manufacturer Part Number
atmega161-4pi
Description
8-bit Microcontroller With 16k Bytes Of In-system Programmable Flash
Manufacturer
ATMEL Corporation
Datasheet
Port D
Port D Data Register – PORTD
Port D Data Direction Register
– DDRD
Port D Input Pins Address –
PIND
Port D as General Digital I/O
100
ATmega161(L)
Port D is an 8-bit bi-directional I/O port with internal pull-up resistors.
Three I/O address locations are allocated for the Port D, one each for the Data Register
– 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 Reg-
ister and the Data Direction Register are read/write.
The Port D output buffers can sink 20 mA. As inputs, Port D pins that are externally
pulled low will source current if the pull-up resistors are activated.
Some Port D pins have alternate functions as shown in Table 33.
Table 33. Port D Pin Alternate Functions
When the PD5 pin is used for the alternate function (OC1A), the DDRD and PORTD
Registers have to be set according to the alternate function description.
The Port D Input Pins address (PIND) is not a register; this address enables access to
the physical value on each Port D pin. When reading PORTD, the Port D Data Latch is
read and when reading PIND, the logical values present on the pins are read.
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 configured as an input pin. If PORTDn is set (one) when configured as an input
pin, the MOS pull-up resistor is activated. To switch the pull-up resistor off, the PORTDn
Bit
$12 ($32)
Read/Write
Initial Value
Bit
$11 ($31)
Read/Write
Initial Value
Bit
$10 ($30)
Read/Write
Initial Value
Port Pin
PD0
PD1
PD2
PD3
PD3
PD5
PD6
PD7
Alternate Function
RXD0 (UART0 Input Line)
TXD0 (UART0 Output Line)
INT0 (External Interrupt0 Input)
INT1 (External Interrupt1 Input)
TOSC1 (RTC Oscillator Timer/Counter2)
TOSC2 (RTC Oscillator Timer/Counter2)/OC1A (Timer/Counter1 Output
CompareA Match Output)
WR (Write Strobe to External Memory)
RD (Read Strobe to External Memory)
PORTD7
PIND7
DDD7
R/W
R/W
N/A
7
0
R
7
0
7
PORTD6
PIND6
DDD6
R/W
R/W
N/A
R
6
0
6
0
6
PORTD5
PIND5
DDD5
R/W
R/W
N/A
R
5
0
5
0
5
PORTD4
PIND4
DDD4
R/W
R/W
N/A
R
4
4
0
4
0
PORTD3
PIND3
DDD3
R/W
R/W
N/A
R
3
0
3
0
3
PORTD2
PIND2
DDD2
R/W
R/W
N/A
R
2
0
2
0
2
PORTD1
PIND1
DDD1
R/W
R/W
N/A
R
1
0
1
1
0
PORTD0
PIND0
DDD0
R/W
R/W
N/A
1228D–AVR–02/07
R
0
0
0
0
0
PORTD
DDRD
PIND

Related parts for atmega161-4pi