Port b as general digital i/o, Alternate functions of port b – Rainbow Electronics AT90LS4433 User Manual

Page 73

Advertising
background image

73

AT90S/LS4433

1042G–AVR–09/02

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.

Port B as General Digital I/O

All six 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 configured 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:

1. n: 5..0, pin number.

Alternate Functions of Port B

The alternate pin configuration is as follows:

• SCK – Port B, Bit 5

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 DDB5.
When the SPI is enabled as a Master, the data direction of this pin is controlled by
DDB5. When the pin is forced to be an input, the pull-up can still be controlled by the
PORTB5 bit. See the description of the SPI port for further details.

• MISO – Port B, Bit 4

MISO: Master Data input, Slave Data output pin for SPI channel. When the SPI is
enabled as a Master, this pin is configured as an input, regardless of the setting of
DDB4. When the SPI is enabled as a Slave, the data direction of this pin is controlled by
DDB4. When the pin is forced to be an input, the pull-up can still be controlled by the
PORTB4 bit. See the description of the SPI port for further details.

• MOSI – Port B, Bit 3

MOSI: SPI Master Data output, Slave Data input for SPI channel. When the SPI is
enabled as a Slave, this pin is configured as an input, regardless of the setting of DDB3.
When the SPI is enabled as a Master, the data direction of this pin is controlled by
DDB3. When the pin is forced to be an input, the pull-up can still be controlled by the
PORTB3 bit. See the description of the SPI port for further details.

• SS – Port B, Bit 2

SS: Slave Port Select input. When the SPI is enabled as a Slave, this pin is configured
as an input, regardless of the setting of DDB2. As a Slave, the SPI is activated when this
pin is driven low. When the SPI is enabled as a Master, the data direction of this pin is

Table 24. DDBn Effects on Port B Pins

(1)

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

Advertising