intd.
87C51GB HARDWAREDESCRIPTION
operandis a port, or a port bit, theseinstructionsread
the latch rather than the pin:
ANL (logicalAND, e.g.ANL PI, A)
ORL
(logical011 e.g.ORL P2, A)
XRL (logicalEX-OK e.g.XRL P3, A)
JBc (jumpifbit = 1and clear bit, e.g.JBC
P1.1,LABEL)
CPL
(complementbit, e.g.CPL P3.0)
INC (increment,e.g.INC P2)
DEC (decrernen~e.g.DEC P2)
DJNZ (decrementand jump if not zero, e.g.
DJNZ P3, LABEL)
MOVPX.Y,C (movecarry bit to bit Y of Port X)
CLRPX.Y
(clearbit Y ofPort X)
SETBPX.Y (setbit Y of Port X)
It is not obviousthat the last three instructionsin this
list are read-modify-writeinstructions, but they are.
Theyreadthe port bytejall 8bitsjmodifythe addressed
bit, then write the newbyteback to the latch.
The reason that read-modify-writeinstructions are di-
rected to the latch rather than the pin is to avoid a
possible
misinterpretationof the voltage level at the
pin. For example,a port bit mightbe usedto drivethe
baseof a transistor. Whena 1is written to the bit, the
transistor is turnedon.If the CPU then readsthe same
port bit at the pin rather than the latch, it willread the
base voltageof the transistor and interpret it as a O.
Readingthe latch rather than the pin will return the
correct valueof 1.
4.5 Accesaing External Memory
Accessestoexternalmemoryareoftwotypes:am—ewes
toexternal ProgramMemoryand amesses
to external
Data Merno~Accessra
to external ProgramMemory
use signal PSEN (program store enable) as the read
strobe. Accesses
to externalData Memoryuse = or
~ (alternatefunctionsof P3.7and P3.6)to strobethe
memory.Referto Figures5 through 7.
STATS1 STATE2 STATS3 STATS4 STAIES STATE6 STATS1 STATS2
IPIIP21PIIP21PIIPSIPIIP21PIIP21PIIF21PIIP21PIIml
XTAL1:
I
1 I I i 1
REii:
OATA
OATA
I
DATA
--l
~sAuPLso k-aAuPLEo
PO:
~ ~ 1A ~ ~
I
PCL
I
OUT
I I I
I
L I
P2:
I
PCHour
I
PCHOUT
I
PCHOUT
,
270697-7
Figure5.ExternalProgramMemoryFetcttaa
6-11