Counters & Time Delays. Microprocessors & Interfacing 1

Similar documents
Assembly Language Programming of 8085

Assembly Language Programming of 8085

UNIT 1 REFERENCE 1 PREPARED BY S.RAVINDRAKUMAR, LECT/ECE, CHETTINAD COLLEGE OF ENGG AND TECH, KARUR

EEE310 MICROPROCESSORS M. Fatih Tüysüz CHAPTER 7

EXAMPLE PROGRAMS 8085


MSMF GATE CENTRE. Sub: MICROPROCESSORS. Time: 50min Date: Marks:33

INSTRUCTION SET OF 8085

Its Assembly language programming

8085 INSTRUCTION SET INSTRUCTION DETAILS

Delhi Noida Bhopal Hyderabad Jaipur Lucknow Indore Pune Bhubaneswar Kolkata Patna Web: Ph:

(2) Explain the addressing mode of OR What do you mean by addressing mode? Explain diff. addressing mode for 8085 with examples.

Instruction : A command to the microprocessor to perform a given task on specified data. Each instruction has two parts

Practical Course File For

Delhi Noida Bhopal Hyderabad Jaipur Lucknow Indore Pune Bhubaneswar Kolkata Patna Web: Ph:

MAHALAKSHMI ENGINEERING COLLEGE TIRUCHIRAPALLI

1 = Enable SOD 0 = Disable SOD. Serial Output Data. Fig.12.9 SIM Instruction Format

PERIPHERAL INTERFACING Rev. 1.0

The due date for submitting this assignment has passed. 1) How many times will the following loop be executed? Depends on the initial value of A

EKT222 Miroprocessor Systems Lab 5

Introduction to Assembly Language Programming (Instruction Set) 1/18/2011 1

Q. P. Code : b. Draw and explain the block dig of a computer with microprocessor as CPU.

Fig7 give the ALP for this problem THIS PROGRAMME / SUM OF N NATURAL NUMBERS FOR N G.T 22 ORG LNN EQU 360 D NSUM: LXIH, 0000 H ; INITIALIZE.

Assembly language Programming

SIR C.R.REDDY COLLEGE OF ENGINEERING ELURU DIGITAL ELECTRONICS & MICROPROCESSOR LAB MANUAL 2/4 CSE: II- SEMESTER

ELECTRICAL ENGINEERING

LIST OF PROGRAMS. Prg. Name of the Program. 1 Study of Pin Diagram of Study of Architecture of Study of 8085 Kit.

Assembly Language programming (3)

Computer Organization

Subject Code: Model Answer Page No: /25

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) MODEL ANSWER

Instruction set of 8085

Rotate Instructions in 8085 Microprocessor to Support Traffic control Signal Processes through Assembly Language which to be Taken as Input of 05H

EECE 340 Introduction to Microprocessors w/lab Section A. Term Project Parking Visitor Counter

Programming of 8085 microprocessor and 8051 micro controller Study material

MAHALAKSHMI ENGINEERING COLLEGE TIRUCHIRAPALLI UNIT I THE 8085 & 8086 MICROPROCESSORS. PART A (2 Marks)

(2½ Hours) [Total Marks: 75]

EC2304-MICROPROCESSOR AND MICROCONROLLERS 2 marks questions and answers UNIT-I

Matrix Multiplication in 8085

Architecture & Instruction set of 8085 Microprocessor and 8051 Micro Controller

8085 Microprocessor Programs

SAMPLE STUDY MATERIAL

CHAPTER 3 JUMP, LOOP, AND CALL INSTRUCTIONS

GATE Exercises on Microprocessors

PERIPHERAL INTERFACING Rev. 1.0

JUMP, LOOP AND CALL INSTRUCTIONS

SIR.C.R.R.COLLEGE OF ENGINEERING DEPT. OF ELECTRONICS AND INSTRUMENTATION ENGG. EIE-328: MICROPROCESSOR LABORATORY 3/4 B.E. EIE: SECOND SEMESTER

UNIT I. Differences between: Microcomputer, Microprocessor and Microcontroller

