EasyManua.ls Logo

Intel 8253 - I;O Port Access

Intel 8253
773 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
XA User Guide 7-16 4/17/98
7.4 Ports
I/O ports on any microcontroller provide a connection to the outside world. The capabilities of
those I/O ports determine how easily the microcontroller can be interfaced to the various external
devices that make up a complete application. The standard XA I/O ports provide a high degree of
versatility through the use of programmable output modes and allow easy connection to a wide
variety of hardware.
7.4.1 I/O Port Access
The standard on-chip I/O ports of the XA are accessed as SFRs. The SFR names used for these
ports begin with port 0, called P0. Port numbers and names go up in sequence from there, to the
number of ports on a specific XA derivative. Ports are normally identified by their names in
assembler source code, such as: "MOV P1,#0". This instruction causes the value 0 to be written
to port 1.
XA I/O ports are typically bit addressable, meaning that individual port bits are readable,
writable, and testable. An instruction using a port bit looks like this: "SETB P2.1". This
particular example would result in the second lowest bit in port 2 (bit 1) having a 1 written to it.
Reading of a Port Pin Versus the Port Latch
Each I/O port has two important logic values associated with it. The first is the contents of the
port latch. When data is written to a port, it is stored in the port latch. The second value is the
logic level of the actual port pin, which may be different than the port latch value, especially if a
port pin is being used as an input.
When a port is explicitly read by an instruction, the value returned is that from the pin. When a
port is read intrinsically, in order to perform some operation and store the value back to the port,
the port latch is read. This type of operation is called a read-modify-write.
Figure 7.14 How ports are read.
1) The following instructions cause read-modify-
write operations, and read the port latch when a
port or port bit is specified as the destination:
ADD Px, ...
ADDC Px, ...
ADDS Px, ...
AND Px, ...
DJNZ Px, ...
OR Px, ...
SUB Px, ...
SUBB Px, ...
XOR Px, ...
CLR Px.y
JBC Px.y, rel8
MOV Px.y, C
SETB Px.y
2) The following instruction reads the
port pins when a port is specified as
the destination operand:
CMP Px, ...
3) When a port or port bit is specified
as a source in any instruction, the port
pin is always read.

Table of Contents