SlideShare a Scribd company logo
1 of 21
Counters & Time Delays
Need of Counter and Time Delays
•Counters are used primarily to keep track of
events.
•Time delays are important in setting up
reasonably accurate timing between two
events.
•The process of designing counters and time
delays using software instructions is far more
flexible and less time consuming than the
design process using hardware.
Counters
• A loop counter is set up by loading a register with
a certain value
Then using the DCR (to decrement) the contents
of the register are updated.
A loop is set up with a conditional jump
instruction that loops back or not depending on
whether the count has reached the termination
count.
•
•
Counters
The operation of a loop counter can be
•
described using the following flowchart.
this
Final
Count?
Yes
the count
of loop
U
No
Body
pdate
Is
Initialize
SampleALP for implementing
Using DCR instruction
a loop
MVI C, 15H
DCR C
LOOP
LOOP
JNZ
Using a Register Pair as a
Counter
Loop
• Using a single register, one can
maximum count of 255 times.
repeat a loop for a
• It is possible to increase this count by using a
register pair for the loop counter instead of the
single register.
– A minor problem arises in how to test for the final
count since DCX and INX do not modify the flags.
– However, if the loop is looking for when the count
becomes zero, we can use a small trick by ORing the
two registers in the pair and then checking the zero flag.
Using a Register Pair
Counter
The following is an example
as a Loop
• of a loop set
up with a register pair as the loop counter.
LXI B, 1000H
LOOP DCX B
MOV A, C
ORA B
JNZ LOOP
Delays
It was shown that each instruction passes
through different combinations of Fetch,
Memory Read, and Memory Write cycles.
•
• Knowing the combinations
calculate how long such an
require to complete.
The table in Appendix F of
of cycles, one can
instruction would
• the book contains a
column with the title B/M/T.
–
–
–
B for Number of Bytes
M for Number of Machine Cycles
T for Number of T-State.
Delays
Knowing how many T-States an instruction
requires, and keeping in mind that a T-State is one
clock cycle long, we can calculate the time using
the following formula:
•
Delay = No. of T-States / Frequency
• For example a “MVI” instruction uses 7 T-States.
Therefore, if the Microprocessor is running at 2
MHz, the instruction would require 3.5 µSeconds
to complete.
Delay loops
We can use a loop to produce a certain
amount of time delay in a program.
•
• The following is
loop:
MVI C, FFH
an example of a delay
7
4
10
T-States
T-States
T-States
LOOP DCR C
JNZ LOOP
• The first instruction initializes the loop counter and is
executed only once requiring only 7 T-States.
The following two instructions form a loop that
requires 14 T-States to execute and is repeated 255
times until C becomes 0.
•
Delay Loops (Contd.)
We need to keep in mind though that in the last
iteration of the loop, the JNZ instruction will fail and
require only 7 T-States rather than the 10.
Therefore, we must deduct 3 T-States from the total
delay to get an accurate delay calculation.
•
•
• To calculate the delay, we use the following formula:
Tdelay = TO + TL
–
–
–
Tdelay = total delay
TO = delay outside the loop
TL = delay of the loop
• TO is the sum of all delays outside the loop.
Delay Loops (Contd.)
Using these formulas, we can calculate
• the
time delay for the previous example:
• TO = 7 T-States
– Delay of the MVI instruction
• TL = (14 X 255) - 3 = 3567 T-States
– 14 T-States for the 2 instructions repeated 255 times
(FF16 = 25510) reduced by the 3 T-States for the final
JNZ.
Clock frequency of the system f = 2 MHz
Clock period T = 1/f = ½ X 10-6 = 0.5 µs
Total delay = Time to execute instruction outside loop + Time to execute loop
instructions
TO = 0.5 X 10-6 X 7
= 3.5 µs
TL = 0.5 X 10-6 X 14 X 255 – 0.5 X 10-6 X 3
= (1785 – 1.5 ) µs
= 1783.5 µs
TD = TO + TL
= 3.5 µs + 1783.5 µs
= 1787 µs
= 1.787 ms
= 1.8 ms (approx.)
Using a Register Pair as a
Counter
Loop
• Using a single register, one can
maximum count of 255 times.
repeat a loop for a
• It is possible to increase this count by using a
register pair for the loop counter instead of the
single register.
– A minor problem arises in how to test for the final
count since DCX and INX do not modify the flags.
– However, if the loop is looking for when the count
becomes zero, we can use a small trick by ORing the
two registers in the pair and then checking the zero flag.
Using a Register Pair as a Loop
Counter
• The following is an example of a delay loop
set up with a register pair as the
counter.
loop
LXI B, 1000H
LOOP DCX B
10
6
4
4
10
T-States
T-States
T-States
T-States
T-States
MOV A,
ORA B
C
JNZ LOOP
Using a Register Pair
Counter
Using the same formula from
calculate:
as a Loop
• before, we can
• TO = 10 T-States
– The delay for the LXI instruction
• TL =
–
(24 X 4096) - 3 = 98301 T- States
24 T-States for the 4 instructions in the loop repeated
4096 times (100016 = 409610) reduced by the 3 T-
States for the JNZ in the last iteration.
Nested
Nested loops can be
easily setup in
Assembly language by
using two registers for
the two loop counters
and updating the right
register in the right
loop.
– In the figure, the body of
loop2 can be before or
after loop1.
Loops
•
this
Final
unt?
Yes
this
Final
Count?
Yes
date the count 2
Update the count1
Body of loop 1
U
e loop 1
Body of loop 2
I
U
No
Up
No
Body
nitializ
Body
Is
Co
date t
Is
Initialize loop 2
Nested Loops for Delay
Instead (or in conjunction with) Register Pairs, a
•
nested loop structure can be used to increase the
total delay produced.
MVI B, 10H
MVI C, FFH
DCR C
JNZ LOOP1
DCR B
JNZ LOOP2
7
7
4
10
4
10
T-States
T-States
T-States
T-States
T-States
T-States
LOOP2
LOOP1
Delay Calculation of Nested
Loops
The calculation remains the same except
that it the formula must be applied
recursively to each loop.
•
– Start with the inner loop, then plug
the calculation of the outer loop.
that delay in
Delay of inner loop
– TO1 = 7 T-States
• MVI C, FFH instruction
– TL1 = (255 X 14) - 3 = 3567 T-States
• 14 T-States for the DCR C and JNZ instructions repeated 255
Delay Calculation
Loops
Delay of outer loop
of Nested
•
– TO2 = 7 T-States
• MVI B, 10H instruction
– TL1 = (16 X (14 + 3574)) - 3 = 57405 T-States
• 14 T-States for the DCR B and JNZ instructions and 3574
T-States for loop1 repeated 16 times (1016 = 1610) minus 3 for the
final JNZ.
– TDelay = 7 + 57405 = 57412 T-States
Total Delay
= 57412 X 0.5 µSec = 28.706 mSec
– TDelay
Increasing the delay
• The delay can be further increased by using
register pairs for each of the loop counters
in the nested loops setup.
It can also be increased by adding dummy
instructions (like NOP) in the body of the
loop.
•

