VRS51x540
______________________________________________________________________________________________
www.ramtron.com
page 11 of 40
Auxiliary P3 Port Functions
The Port 3 I/O pins are shared with the UART
interface, INT0 and INT1 interrupts, Timer 0 and Timer
1 inputs and finally the #WR and #RD lines when
external memory access is performed.
FIGURE 10: P3 PORT STRUCTURE
D Flip-Flop
Q
Q
IC Pin
Read Register
Internal Bus
Write to
Register
Read Pin
X1
Vcc
Auxiliary
Function: Input
Auxiliary
Function: Output
The following table describes the auxiliary function of
the port 3 I/O pins.
TABLE 10: P3 AUXILIARY FUNCTION TABLE
Pin
Mnemonic
Function
P3.0
RXD
Serial Port:
Receive data in asynchronous
mode. Input and output data in
synchronous mode.
P3.1
TXD
Serial Port:
Transmit data in asynchronous
mode. Output clock value in
synchronous mode.
P3.2
INT0
External Interrupt 0
Timer 0 Control Input
P3.3
INT1
External Interrupt 1
Timer 1 Control Input
P3.4
T0
Timer 0 Counter Input
P3.5
T1
Timer 1 Counter Input
P3.6
WR
Write signal for external memory
P3.7
RD
Read signal for external memory
Software Particularities Concerning the Ports
Some instructions allow the user to read the logic state
of the output pin, while others allow the user to read
the content of the associated port register. These
instructions are called read-modify-write instructions. A
list of these instructions may be found in the table
below.
Upon execution of these instructions, the content of the
port register (at least 1-bit) is modified. The other read
instructions take the present state of the input into
account. For example, the instruction ANL P3, #01h
obtains the value in the P3 register; performs the
desired logic operation with the constant 01h; and re-
copies the result into the P3 register. When users want
to take the present state of the inputs into account,
they must first read these states and perform an AND
operation between the reading and the constant.
MOV A, P3; State of the inputs in the accumulator
ANL A, #01; AND operation between P3 and 01h
When the port is used as an output, the register
contains information on the state of the output pins.
Measuring the state of an output directly on the pin is
inaccurate because the electrical level depends mostly
on the type of charge that is applied to it. The functions
shown below take the value of the register rather than
that of the pin.
TABLE 11: LIST OF INSTRUCTIONS THAT READ AND MODIFY THE PORT USING REGISTER
VALUES
Instruction
Function
ANL
Logical AND ex: ANL P0, A
ORL
Logical OR ex: ORL P2, #01110000B
XRL
Exclusive OR ex: XRL P1, A
JBC
Jump if the bit of the port is set to 0
CPL
Complement one bit of the port
INC
Increment the port register by 1
DEC
Decrement the port register by 1
DJNZ
Decrement by 1 and jump if the result
is not equal to 0
MOV P., C
Copy the held bit C to the port
CLR P.x
Set the port bit to 0
SETB P.x
Set the port bit to 1