8085 Time-Delay-And-Counter
8085 Time-Delay-And-Counter
Lecture objectives: at the end of this lecture the student will able to:
1- Define the time delay.
2- Study types of time delay.
3- Design all types of counters.
Loading delay
in register
Exe. some of
instructions
Decrement
delay register
No Is
Register
=0
Yes
End
6.1
B. Time Delay Using Counter: Time delay can be created using counting process which means
executing number of instructions many times where the initial value of counter required to get
specific time delay can be determined. there are two types of delay using counter as below:
B.1 time delay using one register (8-bit counter): in this type of time delay the register
delay is one register loaded with 8-bit number in one loop as shown in program 6.1below :
Program 6.1
B. 2 time delay using register pair: in this type of time delay the register delay is register
pair loaded with 16-bit number in one loop as shown in program 6.2 below:
Program 6.2
C. time delay using loop with in loop: this time delay is used two loop one internal and the
other loop is external, these two loops can be designed by using one register or register pair
as shown in program 6.3 below:
6.2
Where Tt is total time interval. To is the out loop instructions time. Ti is in loop instructions time.
6.3
6.4
Where N10 is the number that loaded in delay register in decimal. t is the processor time clock.
Example 6.1: Calculate the time delay to programs (6.4, 6.5 and 6.6) below, (let the microprocessor
frequency is 1MHz)
Solution:
First t=1/F=1/1*106 =1µS
Program 6.4
Tt =To + Ti
To = [7Tstate (MVI C,37) + 7Tstate (JNZ loop1) + 6Tstate (HLT)]*t
=20 Tstate*1 µS =20 µS
Ti=[7Tstate (MVI A,33) + 4Tstate (RAR) + 4Tstate (DCR C) + 10Tstate (JNZ loop1)]*t*55
=[25Tstate]*t*55
=[25 µS]*55=1375 µS
Tt=20 µS+1375 µS=1395 µS =1.395 mS
loop1) * 254}+ 7Tstate (JNZ loop1) +4Tstate (DCR B)] * 55 +10Tstate (JNZ loop2)*54 Comment [DS2]: External loop
=[7Tstate (MVI D,FF) + {3825 Tstate }+{2450 Tstate}+7Tstate (JNZ loop1) +4Tstate (DCR B)]*55 + 540
= [18 + 3825 + 2450] * 55 + 540
= 346,115 + 540
=346500 Tstate=346,655 µS
Tt=To + Ti =20 µS+346,655 µS=346,675 µS=346.68ms
6.2 Counters:
6.2.1 Definition of counter: A counter program is an program written to design a counter (all
types of counter such as up, down, Johnson, serial, parallel, decimal, etc.) with flexibility in
controlling of time interval between counting states.
Example 6.2: write ALP (Assembly Language Program) to design down counter mod (255) and
display the counting states on out port with time delay (1ms) for each counting
state. Let the processor operate with frequency 2MHz.
Solution: Fig. (6.2) show the flow chat of the counter program
Counting state
display
Time delay
1ms
Update count
No
Is count
complete
Yes
End
other solution:
Tt = [10T (OUT 02) + 7T (MVI D, XX) + 4T*N10 (DCR D) + 10T*N10-1 (JNZ A2) + 7T (JNZ A2) +
4T (DCR A) + 10T (JNZ A1) ] * 0.5S
1000S =[ 38T + 4T*N10 + 10T* (N10-1)] * 0.5S
1000S = 19S + 2*N10 S+ 5*N10 S- 5S
1000S = 14S + 7*N10 S
N10 = (1000 - 14)/7 = 140.857=141
Therefore must loading equivalent to 141 in hexadecimal which equal (8D) in register D.
Home work:
1- Calculate the required time to execute the JPE instruction if the condition is satisfying. Let the
processor operate with 4 MHz frequency.
2- Write ALP to make the microprocessor working as up/down counter mod (32) with time delay
2ms between each two counting states. (let the frequency is 2 MHz)