SlideShare a Scribd company logo
1 of 24
Developing Counter And T
Microprocessor And I
Counters
• Using counters programmer can specify that
how many times an instruction (or set of
instructions) is to be executed.
• A loop counter is set up by loading a register
with a certain value.
Counters (cont.)
• Then using the DCR (to decrement) and INR (to
increment) 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.
• The operation of a loop counter can be
described using the following flowchart.
Indexing
• Indexing means pointing or referencing objects
with sequential numbers. In a library, books are
arranged according to numbers, and they are
referred or sorted by numbers. This is called
indexing.
• Similarly, data bytes are stored in memory
locations and those data bytes are referred to by
their memory locations.
Indexing (cont.)
• E.g., a list of numbers is stored in sequential
memory locations. To access this list we need the
address of first element and total number of
elements in the list. We can use a register pair as
an index by loading this address into the pair and
then incrementing it to access elements of the
list.
Delays
• Each instruction passes through different
combinations of Fetch, Memory Read, and
Memory Write cycles.
• Knowing the combinations of cycles, we can
calculate how long such an instruction would
require to complete.
• 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:
• Delays=No. of T-States/Frequency.
• For example “MVI” instruction uses 7 T-States
and if the microprocessor is running at 2MHz ,the
instruction would require 3.5 µs to complete.
Time Delay Routine
How To Provide Time Delay ?
• In microprocessors we have studied different
instructions like NOP,DCR,DCX. By using this
one can use those instructions ,execute it
number of times and get a “delay”.
• The delay we achieved is due to software
instructions ,Therefore the same is referred as
“software Delay”.
Timing delay using counters
• Counting can also create timing delays.
• The execution time of a program or the
instruction are known to the user.
• By means of this data a user can determine
the account of time delay.
• The time required for the execution of this
program can be calculated with the “T-states”
• Time delay using 8 BIT COUNTER IS AS
FOLLOWS
Delay of Instructions
• Performance/delay of each instruction
MVI C, FFH 7 T-State
LOOP: DCR C 4 T-State
JNZ LOOP 7/10 T-State
• Performance of other INS
ADD R 4 T-
State
ADD M 7 T-
State
CALL addr 18 T-
State
F R
F
F R R
F
F R
S R R W W
Calculation of 8 bit counter
• Total t-states required to execute a given
program are =
• 7 + (count-1)*(10+4)+ (4+7)
MVI C Iterations/Loops last iteration
For count =2
• Number of T-states =7+(2-1)*(10+4)+ (4+7)=32
• Assuming operating frequency of 8085a is 5MHz
• Time required for 1 T-states=1/(5 MHz)=0.2microseconds
• Time required for executing the program =
32* 0.2microseconds=6.4 microseconds
Continue…
• The maximum count that can be loaded in 8
bit register is 255(FFH)
• Hence maximum delay delay possible with 8
bit counter is=
(7+(255-1)*(14)+11)* 0.2microseconds
=714.8 microseconds
Time Delay using 16 bit counter
• Label Instructions T-states
LXI D,COUNT 10T
L1: DCX D 6T
MOV A,D 4T
ORA E 4T
JNZ LJ 10/7 T
• No. of t-states requierd for an iteration
=T-states (DCX D)+T-states(MOV A,D)+T-states(ORA )+T-states (JNZ )
=6+4+4+10=24 T-states
• For last iteration it requires
= T-states (DCX D)+T-states(MOV A,D)+T-states(ORA )+T-states (JNZ )
=6+4+4+7
=21T-states
Calculation of 16 bit counter
• Total t-states required to program are=
=10 +(count-1)*24 +21
LXI D Iterations Last iterations
• For count =0FFH(4095)
• Number of T-states =10+(4094)*24+21=98287
• Assuming operating Frequency=5MHZ
• Time required for 1 T-state=1/(5MHZ)=0.2microseconds
• Time required to execute the program
=98287*0.2microseconds=19.6574milliseconds
• Maximum delay can be achived using FFFFH (65535)
=(10+(65525-1)*24+(21))*0.2microseconds
=0.314569microseconds
Time Delay: Nested Loop
• Performance/delay of each instruction
MVI C, FFH 7 T-State
MVI D, FFH 7 T-State
LOOP1: DCR C 4 T-State
LOOP2: DCR D 4 T-State
JNZ LOOP2 7/10 T-State
JNZ LOOP1 7/10 T-State
• Time delay in Nested loop
TNL= N110 x T x ( L1_TStates+ L2_TStates x N210 )
F R
F
F R R
F R
F R R
F
Time delay using nested loops
• In this method there are more than one loops.The
outer loop sets the multiplying count to the delays
provided by the innermost loop,while the innermost
loop is same as above.
• T-states required for innermost loop=7+(delay count-
1)*14+11
• T-states required for execution of
program=(multiplie count-1)*(T*14)+11
Continue…
• For delay count =0AH(10) and multiplier count
=5 H
T(inner)=7+(10-1)*14+11
=144
Time required for executing the program
assuming operating frequency 5 MHz
=[(5-1)*(144+14)+11]*0.2microseconds
=0.1286milliseconds.
Write a subroutine for 8085 to generate delay of
100(assume 320ns clock cycle)
• The time delay required is and clock cycle is of
320ns.
• So required T-states
=100microseconds/320nanoseconds)
• As very Less T-states are require we can use
delay using 8 bit counter.
Continue..
• Label Instructions T-states
MVI C,COUNT 7T
UP: DCR C 4T
JNZ UP 10/7T
RET 10T
• T(d)=7+(count*(4+10))+10-3=312.5
14 count =312.5-14=297.5
Count =21.32=(15)octadecimal
• So to get a delay of 100microseeconds use 15 as count
value in program
Traffic Light Control: Counter & Delay
LOOP: MVI A 01H
OUT 01H
LD B DELAY_RED
CALL DELAY
Load DelayRedLoad DelayRed
Time DelayTime Delay
Turn Signal to RedTurn Signal to Red
Load DelayYellowLoad DelayYellow
Time DelayTime Delay
Turn Signal to YellowTurn Signal to Yellow
Load DelayGreenLoad DelayGreen
Time DelayTime Delay
Turn Signal to GreenTurn Signal to Green
MVI A 02H
OUT 01H
LD B DELAY_YELLOW
CALL DELAY
MVI A 03H
OUT 01H
LD B DELAY_GREEN
CALL DELAY
JMP LOOP
Thanks

