I/O Ports; Port B - Atmel AT90S4433-8AC Manual

8-bit microcontroller with 2k bytes of in-system programmable flash
Table of Contents

Advertisement

I/O Ports

Port B

Port B Data Register – PORTB
Port B Data Direction Register
– DDRB
Port B Input Pins Address –
PINB
AT90S2313
50
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 uninten-
tionally 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 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 17.
Table 17. Port B Pin Alternate Functions
Port Pin
Alternate Functions
PB0
AIN0 (Analog Comparator positive input)
PB1
AIN1 (Analog Comparator negative input)
PB3
OC1 (Timer/Counter1 Output Compare Match output)
PB5
MOSI (Data input line for memory downloading)
PB6
MISO (Data output line for memory uploading)
PB7
SCK (Serial clock input)
When the pins are used for the alternate function, the DDRB and PORTB Registers
have to be set according to the alternate function description.
Bit
7
6
$18 ($38)
PORTB7
PORTB6
Read/Write
R/W
R/W
Initial value
0
0
Bit
7
6
$17 ($37)
DDB7
DDB6
Read/Write
R/W
R/W
Initial value
0
0
Bit
7
6
$16 ($36)
PINB7
PINB6
Read/Write
R
R
Initial value
N/A
N/A
5
4
3
PORTB5
PORTB4
PORTB3
R/W
R/W
R/W
0
0
0
5
4
3
DDB5
DDB4
DDB3
R/W
R/W
R/W
0
0
0
5
4
3
PINB5
PINB4
PINB3
R
R
R
N/A
N/A
N/A
2
1
0
PORTB2
PORTB1
PORTB0
R/W
R/W
R/W
0
0
0
2
1
0
DDB2
DDB1
DDB0
R/W
R/W
R/W
0
0
0
2
1
0
PINB2
PINB1
PINB0
R
R
R
N/A
N/A
N/A
0839I–AVR–06/02
PORTB
DDRB
PINB

Advertisement

Table of Contents
loading

Table of Contents