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

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 B
Port B Data Register – PORTB
Port B Data Direction Register
– DDRB
Port B Input Pins Address –
PINB
1228D–AVR–02/07
Port B is an 8-bit bi-directional I/O port.
Three I/O memory address locations are allocated for the Port B, one each for the Data
Register – PORTB, $18($38), Data Direction Register – DDRB, $17($37) and the Port B
Input Pins – PINB, $16($36). The Port B 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 B output buffers can
sink 20 mA and thus drive LED displays directly. When pins PB0 to PB7 are used as
inputs and are externally pulled low, they will source current if the internal pull-up resis-
tors are activated.
The Port B pins with alternate functions are shown in Table 30.
Table 30. Port B Pin Alternate Functions
Note:
The Port B Input Pins address (PINB) is not a register; this address enables access to
the physical value on each Port B pin. When reading PORTB, the Port B Data Latch is
read and when reading PINB, the logical values present on the pins are read.
Bit
$18 ($38)
Read/Write
Initial Value
Bit
$17 ($37)
Read/Write
Initial Value
Bit
$16 ($36)
Read/Write
Initial Value
Port Pin
PB0
PB1
PB2
PB3
PB4
PB5
PB6
PB7
1. When the pins are used for the alternate function, the DDRB and PORTB Registers
have to be set according to the alternate function description.
Alternate Functions
OC0 (Timer/Counter0 Compare Match Output)/T0 (Timer/Counter0 External
Counter Input)
OC2 (Timer/Counter2 Compare Match Output)/T1 (Timer/Counter1 External
Counter Input)
RXD1 (UART1 Input Line)/AIN0 (Analog Comparator Positive Input)
TXD1 (UART1 Output Line)/AIN1 (Analog Comparator Negative Input)
SS (SPI Slave Select Input)
MOSI (SPI Bus Master Output/Slave Input)
MISO (SPI Bus Master Input/Slave Output)
SCK (SPI Bus Serial Clock)
PORTB7
DDB7
PINB7
R/W
R/W
N/A
7
0
7
0
R
7
PORTB6
DDB6
PINB6
R/W
R/W
N/A
6
0
6
0
R
6
PORTB5
PINB5
DDB5
R/W
R/W
N/A
5
0
5
0
R
5
PORTB4
PINB4
DDB4
R/W
R/W
N/A
4
0
4
0
R
4
(1)
PORTB3
PINB3
DDB3
R/W
R/W
N/A
3
0
R
3
0
3
PORTB2
PINB2
DDB2
R/W
R/W
N/A
R
2
0
2
2
0
ATmega161(L)
PORTB1
PINB1
DDB1
R/W
R/W
N/A
1
0
R
1
1
0
PORTB0
PINB0
DDB0
R/W
R/W
N/A
R
0
0
0
0
0
PORTB
DDRB
PINB
91

Related parts for atmega161-4pi