More Related Content

What's hot

Sequential circuit design
Sequential circuit designSequential circuit design
Sequential circuit designSatya P. Joshi
 
MICROCONTROLLER 8051- Architecture & Pin Configuration
MICROCONTROLLER 8051- Architecture & Pin Configuration MICROCONTROLLER 8051- Architecture & Pin Configuration
MICROCONTROLLER 8051- Architecture & Pin Configuration AKHIL MADANKAR
 
INTERNAL STRUCTURE OF 8086 MICROPROCESSOR
INTERNAL STRUCTURE OF  8086 MICROPROCESSORINTERNAL STRUCTURE OF  8086 MICROPROCESSOR
INTERNAL STRUCTURE OF 8086 MICROPROCESSORMd. Hasnat Shoheb
 
Counters & time delay
Counters & time delayCounters & time delay
Counters & time delayHemant Chetwani
 
8085 microprocessor ramesh gaonkar
8085 microprocessor   ramesh gaonkar8085 microprocessor   ramesh gaonkar
8085 microprocessor ramesh gaonkarSAQUIB AHMAD
 
8085-microprocessor
8085-microprocessor8085-microprocessor
8085-microprocessorATTO RATHORE
 
Introduction to 8085 Microprocessor
Introduction to 8085 MicroprocessorIntroduction to 8085 Microprocessor
Introduction to 8085 MicroprocessorRavi Anand
 
