Port Loading And Interfacing; Read-Modify-Write Feature; Accessing External Memory - Intel MCS 51 User Manual

Table of Contents

Advertisement

i@L
8XC51FX HARDWARE DESCRIPTION
4.3 Port Loading and Interfacing
The output bfiers of Ports 1, 2, and 3 can each sink
1.6 MA at 0.45 V. These port pil13can be dliVeIl by
open-collector and open-drain outputs although o-to-l
transitions will not be fast since there is little current
pulling the pin up. An input Oturns off pullup pFET3,
leaving only the very weak pullup pFET2 to drive the
transition.
In external bus mode, Port O output buffers can each
sink 3.2 MA at 0.45 V. However, as port pins they
require externalpullups to be able to drive any inputs.
Sec the latest revision of the data sheet for design-in
information.
4.4
Read-Modify-Write Feature
Some instructions that read a port read the latch and
others read the pin. Which ones do which? The instruc-
tions that readthe latch ratherthan the pin are the ones
that read a VAIU% possibly change it, and then rewriteit
to the latch. These are called "read-modify-write"in-
structions. Listed below are the read-modify-write in-
structions. When the destination operand is a port, or a
port bit, these instructions read the latch rather than
the pin:
ANL
(logical AND, e.g., ANL Pl, A)
ORL
(logical OR, e.g., ORL P2, A)
XRL
(logical EX-OR, e.g., XRL P3, A)
JBc
(jump if bit = 1 and clear bit, e.g.,
JBC P1.1, LABEL)
CPL
(complement bit, e.g., CPL P3.0)
INC
(increment, e.g., INC P2)
DEC
(decrernen~ e.g., DEC P2)
DJNZ
(decrement and jump if not zero, e.g.,
DJNZ P3, LABEL)
MOV, PX.Y, C (move carry bit to bit Y of Port X)
CLR PX.Y
(clear bit Y of Port X)
SETB PX.Y
(set
bit Y of Port X)
It is not obvious that the last three instructions in this
list are read-modify-write instructions, but they are.
They read the port byte, all 8 bits, modify the addressed
bit, then write the new byte back to the latch.
The reason that read-modify-writeinstructions are di-
rected to the latch rather than
the
pin is to avoid a
possible misinterpretation of the voltage level at the
pin. For example, a port bit might be used to drive the
base of a transiator.When a 1 is written to the bit, the
transistoris turned on. If the CPU then reads the same
port bit at the pin ratherthan the latch, it will read the
base voltage of the transistor and interpret it as a O.
Reading the latch rather than the pin will return the
correct value of 1.
4.5
Accessing External Memory
Accesses to external memory are of two types: accesses
to externrdProgram Memory and acccases to external
Data Merno~Accesses
to external Program Memory
use signal PSEN (program store enable) as the read
strobe. Accesam to external Data Memory use ~
or
~
(alternatefunctions of P3.7 and P3.6) to strobethe
memory. Refer to Figures 5 through 7.
Fetches from external Program Memory always use a
lfibit address. Accesses to external Data Memory can
use either a 16-bit address (MOVX @ DPTR) or an
8-bit address (MOVX @ Ri);
=A~
1 =A'= 2 STATE 3 STATS 4 STATES ~ATS 6 STATS 1 STATS 2
IPtlnlP!lmlmlnl
Ptlmlmlml
Pl,nlPllmlFllnl
ATAL1:
ALE, ~
~:
OATA
OATA
--l
+~
+SAMPLSO
PO:
z
,
P2:
PCHOU7
.
Pcnolrr
Pmour
270S53-30
Figure 5. External Program Memory Fetches
5-1o

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the MCS 51 and is the answer not in the manual?

Table of Contents

Save PDF