Hardware manual

Common Features Description
2-24 Atmel 8051 Microcontrollers Hardware Manual
4316A–8051–01/04
2.5 Port Structures
and Operation
All four ports in the 80C51 are bidirectional. Each consists of a latch (Special Function
Register P0 through P3), an output driver, and an input buffer.
The output drivers of Ports 0 and 2, and input buffers of Port 0, are used in accesses to
external memory. In this application, Port 0 outputs the low byte of the external memory
address, time-multiplexed with the byte being written or read. Port 2 outputs the high
byte of the external memory address when the address is 16 bits wide. Otherwise the
Port 2 pins continue to emit the P2 SFR content.
All the Port 3 pins, and (in the case of Timer2) two Port 1 pins are multifunctional. They
are not only port pins, but also serve the functions of various special features as listed
below:
The alternate functions can only be activated if the corresponding bit latch in the port
SFR contains a 1. Otherwise the port pin is stuck at 0.
2.5.1 I/O Configurations Figure 2-4 shows a functional diagram of a typical bit latch and I/O buffer in each of the
four ports. The bit latch (one bit in the port’s SFR) is represented as a Type D flip-flop,
which will clock in a value from the internal bus in response to a “write to latch” signal
from the CPU. The Q output of the flip-flop is placed on the internal bus in response to a
“read latch” signal from the CPU. The level of the port pin itself is placed on the internal
bus in response to a “read pin” signal from the CPU. Some instructions that read a port
activate the “read latch” signal, and others activate the “read latch” signal, and others
activate the “read pin” signal.
Port Pin Alternate Function
(1)
P1.0
(1)
P1.1
P3.0
P3.1
P3.2
P3.3
P3.4
P3.5
P3.6
P3.7
T2 (Timer/Counter 2 external input)
T2EX (Timer/Counter 2 capture/reload trigger)
RXD (serial input port)
TXD (serial output port)
INT0
(external interrupt)
INT1
(external interrupt)
T0 (Timer/Counter 0 external input)
T1 (Timer/Counter 1 external input)
WR
(external Data memory write strobe)
RD
(external Data memory read strobe)
Note: 1. P1.0 and P1.1 serve these alternate functions only on the microcontrollers including
Timer2.