Flip-Flop || Digital Electronics
Flip-Flop || Digital ElectronicsFlip-Flop || Digital Electronics
Flip-Flop || Digital ElectronicsMd Sadequl Islam
 
Computer registers
Computer registersComputer registers
Computer registersDeepikaT13
 
Signal descriptors of 8086
Signal descriptors of 8086Signal descriptors of 8086
Signal descriptors of 8086aviban
 
Registers
RegistersRegisters
RegistersGaditek
 
ARITHMETIC OPERATIONS IN 8085 MICROPROCESSOR
ARITHMETIC OPERATIONS IN 8085 MICROPROCESSORARITHMETIC OPERATIONS IN 8085 MICROPROCESSOR
ARITHMETIC OPERATIONS IN 8085 MICROPROCESSORRamaPrabha24
 
Addressing modes of 8086
Addressing modes of 8086Addressing modes of 8086
Addressing modes of 8086saurav kumar
 
MASTER SLAVE JK FLIP FLOP & T FLIP FLOP
MASTER SLAVE JK FLIP FLOP & T FLIP FLOPMASTER SLAVE JK FLIP FLOP & T FLIP FLOP
MASTER SLAVE JK FLIP FLOP & T FLIP FLOPSmit Shah
 
General register organization (computer organization)
General register organization  (computer organization)General register organization  (computer organization)
General register organization (computer organization)rishi ram khanal
 

What's hot (20)

Sequential circuit design
Sequential circuit designSequential circuit design
Sequential circuit design
 
MICROCONTROLLER 8051- Architecture & Pin Configuration
MICROCONTROLLER 8051- Architecture & Pin Configuration MICROCONTROLLER 8051- Architecture & Pin Configuration
MICROCONTROLLER 8051- Architecture & Pin Configuration
 
INTERNAL STRUCTURE OF 8086 MICROPROCESSOR
INTERNAL STRUCTURE OF  8086 MICROPROCESSORINTERNAL STRUCTURE OF  8086 MICROPROCESSOR
INTERNAL STRUCTURE OF 8086 MICROPROCESSOR
 
Counters & time delay
Counters & time delayCounters & time delay
Counters & time delay
 
8085 microprocessor ramesh gaonkar
8085 microprocessor   ramesh gaonkar8085 microprocessor   ramesh gaonkar
8085 microprocessor ramesh gaonkar
 
Pin diagram 8085
Pin diagram 8085 Pin diagram 8085
Pin diagram 8085
 
8085-microprocessor
8085-microprocessor8085-microprocessor
8085-microprocessor
 
Introduction to 8085 Microprocessor
Introduction to 8085 MicroprocessorIntroduction to 8085 Microprocessor
Introduction to 8085 Microprocessor
 
Lecture 3 instruction set
Lecture 3  instruction setLecture 3  instruction set
Lecture 3 instruction set
 
4 bit Binary to Gray converter using XOR
4 bit Binary to Gray converter using XOR4 bit Binary to Gray converter using XOR
4 bit Binary to Gray converter using XOR
 
Flip-Flop || Digital Electronics
Flip-Flop || Digital ElectronicsFlip-Flop || Digital Electronics
Flip-Flop || Digital Electronics
 
Computer registers
Computer registersComputer registers
Computer registers
 
Signal descriptors of 8086
Signal descriptors of 8086Signal descriptors of 8086
Signal descriptors of 8086
 
Registers
RegistersRegisters
Registers
 
Counters
CountersCounters
Counters
 
ARITHMETIC OPERATIONS IN 8085 MICROPROCESSOR
ARITHMETIC OPERATIONS IN 8085 MICROPROCESSORARITHMETIC OPERATIONS IN 8085 MICROPROCESSOR
ARITHMETIC OPERATIONS IN 8085 MICROPROCESSOR
 
Addressing modes of 8086
Addressing modes of 8086Addressing modes of 8086
Addressing modes of 8086
 
