Delay Calulation

A register is loaded with a number , depending on the time delay required ,and then the register is decremented until it reaches zero by setting up a loop with a conditional jump instruction.The loop causes the delay, depending on the clock period of the system.

Code for looping:

mvi c,count 7T

loop: dcr c 4T

jnz loop 10/7 T


if the clock frequency of the system f = 2MHZ
clock period (T) = 1/f = 1/2*10 power-6 = 0.5 microsecond

here, we have to calculate three time variable (t0, tL , tLA)


time to execute MVI C ,count
    t0 = 7T
  = 7 x 0.5 microsecond
 t0  = 3.5 microsecond


time delay in loop (tL) = T x loop T states x count

here T = 0.5 microsecond

loop T states = 4T + 10T = 14T
tL = 0.5 microsecond x 14 x count
tL = (7 x count) microsecond


The T states for JNZ is 10/7

so we also have to consider the 7T states of JNZ . when the loop executes for specified count times , and at last when the condition is false , the T states it takes will be only 7T so we have to subtract 3T from the tL that we have calculated above.

tLA = 3T
= 3 x 0.5 microsecond
 = 1.5 microsecond

now total time taken tt is given by
tt= t0 + tL - tLA
 = 3.5 + (7 x count ) -1.5 microsecond
 tt = 2 + 7 x count

now if you need delay for 1 milli second then

1ms = 2 + 7 x count microsecond
count = (1000-2)/7
count = 140

the maximum delay can be 1.8ms
ie count is 255 in decimal


if you need more time delay you can use second method


The time delay can be considerably increased by setting a loop and using a register pair with a 16 bit number( maximum FFFFh)
.The 16 bit number is decremented by using the instruction DCX .However the instruction DCX doesnot set the zero flag and without the test flags ,jump instructios cannot check desired data conditions .Additional techniques ,therefore must be used tto set the Zero flag.now we use OR instruction [ Continue reading]

4 comments:

Unknown said...

thank you

Unknown said...

Gzb

Krishnakant said...

Can you tell maximum time delay using register pair

Skiran said...

Its really super blog.