More Related Content

What's hot

Automated Traffic Light control using 8051 microcontroller
Automated Traffic Light control using 8051 microcontrollerAutomated Traffic Light control using 8051 microcontroller
Automated Traffic Light control using 8051 microcontrollerVijayMaheshwari12
 
Direct memory access (dma) with 8257 DMA Controller
Direct memory access (dma) with 8257 DMA ControllerDirect memory access (dma) with 8257 DMA Controller
Direct memory access (dma) with 8257 DMA ControllerMuhammed Afsal Villan
 
Contamination delay
Contamination delayContamination delay
Contamination delayNima Afraz
 
Counters & time delay
Counters & time delayCounters & time delay
Counters & time delayHemant Chetwani
 
Traffic Light Controller using 8255
Traffic Light Controller using 8255Traffic Light Controller using 8255
Traffic Light Controller using 8255Amit Kumer Podder
 
Subroutine in 8051 microcontroller
Subroutine in 8051 microcontrollerSubroutine in 8051 microcontroller
Subroutine in 8051 microcontrollerbhadresh savani
 
Choppers and cycloconverters
Choppers and cycloconvertersChoppers and cycloconverters
Choppers and cycloconvertersSHIMI S L
 
Interfacing with peripherals: analog to digital converters and digital to ana...
Interfacing with peripherals: analog to digital converters and digital to ana...Interfacing with peripherals: analog to digital converters and digital to ana...
Interfacing with peripherals: analog to digital converters and digital to ana...NimeshSingh27
 
8051 instruction set
8051 instruction set8051 instruction set
8051 instruction setprakash y
 
Verilog coding of demux 8 x1
Verilog coding of demux  8 x1Verilog coding of demux  8 x1
Verilog coding of demux 8 x1Rakesh kumar jha
 
Braking methods of induction motor
Braking methods of induction motorBraking methods of induction motor
Braking methods of induction motorraviarmugam
 
Pseudo Random Bit Sequence Generator
Pseudo Random Bit Sequence Generator Pseudo Random Bit Sequence Generator
Pseudo Random Bit Sequence Generator ajay singh
 
Programmable Peripheral Interface 8255
 Programmable Peripheral Interface   8255 Programmable Peripheral Interface   8255
Programmable Peripheral Interface 8255Dr.P.Parandaman
 

What's hot (20)

Automated Traffic Light control using 8051 microcontroller
Automated Traffic Light control using 8051 microcontrollerAutomated Traffic Light control using 8051 microcontroller
Automated Traffic Light control using 8051 microcontroller
 