MASTER SLAVE JK FLIP FLOP & T FLIP FLOP
MASTER SLAVE JK FLIP FLOP & T FLIP FLOPMASTER SLAVE JK FLIP FLOP & T FLIP FLOP
MASTER SLAVE JK FLIP FLOP & T FLIP FLOP
 
General register organization (computer organization)
General register organization  (computer organization)General register organization  (computer organization)
General register organization (computer organization)
 
Arithmetic and logical instructions
Arithmetic and logical instructionsArithmetic and logical instructions
Arithmetic and logical instructions
 

Similar to Time delays & counter.ppt

8.1 Counters & Time Delays.pptx
8.1 Counters & Time Delays.pptx8.1 Counters & Time Delays.pptx
8.1 Counters & Time Delays.pptxDevashish397099
 
8085-Programming-II-mod-1.pptx
8085-Programming-II-mod-1.pptx8085-Programming-II-mod-1.pptx
8085-Programming-II-mod-1.pptxAsmita Bhagdikar
 
Microprocessor_Counter_and_Time_Delay.pptx
Microprocessor_Counter_and_Time_Delay.pptxMicroprocessor_Counter_and_Time_Delay.pptx
Microprocessor_Counter_and_Time_Delay.pptxamritsaravagi
 
Microcontrollers-MODULE4.pptx
Microcontrollers-MODULE4.pptxMicrocontrollers-MODULE4.pptx
Microcontrollers-MODULE4.pptxAmoghR3
 
Rtl design optimizations and tradeoffs
Rtl design optimizations and tradeoffsRtl design optimizations and tradeoffs
Rtl design optimizations and tradeoffsGrace Abraham
 
computer architecture 4
computer architecture 4 computer architecture 4
computer architecture 4 Dr.Umadevi V
 
timer counter (1).pptx
timer counter (1).pptxtimer counter (1).pptx
timer counter (1).pptxSujalKumar73
 
TM - Techniques
TM - TechniquesTM - Techniques
TM - TechniquesRajendran
 
Timer programming
Timer programming Timer programming
Timer programming vijaydeepakg
 
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 2
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 2SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 2
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 2KanchanPatil34
 

Similar to Time delays & counter.ppt (20)

8.1 Counters & Time Delays.pptx
8.1 Counters & Time Delays.pptx8.1 Counters & Time Delays.pptx
8.1 Counters & Time Delays.pptx
 
Chapter 8
Chapter 8Chapter 8
Chapter 8
 
8085-Programming-II-mod-1.pptx
8085-Programming-II-mod-1.pptx8085-Programming-II-mod-1.pptx
8085-Programming-II-mod-1.pptx
 
Delay routine
Delay routineDelay routine
Delay routine
 
Chapter 08
Chapter 08Chapter 08
Chapter 08
 
Microprocessor_Counter_and_Time_Delay.pptx
Microprocessor_Counter_and_Time_Delay.pptxMicroprocessor_Counter_and_Time_Delay.pptx
Microprocessor_Counter_and_Time_Delay.pptx
 
6.pptx
6.pptx6.pptx
6.pptx
 
Microcontrollers-MODULE4.pptx
Microcontrollers-MODULE4.pptxMicrocontrollers-MODULE4.pptx
Microcontrollers-MODULE4.pptx
 
Rtl design optimizations and tradeoffs
Rtl design optimizations and tradeoffsRtl design optimizations and tradeoffs
Rtl design optimizations and tradeoffs
 
4.Timer_1.ppt
4.Timer_1.ppt4.Timer_1.ppt
4.Timer_1.ppt
 
8051 timers--2
   8051 timers--2   8051 timers--2
8051 timers--2
 
computer architecture 4
computer architecture 4 computer architecture 4
computer architecture 4
 
timer counter (1).pptx
timer counter (1).pptxtimer counter (1).pptx
timer counter (1).pptx
 
TM - Techniques
TM - TechniquesTM - Techniques
TM - Techniques
 
8051 ch9
8051 ch98051 ch9
8051 ch9
 
8051e
8051e8051e
8051e
 
Timer programming
Timer programming Timer programming
Timer programming
 
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 2
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 2SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 2
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 2
 