LABORATORY 1 INTRODUCTION TO 8085 MICROPROCESSOR DEVELOPMENT SYSTEM BOARD

ELEG3924 Microprocessor

8085 HOW-TO GUIDE Interfacing 8251 with 8085

ROEVER ENGINEERING COLLEGE

Valliammai Engineering College

PERIPHERAL INTERFACING Rev. 1.0

Control Transfer Instructions Jump, Loop, and Call. ECE473/573 Microprocessor System Design, Dr. Shiue

ELEG3923 Microprocessor Ch.3 Jump, Loop, and Call

EXPERIMENT-1 AIM: Familiarization of different keys of 8085 microprocessor kit and its memory map. APPARATUS: 8085 kit. DIAGRAM:

8051 Microcontroller Assembly Programming

1. What is Microprocessor? Give the power supply & clock frequency of 8085?

Sunday, April 25, 2010

EXPERIMENT NO. 1 THE MKT 8085 MICROPROCESSOR TRAINER

AE66/AC66/AT66/ AE108/AC108/AT108 MICROPROCESSORS & MICROCONTROLLERS

COPYRIGHT IS NOT RESERVED BY AUTHORS. AUTHORS ARE NOT RESPONSIBLE FOR ANY LEGAL ISSUES ARISING OUT OF ANY COPYRIGHT DEMANDS

CS2259-MICROPROCESSOR AND MICROCONTROLLER LABORATORY MANUAL

Unit 1 8 BIT MICROPROCESSOR ARCHITECTURE

Mwave+Microprocessor Conventional Solution (ESE-2015 Test Series Dated )

CREATING LOOP-BASED TIME DELAYS IN MICROPROCESSOR SYSTEMS

MICROPROCESSOR BASICS AND RELATED TERMS

2003 LXI H, 42F2H ; this instruction store 42F2 in to the HL pair POP H ; store data from top of the stack to HL pair

LABORATORY MANUAL. PROGRAMME: B.Tech SEMESTER /YEAR: 3rd year 5th Semester SUBJECT CODE: CS592 SUBJECT NAME: Microprocessor & Microcontroller Lab

INSTITUTE OF ENGINEERING AND MANAGEMENT, KOLKATA Microprocessor

CS521 CSE IITG 11/23/2012

The 8085 Instruction Set

Delhi Noida Bhopal Hyderabad Jaipur Lucknow Indore Pune Bhubaneswar Kolkata Patna Web: Ph:

UNIT 18 PROGRAMMING MICROPROCESSORS


G. Pullaiah College of Engineering and Technology: Kurnool Department Of Electronics and Communication Engineering

B.C.A 2017 MICROPROCESSOR AND ASSEMBLY LANGUAGE MODULE SPECIFICATION SHEET. Course Outline

XII HSC - BOARD - MARCH

MGM S Jawaharlal Nehru Engineering College

ET2640 Microprocessors

8085 Microprocessor Architecture and Memory Interfacing. Microprocessor and Microcontroller Interfacing

Week 2. Relational Operators. Block or compound statement. if/else. Branching & Looping. Gaddis: Chapters 4 & 5. CS 5301 Spring 2018.

Bachelor Level/ First Year/ Second Semester/ Science Full Marks: 60 Computer Science and Information Technology (CSc. 153) Pass Marks: 24

Repetition and Loop Statements Chapter 5

Mr. Sapan Naik 1. Babu Madhav Institute of Information Technology, UTU

ORG ; TWO. Assembly Language Programming

APPENDIX D FLOWCHARTS AND PSEUDOCODE OVERVIEW

Subroutines and the Stack

1. What is microprocessor? It is a program controlled semi conductor device (IC), which fetches, decodes and execute instructions.

Consider, for example an input device that has data available at

Microcontroller Intel [Instruction Set]

Chapter Family Microcontrollers Instruction Set

DE60/DC68 MICROPROCESSORS & MICROCONTROLLERS JUNE 2013

Micro Processor & Micro Controllers

An FPGA Implementation of 8-bit RISC Microcontroller

