Lecture 41 CSE 341 – Microprocessors Lecture 4 Md. Omar Faruqe UB 1228

Slides:



Advertisements
Similar presentations
The 8051 Microcontroller and Embedded Systems
Advertisements

Review: Interrupts & Timers
4-1 Timers Timers can be used for  timing  event counting  pulse width measurement  pulse generation  frequency multiplication There are 8 Timers.
8051 Core Specification.
Timers in Hardware ECE152. Overview Why are timers important – Watchdog – Task switching – Accurate time of day Can use polling or interrupts.
CSC Timers Since this is a microcontroller it mainly finds itself in embedded devices Quite often embedded devices need to synchronize events The.
5-1 Timer/Counters In many microprocessor systems we need to:  count logic pulses  measure the frequency of signals  measure the period of pulses 
Timers and Interrupts Shivendu Bhushan Summer Camp ‘13.
Architecture of the 8051 INTERNAL DATA BUS Oscillator & Timing Programmable I/O (32 Pins) 80C51 CPU 64K byte Expansion Control Serial I/O 4K Program Memory.
Embedded Systems UNIT 3. Pin Details of 8051 Pins 1-8: Port 1 Each of these pins can be configured as an input or an output. Pin 9: The positive voltage.
1.  8051 Timers “count up,” incrementing the Timer’s respective “count register” each time there is a triggering clock pulse. 2  When the “count register”
INTERRUPTS PROGRAMMING
Lecture 9 Timer Operations and Programming. 2  Introduction  Summary of timers  Timer programming sequence  Summary of timer SFRs  Timer 0: 8-bit.
Timers and Interrupts Shivendu Bhushan Sonu Agarwal.
1 Timing System Timing System Applications. 2 Timing System components Counting mechanisms Input capture mechanisms Output capture mechanisms.
NATIONAL TAIWAN OCEAN UNIVERSITY 國立台灣海洋大學 2002/4/8 Microcomputers and Microprocessors Chapter 9 COUNTER/TIMER PROGRAMMING IN THE 8051.
CHAPTER TIMER PROGRAMMING Timers The 8051 has two timers/counters, they can be used as ◦ Timers to generate a time delay ◦ Event counters.
8051 timer/counter.
1 Chapter 4 Timer Operation (I. Scott MacKenzie).
Chapter 9 Counter/Timer Programming in the 8051
System Clocks.
Chapter 4 TIMER OPERATION
CoE3DJ4 Digital Systems Design Chapter 4: Timer operation.
Unit 10.2 Timer Examples. Example – Music Generation Channel 6 – Set up as a timer Output to Generate Square Waves Channel 4 – Set up as a timer Output.
Lecture Set 9 MCS-51 Serial Port.
MCU: Interrupts and Timers Ganesh Pitchiah. What’s an MCU ?
Timers.
Timers /Counters Programming  The 8051 has 2 timers/counters: ○ timer/counter 0 ○ timer/counter 1 They can be used as 1. The timer is used as a time.
1. Registers Used in Timer/Counter  TH0, TL0, TH1, TL1  TMOD (Timer mode register)  TCON (Timer control register) 2.
8051 Timer/Counter Lec note 7.
8051 Micro controller. Architecture of 8051 Features of 8051.
Timers and Interrupts Anurag Dwivedi. Let Us Revise.
Intel 8051 Another family of microcontroller is the Intel 8051 family. The basic 8051 microcontroller has four parallel input/output ports, port 0, 1,
Jump, Loop, and Call Instructions
TIMERS AND INTERRUPTS AVI SINGH KEVIN JOSE PIYUSH AWASTHI.
The Silicon Laboratories C8051F020
Microprocessors CSE 341 Lecture Md. Omar Faruqe UB 1228
8051 Aula 02 Prof Afonso Ferreira Miguel. Microcontrolador 8051 (MCS-51)  Timers do MCS51 Two 16-bit Counter/Timers: Two 16-bit Counter/Timers: Up counters,
Microprocessors A practical approach Lesson 2 Hardware description and Delays.
Lecture 3 CSE 341 – Microprocessors Lecture 3 Md. Omar Faruqe UB 1228
kashanu.ac.ir Microprocessors Interrupts Lec note 8.
Microprocessor and Microcontroller Based Systems Instructor: Eng.Moayed N. EL Mobaied The Islamic University of Gaza Faculty of Engineering Electrical.
Timer Programming in Assembly and C Prepared By:
80C51 Block Diagram 1. 80C51 Memory Memory The data width is 8 bits Registers are 8 bits Addresses are 8 bits – i.e. addresses for only 256.
DEPARTMENT OF ELECTRONICS ENGINEERING V-SEMESTER MICROPROCESSOR & MICROCONTROLLER 1 CHAPTER NO microcontroller & programming.
One more PIC18F252 example and revision for exam B222L Branislav Vuksanovic, UoP, ECE.
Microprocessors A practical approach..
80C51 Block Diagram ECE Overview.
Assembly Language * * * * * * * 8051 Timer
UNIT – Microcontroller.
8051 Timers Timers are the peripherals of the 8051 Microcontroller.
Timer Source: under
BVM Engineering College Electrical Engineering Department : Microprocessor and Microcontroller Interfacing Interrupts of 8051 Prepared by:
Interrupt Source: under
UNIT 5 TIMRERS/COUNTERS
EMT 348: Microcontroller Timer/counter
8051 Timers Prof. Rajiv R Bhandari.
Introduction to Micro Controllers & Embedded System Design Timer Operation Department of Electrical & Computer Engineering Missouri University of Science.
Timer.
8051 Timers / Counters It has two timers Timer 0 and Timer 1.
Timer Source: under
Interrupt Source: under
Interrupt Source: under
EECE.3170 Microprocessor Systems Design I
Timer Source: under
8253 – PROGRAMMABLE INTERVAL TIMER (PIT). What is a Timer? Timer is a specialized type of device that is used to measure timing intervals. Timers can.
Programmable Interval Timer
Source: Serial Port Source:
Presentation transcript:

Lecture 41 CSE 341 – Microprocessors Lecture 4 Md. Omar Faruqe UB

Lecture 42 Delay Routines Delay Routines are very important in microcontroller based systems. Just as we saw in the labs last week, we need delay routines to be incorporated in many applications that we build using microcontroller. How do we write a simple delay routine ? We could use a dummy loop. A loop that makes the processor go in cycles inside the loop thus delaying the processor.

Lecture 43 Delay Routine The light needs to be toggled every 0.5 sec

Lecture 44 Requirements of the Routine Simple Flowchart showing the delay requirements.

Lecture 45 Delay Program ORG 0H JMP Main ORG 30H Main: SETB P1.0 JMP Delay CLR P1.0 JMP Delay JMP Main Delay:.. RET END

Lecture 46 Delay Routine NC = 1 + (1+2)*5 = 16 Cycles Let us suppose the Microprocessor is running a 1MHz. What is the time taken by each clock cycle ?.1µS So the delay produced by the above program is?16µS

Lecture 47 Delay Routine Remember we said that the registers were 8 bits. So what is the maximum number they can hold ?255 Calculate the delay caused by this program? Nc = 1 + (1+2)*255 = 766 Cycles As each cycles takes, 1  S, the program therefore can generate a maximum of 766  S. What would be the delay if the  P ran at 10 MHz?76.6  S.

Lecture 48 Delay Routine Remember we needed to generate a delay of 0.5S We found that using 1 dummy loop it is possible to generate max of 766  S. So any ideas how we can do this ? Multiple Dummy Loops !

Lecture 49

10 Delay Routines Total Number of Cycles, NC = 1 + [ 1+(1+2)*N ]*N1 + 2 = 1 + [ 4 + 3N2]*N1 + 2 = 3 + 4N1 + 3 N1 N2 Now if you wanted to generate a fixed delay you would have a fixed NC and you would need to calculate N1 & N2 that gives the intended NC value. This is a huge problem:  The calculation is cumbersome  It is even more harder when an application required varying delay.  The size of the register limits the maximum delay that you can have  Exact delays can be very hard to achieve

Lecture 411 Timers Internal Timers are very important aspects of microprocessors. 11 Internal timers can be used to provide an interrupt after a specified period of time. This is essential in the design of O/S. It is also needed in applications which requires a specific time delay. The 8051 has two 16bit timers. Timer 0 – T0 Timer 1 – T1 There are two timer functions: Counter (Can count external events) Timer (Counts machine cycle)

Lecture 412 Timers The timer function of the microprocessor has 4 modes (in this case) The modes have to be specified using a SFR called TMOD. The structure of TMOD is given below: To understand this in details let us examine the timer architecture.

Lecture 413 Timers Architecture

Lecture 414 Timers Gate: This acts as a switch to decide whether the timer will be controller by external interrupt or not. When Gate is set to ‘1’ the timer starts using external signals When Gate is set to ‘0’ the timer is controlled internally. When this bit is set (i.e. ‘1’), the timer may be controlled externally by 1 INT (P3.3) for timer 1 and 0 INT (P3.4). for timer 0. The timer starts when this pin is high. When the Gate bit is ‘0’, then the counter starts internally by making TR1 or TR0 set to ‘1’. T/C : This bit determines whether the internal oscillator clock or an external clock from pin T1 for timer 1 or T0 for timer 0 should be used.

Lecture 415 Timer Modes

Lecture 416 Setting up the timer TFO - Timer overflow Bit TRO - Timer Start Bit

Lecture 417 Writing a Timer based Delay The procedure for programming the timer is as follows: Initialization of the TMOD register Initialization of TL0 and TH0 Timer start command Monitor TF0 until set

Lecture  S Delay Routine So what should be the values of TH1 and TL1 if we were to achieved a 100 mS delay? The overflow occurs when the bits are set to – 100 = FF C9 TH TL

Lecture  S Delay Routine

Lecture 420 Write a 0.5s Delay Routine?

Lecture 421 Questions ?