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

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
I/O Ports
Port A
Port A Data Register – PORTA
Port A Data Direction Register
– DDRA
Port A Input Pins Address –
PINA
Port A as General Digital I/O
1228D–AVR–02/07
All AVR ports have true read-modify-write functionality when used as general digital I/O
ports. This means that the direction of one port pin can be changed without unintention-
ally 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).
Port A is an 8-bit bi-directional I/O port.
Three I/O memory address locations are allocated for the Port A, one each for the Data
Register – PORTA, $1B($3B), Data Direction Register – DDRA, $1A($3A) and the Port
A Input Pins – PINA, $19($39). The Port A Input Pins address is read-only, while the
Data Register and the Data Direction Register are read/write.
All port pins have individually selectable pull-up resistors. The Port A output buffers can
sink 20 mA and thus drive LED displays directly. When pins PA0 to PA7 are used as
inputs and are externally pulled low, they will source current if the internal pull-up resis-
tors are activated.
The Port A pins have alternate functions related to the optional external memory inter-
face. Port A can be configured to be the multiplexed low-order address/data bus during
accesses to the external Data memory. In this mode, Port A has internal pull-up
resistors.
When Port A is set to the alternate function by the SRE (External SRAM Enable) bit in
the MCUCR (MCU Control Register), the alternate settings override the Data Direction
Register.
The Port A Input Pins address (PINA) is not a register; this address enables access to
the physical value on each Port A pin. When reading PORTA, the Port A Data Latch is
read and when reading PINA, the logical values present on the pins are read.
All eight pins in Port A have equal functionality when used as digital I/O pins.
PAn, general I/O pin: The DDAn bit in the DDRA Register selects the direction of this
pin. If DDAn is set (one), PAn is configured as an output pin. If DDAn is cleared (zero),
PAn is configured as an input pin. If PORTAn is set (one) when the pin is configured as
an input pin, the MOS pull-up resistor is activated. To switch the pull-up resistor off, the
PORTAn has to be cleared (zero) or the pin has to be configured as an output pin. The
Bit
$1B ($3B)
Read/Write
Initial Value
Bit
$1A ($3A)
Read/Write
Initial Value
Bit
$19 ($39)
Read/Write
Initial Value
PORTA7
PINA7
DDA7
R/W
R/W
N/A
7
0
7
0
R
7
PORTA6
PINA6
DDA6
R/W
R/W
N/A
6
0
6
0
R
6
PORTA5
PINA5
DDA5
R/W
R/W
N/A
5
0
R
5
0
5
PORTA4
PINA4
DDA4
R/W
R/W
N/A
4
0
R
4
0
4
PORTA3
PINA3
DDA3
R/W
R/W
N/A
3
0
R
3
0
3
PORTA2
PINA2
DDA2
R/W
R/W
N/A
2
0
R
2
0
2
ATmega161(L)
PORTA1
PINA1
DDA1
R/W
R/W
N/A
R
1
0
1
0
1
PORTA0
PINA0
DDA0
R/W
R/W
N/A
0
0
0
0
0
R
PORTA
DDRA
PINA
89

Related parts for atmega161-4pi