Direct memory access (dma) with 8257 DMA Controller
Direct memory access (dma) with 8257 DMA ControllerDirect memory access (dma) with 8257 DMA Controller
Direct memory access (dma) with 8257 DMA Controller
 
Contamination delay
Contamination delayContamination delay
Contamination delay
 
Interrupts in 8051
Interrupts in 8051Interrupts in 8051
Interrupts in 8051
 
Instruction Set of 8051 Microcontroller
Instruction Set of 8051 MicrocontrollerInstruction Set of 8051 Microcontroller
Instruction Set of 8051 Microcontroller
 
Counters & time delay
Counters & time delayCounters & time delay
Counters & time delay
 
Traffic Light Controller using 8255
Traffic Light Controller using 8255Traffic Light Controller using 8255
Traffic Light Controller using 8255
 
Subroutine in 8051 microcontroller
Subroutine in 8051 microcontrollerSubroutine in 8051 microcontroller
Subroutine in 8051 microcontroller
 
Choppers and cycloconverters
Choppers and cycloconvertersChoppers and cycloconverters
Choppers and cycloconverters
 
Interfacing with peripherals: analog to digital converters and digital to ana...
Interfacing with peripherals: analog to digital converters and digital to ana...Interfacing with peripherals: analog to digital converters and digital to ana...
Interfacing with peripherals: analog to digital converters and digital to ana...
 
Unit4.addressing modes 54 xx
Unit4.addressing modes 54 xxUnit4.addressing modes 54 xx
Unit4.addressing modes 54 xx
 
8051 instruction set
8051 instruction set8051 instruction set
8051 instruction set
 
Instruction formats-in-8086
Instruction formats-in-8086Instruction formats-in-8086
Instruction formats-in-8086
 
8051 instruction set
8051 instruction set8051 instruction set
8051 instruction set
 
Verilog coding of demux 8 x1
Verilog coding of demux  8 x1Verilog coding of demux  8 x1
Verilog coding of demux 8 x1
 
Braking methods of induction motor
Braking methods of induction motorBraking methods of induction motor
Braking methods of induction motor
 
8255
82558255
8255
 
8251 USART
8251 USART8251 USART
8251 USART
 
Pseudo Random Bit Sequence Generator
Pseudo Random Bit Sequence Generator Pseudo Random Bit Sequence Generator
Pseudo Random Bit Sequence Generator
 
Programmable Peripheral Interface 8255
 Programmable Peripheral Interface   8255 Programmable Peripheral Interface   8255
Programmable Peripheral Interface 8255
 

Similar to Developing Counter And Time Delay Routines For Microprocessors

Time delays & counter.ppt
Time delays & counter.pptTime delays & counter.ppt
Time delays & counter.pptISMT College
 
computer architecture 4
computer architecture 4 computer architecture 4
computer architecture 4 Dr.Umadevi V
 
ppt-U3 - (Programming, Memory Interfacing).pptx
ppt-U3 - (Programming, Memory Interfacing).pptxppt-U3 - (Programming, Memory Interfacing).pptx
ppt-U3 - (Programming, Memory Interfacing).pptxRaviKiranVarma4
 
Timing Diagram.pptx
Timing Diagram.pptxTiming Diagram.pptx
Timing Diagram.pptxISMT College
 
8085-Programming-II-mod-1.pptx
8085-Programming-II-mod-1.pptx8085-Programming-II-mod-1.pptx
8085-Programming-II-mod-1.pptxAsmita Bhagdikar
 
Control unit design
Control unit designControl unit design
Control unit designDhaval Bagal
 
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
 
Pipeline and Vector Processing Computer Org. Architecture.pptx
Pipeline and Vector Processing Computer Org. Architecture.pptxPipeline and Vector Processing Computer Org. Architecture.pptx
Pipeline and Vector Processing Computer Org. Architecture.pptxitofficial07
 
Cpu performance matrix
Cpu performance matrixCpu performance matrix
Cpu performance matrixRehman baig
 
Unit-1_Digital Computers, number systemCOA[1].pptx
Unit-1_Digital Computers, number systemCOA[1].pptxUnit-1_Digital Computers, number systemCOA[1].pptx
Unit-1_Digital Computers, number systemCOA[1].pptxVanshJain322212
 
Micro operation control of processor
Micro operation control of processorMicro operation control of processor
Micro operation control of processorMuhammad Ishaq
 

Similar to Developing Counter And Time Delay Routines For Microprocessors (20)

Time delays & counter.ppt
Time delays & counter.pptTime delays & counter.ppt
Time delays & counter.ppt
 
