SlideShare une entreprise Scribd logo
1  sur  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

Contenu connexe

Tendances (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
 

Similaire à 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
 
5-Timer Mode 2 Programming-18-03-2024.pptx
5-Timer Mode 2 Programming-18-03-2024.pptx5-Timer Mode 2 Programming-18-03-2024.pptx
5-Timer Mode 2 Programming-18-03-2024.pptxRahultater4
 
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
 

Similaire à 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
 
5-Timer Mode 2 Programming-18-03-2024.pptx
5-Timer Mode 2 Programming-18-03-2024.pptx5-Timer Mode 2 Programming-18-03-2024.pptx
5-Timer Mode 2 Programming-18-03-2024.pptx
 
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
 

Dernier

Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...RKavithamani
 

Dernier (20)

Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
 

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