Lab5 s1
Lab5 s1Lab5 s1
Lab5 s1
 
8051 Timers
8051 Timers8051 Timers
8051 Timers
 

More from ISMT College

Timing Diagram.pptx
Timing Diagram.pptxTiming Diagram.pptx
Timing Diagram.pptxISMT College
 
4. Instruction Set Of MP 8085.pptx
4. Instruction Set Of MP 8085.pptx4. Instruction Set Of MP 8085.pptx
4. Instruction Set Of MP 8085.pptxISMT College
 
3. Addressing Modes in 8085 microprocessor.pptx
3. Addressing Modes in 8085 microprocessor.pptx3. Addressing Modes in 8085 microprocessor.pptx
3. Addressing Modes in 8085 microprocessor.pptxISMT College
 
2. 8085-Microprocessor.pptx
2. 8085-Microprocessor.pptx2. 8085-Microprocessor.pptx
2. 8085-Microprocessor.pptxISMT College
 
1. Introduction to Microprocessor.pptx
1. Introduction to Microprocessor.pptx1. Introduction to Microprocessor.pptx
1. Introduction to Microprocessor.pptxISMT College
 
Digital Logic BCA TU Chapter 2.2
Digital Logic BCA TU Chapter 2.2Digital Logic BCA TU Chapter 2.2
Digital Logic BCA TU Chapter 2.2ISMT College
 
Chapter 1 Introduction to Digital Logic
Chapter 1 Introduction to Digital LogicChapter 1 Introduction to Digital Logic
Chapter 1 Introduction to Digital LogicISMT College
 
Access Control List (ACL)
Access Control List (ACL)Access Control List (ACL)
Access Control List (ACL)ISMT College
 
Introduction to Counters
Introduction to CountersIntroduction to Counters
Introduction to CountersISMT College
 
Chapter 2.1 introduction to number system
Chapter 2.1 introduction to number systemChapter 2.1 introduction to number system
Chapter 2.1 introduction to number systemISMT College
 
Chapter 1 Introduction to Digital Logic
Chapter 1 Introduction to Digital LogicChapter 1 Introduction to Digital Logic
Chapter 1 Introduction to Digital LogicISMT College
 
Programmable logic devices
Programmable logic devicesProgrammable logic devices
Programmable logic devicesISMT College
 
Basic Gates in Digital Logic
Basic Gates in Digital LogicBasic Gates in Digital Logic
Basic Gates in Digital LogicISMT College
 
Adder & subtractor (Half adder, Full adder, Half subtractor, Full subtractor)
Adder & subtractor (Half adder, Full adder, Half subtractor, Full subtractor)Adder & subtractor (Half adder, Full adder, Half subtractor, Full subtractor)
Adder & subtractor (Half adder, Full adder, Half subtractor, Full subtractor)ISMT College
 
Register in Digital Logic
Register in Digital LogicRegister in Digital Logic
Register in Digital LogicISMT College
 

More from ISMT College (18)

Attack.pptx
Attack.pptxAttack.pptx
Attack.pptx
 
Timing Diagram.pptx
Timing Diagram.pptxTiming Diagram.pptx
Timing Diagram.pptx
 
4. Instruction Set Of MP 8085.pptx
4. Instruction Set Of MP 8085.pptx4. Instruction Set Of MP 8085.pptx
4. Instruction Set Of MP 8085.pptx
 
Instruction.pdf
Instruction.pdfInstruction.pdf
Instruction.pdf
 
3. Addressing Modes in 8085 microprocessor.pptx
3. Addressing Modes in 8085 microprocessor.pptx3. Addressing Modes in 8085 microprocessor.pptx
3. Addressing Modes in 8085 microprocessor.pptx
 
2. 8085-Microprocessor.pptx
2. 8085-Microprocessor.pptx2. 8085-Microprocessor.pptx
2. 8085-Microprocessor.pptx
 
1. Introduction to Microprocessor.pptx
1. Introduction to Microprocessor.pptx1. Introduction to Microprocessor.pptx
1. Introduction to Microprocessor.pptx
 
Digital Logic BCA TU Chapter 2.2
Digital Logic BCA TU Chapter 2.2Digital Logic BCA TU Chapter 2.2
Digital Logic BCA TU Chapter 2.2
 