Chapter 8
Chapter 8Chapter 8
Chapter 8
 
computer architecture 4
computer architecture 4 computer architecture 4
computer architecture 4
 
Chapter 08
Chapter 08Chapter 08
Chapter 08
 
Timing & Control.pptx
Timing & Control.pptxTiming & Control.pptx
Timing & Control.pptx
 
ppt-U3 - (Programming, Memory Interfacing).pptx
ppt-U3 - (Programming, Memory Interfacing).pptxppt-U3 - (Programming, Memory Interfacing).pptx
ppt-U3 - (Programming, Memory Interfacing).pptx
 
Unit - 5 Pipelining.pptx
Unit - 5 Pipelining.pptxUnit - 5 Pipelining.pptx
Unit - 5 Pipelining.pptx
 
Timing Diagram.pptx
Timing Diagram.pptxTiming Diagram.pptx
Timing Diagram.pptx
 
8085-Programming-II-mod-1.pptx
8085-Programming-II-mod-1.pptx8085-Programming-II-mod-1.pptx
8085-Programming-II-mod-1.pptx
 
Control unit design
Control unit designControl unit design
Control unit design
 
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
 
Pipeline and Vector Processing Computer Org. Architecture.pptx
Pipeline and Vector Processing Computer Org. Architecture.pptxPipeline and Vector Processing Computer Org. Architecture.pptx
Pipeline and Vector Processing Computer Org. Architecture.pptx
 
Unit 4 COA.pptx
Unit 4 COA.pptxUnit 4 COA.pptx
Unit 4 COA.pptx
 
Cpu performance matrix
Cpu performance matrixCpu performance matrix
Cpu performance matrix
 
AVRTIMER.pptx
AVRTIMER.pptxAVRTIMER.pptx
AVRTIMER.pptx
 
Unit-1_Digital Computers, number systemCOA[1].pptx
Unit-1_Digital Computers, number systemCOA[1].pptxUnit-1_Digital Computers, number systemCOA[1].pptx
Unit-1_Digital Computers, number systemCOA[1].pptx
 
02 performance
02 performance02 performance
02 performance
 
Pipelining slides
Pipelining slides Pipelining slides
Pipelining slides
 
Coa.ppt2
Coa.ppt2Coa.ppt2
Coa.ppt2
 
Micro operation control of processor
Micro operation control of processorMicro operation control of processor
Micro operation control of processor
 

Recently uploaded

UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 
An introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptxAn introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptxPurva Nikam
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .Satyam Kumar
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncssuser2ae721
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...Chandu841456
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleAlluxio, Inc.
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 

Recently uploaded (20)

UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
An introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptxAn introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptx
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at Scale
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 

