AT90S/LS4434 and AT90S/LS8535
72
When the pins are used for the alternate function, the DDRB and PORTB registers have to be set according to the alternate
function description.
Port B Data Register – PORTB
Port B Data Direction Register – DDRB
Port B Input Pins Address – PINB
The Port B Input Pins address (PINB) is not a register and 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.
Port B As General Digital I/O
All eight pins in Port B have equal functionality when used as digital I/O pins.
PBn, general I/O pin: The DDBn bit in the DDRB register selects the direction of this pin. If DDBn is set (one), PBn is con-
figured as an output pin. If DDBn is cleared (zero), PBn is configured as an input pin. If PORTBn 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 PORTBn has to be
cleared (zero) or the pin has to be configured as an output pin. The port pins are tri-stated when a reset condition becomes
active, even if the clock is not running.
Note:
n: 7,6…0, pin number.
Alternate Functions of Port B
The alternate pin configuration is as follows:
•
SCK – Port B, Bit 7
SCK: Master clock output, slave clock input pin for SPI channel. When the SPI is enabled as a slave, this pin is configured
as an input regardless of the setting of DDB7. When the SPI is enabled as a master, the data direction of this pin is con-
trolled by DDB7. When the pin is forced to be an input, the pull-up can still be controlled by the PORTB7 bit. See the
description of the SPI port for further details.
Bit
7
6
5
4
3
2
1
0
$18 ($38)
PORTB7
PORTB6
PORTB5
PORTB4
PORTB3
PORTB2
PORTB1
PORTB0
PORTB
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
$17 ($37)
DDB7
DDB6
DDB5
DDB4
DDB3
DDB2
DDB1
DDB0
DDRB
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
$16 ($36)
PINB7
PINB6
PINB5
PINB4
PINB3
PINB2
PINB1
PINB0
PINB
Read/Write
R
R
R
R
R
R
R
R
Initial value
N/A
N/A
N/A
N/A
N/A
N/A
N/A
N/A
Table 32.
DDBn Effects on Port B Pins
DDBn
PORTBn
I/O
Pull-up
Comment
0
0
Input
No
Tri-state (high-Z)
0
1
Input
Yes
PBn will source current if ext. pulled low
1
0
Output
No
Push-pull Zero Output
1
1
Output
No
Push-pull One Output