ZBO CPU
ZBO DMA
PIO
zeo
zao crc
ZBO CPU
How
does
the
Non-Maskable
lnterrupt
acknowledge cycle and RETN instruction actually
work?
A :When
a
Non-Maskablelnterrupt
is
acknowledged,nter rupt flip-flop #1 (IFF1) is
actually cleared to inhibit the acknowledgement of
maskable interrupts. The state of
1nterrupt flip-flop #2 (IFF2)
This is lhe
is n
ot altered only can
time that the contents of
and
disagree
IFF1 When the RETNinstruct
ion IFF2 the state of IFF2
executes.
F1.
This allows
is copied back into
the state of
fore
a
IF
maskable interrupts. beNon
Maskable lnterrupl
to be restored after service routine execution.
Q How are subtraction operations performed?
3-129
...-
3-130
1andwill
A.
was executed.
This paradox can be traced to the mtemal timing of !
he CPU Theproblem is that the interrupt flip-flop
{IFF2) is cleared before il s actually transferred to
the PN flag. The state of lhe interrupt enable latch is
notcopied into the parity flag unlil after the interrupt
time, occurring during the executon of the
mslruct1on, has been ac cepted S1nce the
acceptance of theinterrupt automati cally clears the
interrupt enablelalch. the parity flagis also cleared,
despite the fact that interrupts were en abled when
the instruction started executing
A neat solulion to this anomaly relies on the fact that
at least oneitem -- the old PC value-is saved on the
stack when an interrupt 1saccepted. The ne:xt entry"
position on the stack (the word below the address
currently held
in the stack po1nter) may be deared before executron of
LO A,I (or LDA,R) lf that zero value haschangedby
the time thal the nex1instruction in the routine is
executed,
then
an
inlerrupt
must
havebeen accepted.This implies that interrupts were
enabled, even if the state of the
parity flag suggests that they were not. Of course.if
the parity flag is found to be set after LD A,R (LO
A,1) has be enexecuted,there is no need to check
thestack top.
lnterrupts are definitely enabledif the parity flag is
inthis state
:rwo routnes are listed here Both retum carry clear
if 1nterrupts are enabled,set otherwise . Bolh corrupt
the A register. it does nol contain the value in the 1
(or A) register on exit The status of all flags except
the carry flag are undefined on exit
The first rout1ne may be loaded anywhere in memory
except "page zero" - OOOOh to OOFFh. This small
restriction comes about because the routine checks
ony the most significant byte of lhe "nexf stack
entry . ThisbyteWi_ll
benon-zero afteraninterrupt
hasoccurred if and only if the routineitself is not on
page 2ero. The secondroutine tests both bytes of the
"next'' entry and. therefore. overcomes this restriction.
GETIFF
XOR
PUSH A
F POP AF
lD
A,I
RET PE
DEC
SP
DEC SP
POP AF
ANO
RET
NZ
SCF
RET
ENO
;C flag, acc. =
GETIFF
PUSH HL
XOR
LD
H.A
lD
L,A
PUSH HL
POP HL
LD
A,I
JP
PE,
;Save HL conlents
;C flag, acc. := O
;HL := OOOOh
;Stack bottom :=
OOOOh
;Restore SP
;P flag := IFF2
RET
POP
HL
DEC
DEC
POP
LO
OR
POP
RE
T
SC
F
POPHL:
RET
END
3-131
asynchronous inputs:
Z80 CPU
e;
'-------------------------1. All
interfaces
between
synchronous
and
asynchro nous system thal use clocked bi-stable
devices are subject to the "meta-stable"
phenomenon.
2.The probability of occurrence of a meta-stable
stateis
directly proportional of the frequency of changes
in the state at the inter1aceand inversely
proportionalto the exponentialof the switching
speedof the devices used.
''""'
A
Z80 DMA
Q: Does DMA recogrnze only 8-bit 1/0 addresses?
A The DMA device does not care whether the 1/0
ad dresses ar memory addresses are 8bit or 16-bi .
The Z80 DMA can address jusi as many 1/0
locations as il can memory local ons.
Q: What is the importance on !he placement of the "LOAD"
commands?
A: The "LOAD" command only loads the contents of
the
source
addressregister
intothe
source
addresscounler. The contents of the destination
address register are automatically loaded into the
destination
address counter the firstlime the
destination
address
gets
incre
mented
or
decremented.
'ts08
Figure 1.
zso
0 any eonstrainls
user
zao
zao P10
O When us1ng a port of the PIOin b1I mode (mode 3).
can any ot the bits, programmed as outputs, affect
the ln er rupt conditions sel for recogniz1ng inputs?
A While 1t is undocumented,itis possble thal the state of
lhe bits programmed as outpu1s could be used as
sabsfy1ng conditions for the mode 3 interrupt
equatt0n. 11 tS recommended that all bits not
needed for the mterrupts be masked off
Q Can the PIO be programmed to provide a 16-bit
A.Yes
3-133
'LS123
'LS123
B
O: How can you get two PIOs to talk with each other
in
Mode 2 operation?
N Suggest using ARDY1 andBRDY2 to generate astrobe
pulse for ASTB1 and BSTB2. Sama setup could be
used tor ARDY2 and BRDY1 anc1 for ASTB2 and
BSTB1 .The logic basically consists e>f a 74LS123
(one shot) and a 74LS08 (ANO gate). The ARDY1
and BROY2 s1gnals are ANDedtogether and
suppiled as B TRG for generating ASTB1 and
BSTB2. The ARDY2 and BRDY2 signals are ANDed
together and supplied as the ATRG for generating
BSTB1 and AST82.The A TRG tor geneting
ASTB1andBST82is
alwayslow
(grounded).Inthts
manner.the port control signals are usedto set the
priority for strobe signa! generation.
Please refer to Figure 2 and Table 1.
o
o
-lmm
l
l
-SS'l'IJ1 iredioo
1
1
oo
o
o
1
J
2-71
2-i> l
1
l
o
o
2-- l
,
1-72
1-::> 2
1
2
1. Disable
CPUinterrupts;
program
ming error.Dependingupon the details of the
problem, there are severa!solutions.
1. The interrupts
assoon
as nterrupts are enabled.
3.A change in bit pattem (whilein Mode 3) may
cause an interrupt. A detined state for extemal
inputsis recomrnended for power-up sequences.
O: How can 1 get aroundthe fact that only one "bit set"
can
be detected al a time in the OR bit mode?
A:one possibility would be to "mask" that bit during
the interrupt service routine. Another possibility is
to use externa! hardware to "mask" the bit.
o:
states that no
addit1onal wait states (other than the automatic wait
slate 1nserted by the CPU) are allowed in the 1/0
cycles. Why?
A : lt is not that the the wait states aren't allowed. il is
jusi that lhey don't accomplish any1hing.The dala will
arrive al a particular time for the read cycles, and the
interna! write strobe is generated as a result of the
clo<:k edges that willbe avalaible.Dunng the
readcycle. 1t is possible that an improper value of
the down-counter could be released onto lhe bus if
additional wait states were added (the counter
could change in the middle of the read operation).
Z80 CTC
O:How does the software reset commandto the CTC
affect the rest of the CTC's operation?
A : The data book and the technical manual differ in
the inforrnation that ispresenledon thissubject. A
software reset command stop the counter from
counting any further. In arder to start the counter
again, a new time constant must be loadedinto the
time constant register. AH bits in a mode control word
will cause the operation of the CTC to be affected.
lnterrupt
Modem control signals
Features
O: What is the maximum data rate of the SIO?
A: 1/5 of the system clock rate. So it is 1.6Mbls
3-135
A:
Registers
rue
lnterrupt
O W'hat are the various lnterruptng conditions?
A The SIO can generate 1nterrupts from 1he
rece1ver. Transmitter and Extemal/status for each
channel (6 sources) Thts 1s a list of ali
condit1ons that could poss1bly generate an
1nterrup1(one channel onlylisted).
Transm1tter
Rece1ver
ExlemaVStatus
ransition on
OCDJ
interrupts?
A:ves lf thernterruptingcondition has a higher priority
than
theinterrvpt currently being serviced it wll cause an
other rnterrupt, thus nesting the interrupt service.
A: No.
Willenabling
lnterruptafter
atransition
on
theSyncJHunt bit cause lnterrupt to oc:cur?
A No.ExtemaVStatus lnterrupt should be enabled belore
the transit1on occurs
Note lt is advisable to execute tha Reset
ExVStatus lnterrupt command in advance, so that
the status of ARO. bit 04 rellects the curren!
condition.
O
A. Either
3-137
l ! !; \I:. 3'1M'7JA
----------------------- - ==
o wnen 1nterlacing the SIO to the CPU other lhan the Z80
CPU,is rt poss1ble to assert M1 and IORQ at the
same ltme as the lnterrupt acknowledge cycie to
s1mulate Z80 trm1ng?
a) Asynchronous?
b)Synchronous
e) SDLC?
A a) In asynchronous modes, the transm1tter goes tnlo
a markmg state whenever all data has been sent
b) Inthe synchronous mode the SIO willsendout 16
bits ol CRC (2 bytes, 11 programmed and the
Transmrtter underrun/EOM atch has been reset)
followed by the appropnate number of Sync
character The line will lhen conltnue lo 1dte sync
characters
e) Inlhe SDLC mode lhe SIO w1ll send out 16 bits of
CRC (2 bytes ; 11 programmed and lhe
Transm1tter underrunJEOM Latch has been reset)
followed by the
SDLC flag character (7Eh). The hne willthen
contrnue loidte SDLC flag characters.
O: When Auto enable bit is set, will OCD & CTS going
true cause an lnterrupt?
i (ldeally.
enable for
enable bit 1s
transm1tter
Transm1tter
ANOed with the status of CTS) So when CTS is
1nactive, transm1t stops 1mmedrately (The data
be1ng shifted out wrll be sending out completely,
however)
each channel?
A Yes.
w1ll
3 138
CRC
characters are afso transmitted?
A' Try the following procedure:
1 lnitialize
Interna! tlming
O When the transmtter is dsabled. when does the
Externa! interface
O: Can a sloppy system clock cause problems in
SIO operation?
A. Yes. The specs on this system clock are verylight and
must be metto prevent SIOmalfunctiori The specrca
t1ons are
Symbol
Descriptron
VIHC
VIHL
Clod< "H"
Clocl< "L''
Min
Max
Vcc-0 6 5. 5
-0 3 0.45
A: One bi1 bme atter the last bi1 of the data leaves !he
transmit shift
reg1ster.
Unit
Volt
Volt
duty cyde?
3-139
time"?
A:No.
Asynchronous Mode
O:Wtry are there different Clock factors?
A :These clocklactors enable the SIOto sample the
center
of the data cell.Inthe X 16 mode, the SIO divides
the bit cellinto 16 counts and samples on count s.
,
33-144c0
==========================::::::::::=-
,,.. . . . . . . . . . . . ----
07 D6 05 04 03 02 01
1
2
3
4
1
1
O
1 1 1 0 0
1 1 0 0 0
1 O O O d
0 0 0 d d
O O d d d
Q
d
d
d
d
d
d
d
d
d
synchronous Mode
o.Can you
(RR1 ;06)
changes?
A No.1he CRC error status 1s not one of the special
rece1ve condihons. Perhaps. explanation of cyclic re
dundancy block checkingand how the 810operates for
CRCis relevan!
CRC
Cyclic AedundanctChecking 1s a method of
checklng for errors in serial data transm1ssion. ltis
also known as the polynomial error code ched< The
polynomial is an algebraiclunction used to create a
constant from the message bit pattern This
constan!, generated and accumulated in both the
Transmitter and Receiver, is usedto divide the
binary numeric valueof the character The quotient is
discarded and the remainder added to the
nex1character wtlich again 1s divrded This contin
ues until!he last character when thc
rema1ri<1eristrans mit1ed to !he receiver for
compariso11 with the Re ceiver's remainder An
equal companson indicated no errors, while an
unequal companson rndicates an error in
transmission
SIO-CRC
The SIO conta1ns CRC generation and check1ng in
the
Transmitter and Aeceiver
11 allows for eilher of two polynom1als to be used.
chronous communicahon
brsync
3-141
o:
O:
SDLC mode
O: How does the SIO send CRC?
A: The SIO can be programmed to automat1cally send
the CRC. Firsl.write the firstbyte of the message to be
sent. This guarantees the transmitteris full. Then.
reset the Transmit Underrun/EOM latch (WR0,10h}.
Write the
resi of tl'le data frame. When lhe transmit buffer
under
runs,
lhe
CRC
willbesent.
Thefollowmgtabledescnbes the action takenbythe
SIOfor the bit orentedprotocols.
Tx Underrun
rupls).
which
use less than 8-bit sync characters?
A The sync charcter match log1c within the Sto only
mak.es companson on 8 bit boundanes (8-btts for
Action
Comment
Upon hUnderrun
Send CRC+Flags
Send Flags
Valid Frame
Software
CRC
Q:In SDLC mode, when do you get the End of Message
(EOM) mterrupt?
A.
3142
o:When
A.
flag in SDLC?
Upon receiptof seven continuous ones. the
breaklabort bit will be set to 1ndicate the abort
condit1on Th1s brt will rema1n set unlilthe SIO
rece111es a zero
3-143