Developing Counter And Time Delay Routines For Microprocessors

  • 1. Developing Counter And T Microprocessor And I
  • 2. Counters • Using counters programmer can specify that how many times an instruction (or set of instructions) is to be executed. • A loop counter is set up by loading a register with a certain value.
  • 3. Counters (cont.) • Then using the DCR (to decrement) and INR (to increment) 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. • The operation of a loop counter can be described using the following flowchart.
  • 5. Indexing • Indexing means pointing or referencing objects with sequential numbers. In a library, books are arranged according to numbers, and they are referred or sorted by numbers. This is called indexing. • Similarly, data bytes are stored in memory locations and those data bytes are referred to by their memory locations.
  • 6. Indexing (cont.) • E.g., a list of numbers is stored in sequential memory locations. To access this list we need the address of first element and total number of elements in the list. We can use a register pair as an index by loading this address into the pair and then incrementing it to access elements of the list.
  • 7. Delays • Each instruction passes through different combinations of Fetch, Memory Read, and Memory Write cycles. • Knowing the combinations of cycles, we can calculate how long such an instruction would require to complete.
  • 8. • 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: • Delays=No. of T-States/Frequency. • For example “MVI” instruction uses 7 T-States and if the microprocessor is running at 2MHz ,the instruction would require 3.5 µs to complete.
  • 9.
  • 11. How To Provide Time Delay ? • In microprocessors we have studied different instructions like NOP,DCR,DCX. By using this one can use those instructions ,execute it number of times and get a “delay”. • The delay we achieved is due to software instructions ,Therefore the same is referred as “software Delay”.
  • 12. Timing delay using counters • Counting can also create timing delays. • The execution time of a program or the instruction are known to the user. • By means of this data a user can determine the account of time delay. • The time required for the execution of this program can be calculated with the “T-states” • Time delay using 8 BIT COUNTER IS AS FOLLOWS
  • 13. Delay of Instructions • Performance/delay of each instruction MVI C, FFH 7 T-State LOOP: DCR C 4 T-State JNZ LOOP 7/10 T-State • Performance of other INS ADD R 4 T- State ADD M 7 T- State CALL addr 18 T- State F R F F R R F F R S R R W W
  • 14. Calculation of 8 bit counter • Total t-states required to execute a given program are = • 7 + (count-1)*(10+4)+ (4+7) MVI C Iterations/Loops last iteration For count =2 • Number of T-states =7+(2-1)*(10+4)+ (4+7)=32 • Assuming operating frequency of 8085a is 5MHz • Time required for 1 T-states=1/(5 MHz)=0.2microseconds • Time required for executing the program = 32* 0.2microseconds=6.4 microseconds
  • 15. Continue… • The maximum count that can be loaded in 8 bit register is 255(FFH) • Hence maximum delay delay possible with 8 bit counter is= (7+(255-1)*(14)+11)* 0.2microseconds =714.8 microseconds
  • 16. Time Delay using 16 bit counter • Label Instructions T-states LXI D,COUNT 10T L1: DCX D 6T MOV A,D 4T ORA E 4T JNZ LJ 10/7 T • No. of t-states requierd for an iteration =T-states (DCX D)+T-states(MOV A,D)+T-states(ORA )+T-states (JNZ ) =6+4+4+10=24 T-states • For last iteration it requires = T-states (DCX D)+T-states(MOV A,D)+T-states(ORA )+T-states (JNZ ) =6+4+4+7 =21T-states
  • 17. Calculation of 16 bit counter • Total t-states required to program are= =10 +(count-1)*24 +21 LXI D Iterations Last iterations • For count =0FFH(4095) • Number of T-states =10+(4094)*24+21=98287 • Assuming operating Frequency=5MHZ • Time required for 1 T-state=1/(5MHZ)=0.2microseconds • Time required to execute the program =98287*0.2microseconds=19.6574milliseconds • Maximum delay can be achived using FFFFH (65535) =(10+(65525-1)*24+(21))*0.2microseconds =0.314569microseconds
  • 18. Time Delay: Nested Loop • Performance/delay of each instruction MVI C, FFH 7 T-State MVI D, FFH 7 T-State LOOP1: DCR C 4 T-State LOOP2: DCR D 4 T-State JNZ LOOP2 7/10 T-State JNZ LOOP1 7/10 T-State • Time delay in Nested loop TNL= N110 x T x ( L1_TStates+ L2_TStates x N210 ) F R F F R R F R F R R F
  • 19. Time delay using nested loops • In this method there are more than one loops.The outer loop sets the multiplying count to the delays provided by the innermost loop,while the innermost loop is same as above. • T-states required for innermost loop=7+(delay count- 1)*14+11 • T-states required for execution of program=(multiplie count-1)*(T*14)+11
  • 20. Continue… • For delay count =0AH(10) and multiplier count =5 H T(inner)=7+(10-1)*14+11 =144 Time required for executing the program assuming operating frequency 5 MHz =[(5-1)*(144+14)+11]*0.2microseconds =0.1286milliseconds.
  • 21. Write a subroutine for 8085 to generate delay of 100(assume 320ns clock cycle) • The time delay required is and clock cycle is of 320ns. • So required T-states =100microseconds/320nanoseconds) • As very Less T-states are require we can use delay using 8 bit counter.
  • 22. Continue.. • Label Instructions T-states MVI C,COUNT 7T UP: DCR C 4T JNZ UP 10/7T RET 10T • T(d)=7+(count*(4+10))+10-3=312.5 14 count =312.5-14=297.5 Count =21.32=(15)octadecimal • So to get a delay of 100microseeconds use 15 as count value in program
  • 23. Traffic Light Control: Counter & Delay LOOP: MVI A 01H OUT 01H LD B DELAY_RED CALL DELAY Load DelayRedLoad DelayRed Time DelayTime Delay Turn Signal to RedTurn Signal to Red Load DelayYellowLoad DelayYellow Time DelayTime Delay Turn Signal to YellowTurn Signal to Yellow Load DelayGreenLoad DelayGreen Time DelayTime Delay Turn Signal to GreenTurn Signal to Green MVI A 02H OUT 01H LD B DELAY_YELLOW CALL DELAY MVI A 03H OUT 01H LD B DELAY_GREEN CALL DELAY JMP LOOP