SlideShare a Scribd company logo
1 of 7
Chapter-8
Counter and Time Delays
8.1 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.
COUNTER
A counter is designed simply by loading an appropriate number into one of the
registers and using INR (for up-counter) or DCR (for down-counter)
instructions. A loop is established to update the count.
TIME DELAY
The procedure used to design a specific delay is similar to that used to set up a counter.
A register is loaded with a number, depending on the time delay required, and then the
register is decremented until it reaches zero.
8.11 Time Delay Using One Register
Label Opcode Operand T-states
MVI C,FFH
7
LOOP: DCR C 4
JNZ LOOP 10/7=3
An 8085–based microcomputer with 2 MHz clock frequency will execute the
instruction MVI in 3.5 µs as follows:
Clock frequency of the system f = 2 MHz=2*10^6 Hz
Clock period T = 1/f = 1/2 x 106 = 0.5 µs=0.5*10^-6 s
Time to execute MVI = 7 T-states x 0.5
= 3.5 µs
The time delay in the loop TL with 2 MHz clock frequency is calculated as
TL = (T x Loop T-states x N10 )
Where TL = Time delay in the loop
T = System clock period
N10 = Decimal equivalent of the count loaded in the delay register
TL = (0.5 x 10-6 x 14 x 255)
= 1785 µs
≈ 1.8 ms
The T-states for JNZ instruction are 10/7. So the adjusted loop delay is
TLA = TL - (3 T-states x Clock period)
= 1785 µs – 1.5 µs = 1783.5 µs
Therefore, the total delay is
Total Delay = Time to execute instructions outside loop + Time to execute loop
instructions
TD = TO + TLA
= (7 x 0.5 µs) + 1783.5 µs = 1787 µs
≈ 1.8 ms
The difference between the loop delay TL and these calculations is only 2 µs
and can be ignored in most cases.
8.12 Time Delay Using a Register Pair
Here the counter value can be a 16-bit number and maximum of FFFFH.
Label Opcode Operand T-states
LXI B,2384H 10
LOOP: DCX B 6
MOV A,C 4
ORA B 4
JNZ LOOP 10/7
TIME DELAY
The loop includes 24 clock periods for execution. The decimal equivalent of
counter value is
2384H = 909210
If the clock period of the system = 0.5 µs, the delay in the loop TL is
TL = (T x Loop T-states x N10 )
= (0.5 x 24 x 909210)
≈ 109 ms (without adjusting for the last cycle)
Total Delay TD = 109 ms + TO
≈ 109 ms (the instruction LXI adds only 5 µs)
8.13 Time Delay Using a Loop within a Loop Technique
Label Opcode Operand T-states
MVI B,38H 7
LOOP2: MVI C,FFH 7
LOOP1: DCR C 4
JNZ LOOP1 10/7
DCR B 4
JNZ LOOP2 10/7
DELAY CALCULATIONS
The delay in LOOP1 is TL1 = 1783.5 µs. The counter value of LOOP2 is 5610
(38H). Delay for the LOOP2 is calculated as follows:
TL2 = 56 (TL1 + 21 T-states x 0.5 µs)
= 56 (1783.5 µs + 10.5 µs)
= 100.46 ms
8.3 ILLUSTRATIVE PROGRAM: ZERO-TO-NINE (MODULO TEN) COUNTER
PROBLEM STATEMENT
Write a program to count from 0 to 9 with a one-second delay between each
count. At the count of 9, the counter should reset itself to 0 and repeat the
sequence continuously. Assume the clock frequency of the microprocessor is 1
MHz.
Delay Calculations
Loop Delay TL = 24 T-states x T x Count
1 second = 24 x 1.0 x 10-6 x Count
Count = 1/(24 x 10-6 )
= 4166610
= A2C2H
Chapter-8 Counter and Time Delays

More Related Content

What's hot (11)

Counters & time delay
Counters & time delayCounters & time delay
Counters & time delay
 
04 18-2018--nmap blue
04 18-2018--nmap blue04 18-2018--nmap blue
04 18-2018--nmap blue
 
04 16-2018--nmap blue
04 16-2018--nmap blue04 16-2018--nmap blue
04 16-2018--nmap blue
 