Chapter 1 Introduction to Digital Logic
Chapter 1 Introduction to Digital LogicChapter 1 Introduction to Digital Logic
Chapter 1 Introduction to Digital Logic
 
VLAN
VLANVLAN
VLAN
 
Access Control List (ACL)
Access Control List (ACL)Access Control List (ACL)
Access Control List (ACL)
 
Introduction to Counters
Introduction to CountersIntroduction to Counters
Introduction to Counters
 
Chapter 2.1 introduction to number system
Chapter 2.1 introduction to number systemChapter 2.1 introduction to number system
Chapter 2.1 introduction to number system
 
Chapter 1 Introduction to Digital Logic
Chapter 1 Introduction to Digital LogicChapter 1 Introduction to Digital Logic
Chapter 1 Introduction to Digital Logic
 
Programmable logic devices
Programmable logic devicesProgrammable logic devices
Programmable logic devices
 
Basic Gates in Digital Logic
Basic Gates in Digital LogicBasic Gates in Digital Logic
Basic Gates in Digital Logic
 
Adder & subtractor (Half adder, Full adder, Half subtractor, Full subtractor)
Adder & subtractor (Half adder, Full adder, Half subtractor, Full subtractor)Adder & subtractor (Half adder, Full adder, Half subtractor, Full subtractor)
Adder & subtractor (Half adder, Full adder, Half subtractor, Full subtractor)
 
Register in Digital Logic
Register in Digital LogicRegister in Digital Logic
Register in Digital Logic
 

Recently uploaded

