Lecture03 PDF
Lecture03 PDF
DELAYS
LECTURE 3
MVI B,00H
NEXT: DCR B
MVI C,8CH
DELAY: DCR C
JNZ DELAY
MOV A,B
OUT PORT#
JMP NEXT
ILLUSTRATIVE PROGRAM: ZERO TO NINE
(MODULO TEN) COUNTER
Start
START: MVI B,00H
MOV A,B Initialize counter
DSPLAY: OUT PORT #
LXI H,16-bit Display Output
LOOP: DCX H
MOV A,L Load Delay register
ORA H
Decrement Delay register
JNZ LOOP
INR B Is Delay register=0?
MOV A,B
CPI 0AH Next Count
JNZ DSPLAY
Is count =0AH?
JZ START
If yes, Initialize counter
If no, Display Output
ILLUSTRATIVE PROGRAM:
GENERATING PULSE WAVEFORMS
•Generates a continuous
square wave with the period
of 500 Micro Sec. Assume
the system clock period is
325ns, and use bit D0
output the square wave.
•Delay outside loop: T0=46
T states * 325=14.95 micro
sec.
•Loop delay: TL=4.5 micro
sec
•Total Td=To+TL
Count=34 H
DEBUGGING COUNTER AND
TIME DELAY PROGRAMS
It is designed to count
from 100(base 10) to 0
in Hex continuously
with a 1 second delay
between each count.
The delay is set up
using two loops. The
inner loop is executed to
provide approximately
100ms delay and is
repeated 10 times, using
outer loop to provide a
total delay of 1 second.
The clock period of
system is 330ns.