Jp
Jp Jp
Jp
 
CalibrationModule
CalibrationModuleCalibrationModule
CalibrationModule
 
PSpice Simulation Resault
PSpice Simulation ResaultPSpice Simulation Resault
PSpice Simulation Resault
 
microprocessors
microprocessorsmicroprocessors
microprocessors
 
ControlLogix Timers FA16
ControlLogix Timers FA16ControlLogix Timers FA16
ControlLogix Timers FA16
 
Jrc gnss-testing-facilities
Jrc gnss-testing-facilitiesJrc gnss-testing-facilities
Jrc gnss-testing-facilities
 
Time delays & counter.ppt
Time delays & counter.pptTime delays & counter.ppt
Time delays & counter.ppt
 
Micro Assignment 2
Micro Assignment 2Micro Assignment 2
Micro Assignment 2
 

Similar to Chapter-8 Counter and Time Delays

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
 
MICROCONTROLLER TIMERS.ppt
MICROCONTROLLER TIMERS.pptMICROCONTROLLER TIMERS.ppt
MICROCONTROLLER TIMERS.pptreemasajin1
 
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
 
8051 Timers and Counters
8051 Timers and Counters8051 Timers and Counters
8051 Timers and Counterscjbas
 
Timer programming
Timer programming Timer programming
Timer programming vijaydeepakg
 
Microprocessor Week 9: Timer and Counter
Microprocessor Week 9: Timer and CounterMicroprocessor Week 9: Timer and Counter
Microprocessor Week 9: Timer and CounterArkhom Jodtang
 
lecture 12 counter_microcontroller2.ppt
lecture 12 counter_microcontroller2.pptlecture 12 counter_microcontroller2.ppt
lecture 12 counter_microcontroller2.pptHebaEng
 
computer architecture 4
computer architecture 4 computer architecture 4
computer architecture 4 Dr.Umadevi V
 
AVR_Course_Day7 timers counters and interrupt programming
AVR_Course_Day7 timers counters and  interrupt programmingAVR_Course_Day7 timers counters and  interrupt programming
AVR_Course_Day7 timers counters and interrupt programmingMohamed Ali
 

Similar to Chapter-8 Counter and Time Delays (20)

Microprocessor_Counter_and_Time_Delay.pptx
Microprocessor_Counter_and_Time_Delay.pptxMicroprocessor_Counter_and_Time_Delay.pptx
Microprocessor_Counter_and_Time_Delay.pptx
 
4.Timer_1.ppt
4.Timer_1.ppt4.Timer_1.ppt
4.Timer_1.ppt
 
8051 ch9
8051 ch98051 ch9
8051 ch9
 
8051 Timer
8051 Timer8051 Timer
8051 Timer
 
Microcontrollers-MODULE4.pptx
Microcontrollers-MODULE4.pptxMicrocontrollers-MODULE4.pptx
Microcontrollers-MODULE4.pptx
 
6.pptx
6.pptx6.pptx
6.pptx
 
MICROCONTROLLER TIMERS.ppt
MICROCONTROLLER TIMERS.pptMICROCONTROLLER TIMERS.ppt
MICROCONTROLLER TIMERS.ppt
 
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
 
Delay routine
Delay routineDelay routine
Delay routine
 
8051 Timers and Counters
8051 Timers and Counters8051 Timers and Counters
8051 Timers and Counters
 
Timer programming
Timer programming Timer programming
Timer programming
 
8051 ch9-950217
8051 ch9-9502178051 ch9-950217
8051 ch9-950217
 
Microprocessor Week 9: Timer and Counter
Microprocessor Week 9: Timer and CounterMicroprocessor Week 9: Timer and Counter
Microprocessor Week 9: Timer and Counter
 
12 mt06ped007
12 mt06ped007 12 mt06ped007
12 mt06ped007
 
lecture 12 counter_microcontroller2.ppt
lecture 12 counter_microcontroller2.pptlecture 12 counter_microcontroller2.ppt
lecture 12 counter_microcontroller2.ppt
 
UNIT-5.ppt
UNIT-5.pptUNIT-5.ppt
UNIT-5.ppt
 
Chapter 8
Chapter 8Chapter 8
Chapter 8
 