(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 

Recently uploaded (20)

(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 

Time delays & counter.ppt

  • 2. Need of Counter and Time Delays •Counters are used primarily to keep track of events. •Time delays are important in setting up reasonably accurate timing between two events. •The process of designing counters and time delays using software instructions is far more flexible and less time consuming than the design process using hardware.
  • 3. Counters • A loop counter is set up by loading a register with a certain value Then using the DCR (to decrement) the contents of the register are updated. A loop is set up with a conditional jump instruction that loops back or not depending on whether the count has reached the termination count. • •
  • 4. Counters The operation of a loop counter can be • described using the following flowchart. this Final Count? Yes the count of loop U No Body pdate Is Initialize
  • 5. SampleALP for implementing Using DCR instruction a loop MVI C, 15H DCR C LOOP LOOP JNZ
  • 6. Using a Register Pair as a Counter Loop • Using a single register, one can maximum count of 255 times. repeat a loop for a • It is possible to increase this count by using a register pair for the loop counter instead of the single register. – A minor problem arises in how to test for the final count since DCX and INX do not modify the flags. – However, if the loop is looking for when the count becomes zero, we can use a small trick by ORing the two registers in the pair and then checking the zero flag.
  • 7. Using a Register Pair Counter The following is an example as a Loop • of a loop set up with a register pair as the loop counter. LXI B, 1000H LOOP DCX B MOV A, C ORA B JNZ LOOP
  • 8. Delays It was shown that each instruction passes through different combinations of Fetch, Memory Read, and Memory Write cycles. • • Knowing the combinations calculate how long such an require to complete. The table in Appendix F of of cycles, one can instruction would • the book contains a column with the title B/M/T. – – – B for Number of Bytes M for Number of Machine Cycles T for Number of T-State.
  • 9. Delays Knowing how many T-States an instruction requires, and keeping in mind that a T-State is one clock cycle long, we can calculate the time using the following formula: • Delay = No. of T-States / Frequency • For example a “MVI” instruction uses 7 T-States. Therefore, if the Microprocessor is running at 2 MHz, the instruction would require 3.5 µSeconds to complete.
  • 10. Delay loops We can use a loop to produce a certain amount of time delay in a program. • • The following is loop: MVI C, FFH an example of a delay 7 4 10 T-States T-States T-States LOOP DCR C JNZ LOOP • The first instruction initializes the loop counter and is executed only once requiring only 7 T-States. The following two instructions form a loop that requires 14 T-States to execute and is repeated 255 times until C becomes 0. •
  • 11. Delay Loops (Contd.) We need to keep in mind though that in the last iteration of the loop, the JNZ instruction will fail and require only 7 T-States rather than the 10. Therefore, we must deduct 3 T-States from the total delay to get an accurate delay calculation. • • • To calculate the delay, we use the following formula: Tdelay = TO + TL – – – Tdelay = total delay TO = delay outside the loop TL = delay of the loop • TO is the sum of all delays outside the loop.
  • 12. Delay Loops (Contd.) Using these formulas, we can calculate • the time delay for the previous example: • TO = 7 T-States – Delay of the MVI instruction • TL = (14 X 255) - 3 = 3567 T-States – 14 T-States for the 2 instructions repeated 255 times (FF16 = 25510) reduced by the 3 T-States for the final JNZ.
  • 13. Clock frequency of the system f = 2 MHz Clock period T = 1/f = ½ X 10-6 = 0.5 µs Total delay = Time to execute instruction outside loop + Time to execute loop instructions TO = 0.5 X 10-6 X 7 = 3.5 µs TL = 0.5 X 10-6 X 14 X 255 – 0.5 X 10-6 X 3 = (1785 – 1.5 ) µs = 1783.5 µs TD = TO + TL = 3.5 µs + 1783.5 µs = 1787 µs = 1.787 ms = 1.8 ms (approx.)
  • 14. Using a Register Pair as a Counter Loop • Using a single register, one can maximum count of 255 times. repeat a loop for a • It is possible to increase this count by using a register pair for the loop counter instead of the single register. – A minor problem arises in how to test for the final count since DCX and INX do not modify the flags. – However, if the loop is looking for when the count becomes zero, we can use a small trick by ORing the two registers in the pair and then checking the zero flag.
  • 15. Using a Register Pair as a Loop Counter • The following is an example of a delay loop set up with a register pair as the counter. loop LXI B, 1000H LOOP DCX B 10 6 4 4 10 T-States T-States T-States T-States T-States MOV A, ORA B C JNZ LOOP
  • 16. Using a Register Pair Counter Using the same formula from calculate: as a Loop • before, we can • TO = 10 T-States – The delay for the LXI instruction • TL = – (24 X 4096) - 3 = 98301 T- States 24 T-States for the 4 instructions in the loop repeated 4096 times (100016 = 409610) reduced by the 3 T- States for the JNZ in the last iteration.
  • 17. Nested Nested loops can be easily setup in Assembly language by using two registers for the two loop counters and updating the right register in the right loop. – In the figure, the body of loop2 can be before or after loop1. Loops • this Final unt? Yes this Final Count? Yes date the count 2 Update the count1 Body of loop 1 U e loop 1 Body of loop 2 I U No Up No Body nitializ Body Is Co date t Is Initialize loop 2
  • 18. Nested Loops for Delay Instead (or in conjunction with) Register Pairs, a • nested loop structure can be used to increase the total delay produced. MVI B, 10H MVI C, FFH DCR C JNZ LOOP1 DCR B JNZ LOOP2 7 7 4 10 4 10 T-States T-States T-States T-States T-States T-States LOOP2 LOOP1
  • 19. Delay Calculation of Nested Loops The calculation remains the same except that it the formula must be applied recursively to each loop. • – Start with the inner loop, then plug the calculation of the outer loop. that delay in Delay of inner loop – TO1 = 7 T-States • MVI C, FFH instruction – TL1 = (255 X 14) - 3 = 3567 T-States • 14 T-States for the DCR C and JNZ instructions repeated 255
  • 20. Delay Calculation Loops Delay of outer loop of Nested • – TO2 = 7 T-States • MVI B, 10H instruction – TL1 = (16 X (14 + 3574)) - 3 = 57405 T-States • 14 T-States for the DCR B and JNZ instructions and 3574 T-States for loop1 repeated 16 times (1016 = 1610) minus 3 for the final JNZ. – TDelay = 7 + 57405 = 57412 T-States Total Delay = 57412 X 0.5 µSec = 28.706 mSec – TDelay
  • 21. Increasing the delay • The delay can be further increased by using register pairs for each of the loop counters in the nested loops setup. It can also be increased by adding dummy instructions (like NOP) in the body of the loop. •