INDEX. 1 Study of intel 8085 micropeocessor kit. 2 Program to find addition of two 8 bit no. 3 Program to find subtraction of two 8 bit no.

PERIPHERAL INTERFACING Rev. 1.0

Chapter 4: Control structures. Repetition

EE309: Computer Organization, Architecture and MicroProcessors. sumantra/courses/up/up.html GND HIGH ORDER ADDRESS BUS

Transcription:

Counters & Time Delays Microprocessors & Interfacing 1

Counters A loop counter is set up by loading a register with a certain value 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. Microprocessors & Interfacing 2

Counters The operation of a loop counter can be described using the following flowchart. Initialize Body of loop Update the count No Is this Final Count? Yes Microprocessors & Interfacing 3

Delays It was shown in Chapter 2 that each instruction passes through different combinations of Fetch, Memory Read, and Memory Write cycles. Knowing the combinations of cycles, one can calculate how long such an instruction would require to complete. The table in Appendix F of 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. Microprocessors & Interfacing 4

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 mseconds to complete. Microprocessors & Interfacing 5

Delay loops We can use a loop to produce a certain amount of time delay in a program. The following is an example of a delay loop: MVI C, FFH 7 T-States LOOP DCR C JNZ LOOP 4 T-States 10 T-States 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. Microprocessors & Interfacing 6

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: T delay = T O + T L T delay = total delay T O = delay outside the loop T L = delay of the loop T O is the sum of all delays outside the loop. T L is calculated using the formula T L = T X Loop T-States X N 10 Microprocessors & Interfacing 7

Delay Loops (Contd.) Using these formulas, we can calculate the time delay for the previous example: T O = 7 T-States Delay of the MVI instruction T L = (14 X 255) - 3 = 3567 T-States 14 T-States for the 2 instructions repeated 255 times (FF 16 = 255 10 ) reduced by the 3 T-States for the final JNZ. T Delay = (7 + 3567) X 0.5 msec = 1.787 msec Assuming f = 2 MHz Microprocessors & Interfacing 8

Using a Register Pair as a Loop Counter Using a single register, one can repeat a loop for a maximum count of 255 times. 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. Microprocessors & Interfacing 9

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 loop counter. LXI B, 1000H 10 T-States LOOP DCX B 6 T-States MOV A, C 4 T-States ORA B 4 T-States JNZ LOOP 10 T-States Microprocessors & Interfacing 10

Using a Register Pair as a Loop Counter Using the same formula from before, we can calculate: T O = 10 T-States The delay for the LXI instruction T L = (24 X 4096) - 3 = 98301 T- States 24 T-States for the 4 instructions in the loop repeated 4096 times (1000 16 = 4096 10 ) reduced by the 3 T-States for the JNZ in the last iteration. T Delay = (10 + 98301) X 0.5 msec = 49.155 msec Microprocessors & Interfacing 11

Nested Loops 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. No No Initialize loop 2 Body of loop 2 Initialize loop 1 Body of loop 1 Update the count1 Is this Final Count? Yes Update the count 2 Is this Final Count? Yes Microprocessors & Interfacing 12

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 7 T-States LOOP2 MVI C, FFH 7 T-States LOOP1 DCR C 4 T-States JNZ LOOP1 10 T-States DCR B 4 T-States JNZ LOOP2 10 T-States Microprocessors & Interfacing 13

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 that delay in the calculation of the outer loop. Delay of inner loop T O1 = 7 T-States MVI C, FFH instruction T L1 = (255 X 14) - 3 = 3567 T-States 14 T-States for the DCR C and JNZ instructions repeated 255 times (FF 16 = 255 10 ) minus 3 for the final JNZ. T LOOP1 = 7 + 3567 = 3574 T-States Microprocessors & Interfacing 14

Delay Calculation of Nested Loops Delay of outer loop T O2 = 7 T-States MVI B, 10H instruction T L1 = (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 (10 16 = 16 10 ) minus 3 for the final JNZ. T Delay = 7 + 57405 = 57412 T-States Total Delay T Delay = 57412 X 0.5 msec = 28.706 msec Microprocessors & Interfacing 15

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. Microprocessors & Interfacing 16