computer architecture 4
computer architecture 4 computer architecture 4
computer architecture 4
 
AVR_Course_Day7 timers counters and interrupt programming
AVR_Course_Day7 timers counters and  interrupt programmingAVR_Course_Day7 timers counters and  interrupt programming
AVR_Course_Day7 timers counters and interrupt programming
 
Class9
Class9Class9
Class9
 

Recently uploaded

Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
MICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxMICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxabhijeetpadhi001
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 

Recently uploaded (20)

Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
MICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxMICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptx
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 

Chapter-8 Counter and Time Delays

  • 1. Chapter-8 Counter and Time Delays 8.1 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. COUNTER A counter is designed simply by loading an appropriate number into one of the registers and using INR (for up-counter) or DCR (for down-counter) instructions. A loop is established to update the count. TIME DELAY The procedure used to design a specific delay is similar to that used to set up a counter. A register is loaded with a number, depending on the time delay required, and then the register is decremented until it reaches zero.
  • 2. 8.11 Time Delay Using One Register Label Opcode Operand T-states MVI C,FFH 7 LOOP: DCR C 4 JNZ LOOP 10/7=3 An 8085–based microcomputer with 2 MHz clock frequency will execute the instruction MVI in 3.5 µs as follows: Clock frequency of the system f = 2 MHz=2*10^6 Hz Clock period T = 1/f = 1/2 x 106 = 0.5 µs=0.5*10^-6 s Time to execute MVI = 7 T-states x 0.5 = 3.5 µs The time delay in the loop TL with 2 MHz clock frequency is calculated as TL = (T x Loop T-states x N10 ) Where TL = Time delay in the loop T = System clock period N10 = Decimal equivalent of the count loaded in the delay register
  • 3. TL = (0.5 x 10-6 x 14 x 255) = 1785 µs ≈ 1.8 ms The T-states for JNZ instruction are 10/7. So the adjusted loop delay is TLA = TL - (3 T-states x Clock period) = 1785 µs – 1.5 µs = 1783.5 µs Therefore, the total delay is Total Delay = Time to execute instructions outside loop + Time to execute loop instructions TD = TO + TLA = (7 x 0.5 µs) + 1783.5 µs = 1787 µs ≈ 1.8 ms The difference between the loop delay TL and these calculations is only 2 µs and can be ignored in most cases.
  • 4. 8.12 Time Delay Using a Register Pair Here the counter value can be a 16-bit number and maximum of FFFFH. Label Opcode Operand T-states LXI B,2384H 10 LOOP: DCX B 6 MOV A,C 4 ORA B 4 JNZ LOOP 10/7 TIME DELAY The loop includes 24 clock periods for execution. The decimal equivalent of counter value is 2384H = 909210 If the clock period of the system = 0.5 µs, the delay in the loop TL is TL = (T x Loop T-states x N10 ) = (0.5 x 24 x 909210) ≈ 109 ms (without adjusting for the last cycle)
  • 5. Total Delay TD = 109 ms + TO ≈ 109 ms (the instruction LXI adds only 5 µs) 8.13 Time Delay Using a Loop within a Loop Technique Label Opcode Operand T-states MVI B,38H 7 LOOP2: MVI C,FFH 7 LOOP1: DCR C 4 JNZ LOOP1 10/7 DCR B 4 JNZ LOOP2 10/7 DELAY CALCULATIONS The delay in LOOP1 is TL1 = 1783.5 µs. The counter value of LOOP2 is 5610 (38H). Delay for the LOOP2 is calculated as follows: TL2 = 56 (TL1 + 21 T-states x 0.5 µs) = 56 (1783.5 µs + 10.5 µs) = 100.46 ms
  • 6. 8.3 ILLUSTRATIVE PROGRAM: ZERO-TO-NINE (MODULO TEN) COUNTER PROBLEM STATEMENT Write a program to count from 0 to 9 with a one-second delay between each count. At the count of 9, the counter should reset itself to 0 and repeat the sequence continuously. Assume the clock frequency of the microprocessor is 1 MHz. Delay Calculations Loop Delay TL = 24 T-states x T x Count 1 second = 24 x 1.0 x 10-6 x Count Count = 1/(24 x 10-6 ) = 4166610 = A2C2H