4-1 Timers Timers can be used for  timing  event counting  pulse width measurement  pulse generation  frequency multiplication There are 8 Timers.

Slides:



Advertisements
Similar presentations
The 8051 Microcontroller and Embedded Systems
Advertisements

Microcontroller Programming II MP6-1
Programmable Interval Timer
The 8051 Microcontroller Chapter 5 SERIAL PORT OPERATION.
8051 Core Specification.
Infineon Technologies Corp. June 99 1 HOT167-1 Version 2.0 * C167CS not yet supported by DAvE V1.0 CD ROM. See “Hints regarding DAvE.” Exercise 7ASC_1.
Infineon Technologies Corp. June 99 1 HOT167-1 Version 2.0 F PWMmax = x 50ns = 78 kHz Pulse Width Modulation Unit (PWM) (20 MHz)  4 independent.
5-1 Timer/Counters In many microprocessor systems we need to:  count logic pulses  measure the frequency of signals  measure the period of pulses 
7-1 Digital Serial Input/Output Two basic approaches  Synchronous shared common clock signal all devices synchronised with the shared clock signal data.
Timers and Interrupts Shivendu Bhushan Summer Camp ‘13.
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”
Lecture 9 Timer Operations and Programming. 2  Introduction  Summary of timers  Timer programming sequence  Summary of timer SFRs  Timer 0: 8-bit.
1 Timing System Timing System Applications. 2 Timing System components Counting mechanisms Input capture mechanisms Output capture mechanisms.
CHAPTER TIMER PROGRAMMING Timers The 8051 has two timers/counters, they can be used as ◦ Timers to generate a time delay ◦ Event counters.
8254 Programmable Interval Timer
ENEE 440 Chapter Timer 8254 Register Select The 8254 timer is actually 3 timers in one. It is an upgraded version of the 8253 timer which was.
1 Chapter 4 Timer Operation (I. Scott MacKenzie).
ECE 371- Unit 11 Timers and Counters (“Stop Watches and Alarm Clocks”)
7/23 Timers in Coldfire Processor Computer Science & Engineering Department Arizona State University Tempe, AZ Dr. Yann-Hang Lee (480)
8253 TIMER. Engr 4862 Microprocessors 8253 / 8254 Timer A.k.a. PIT (programmable Interval Timer), used to bring down the frequency to the desired level.
PIT: Programmable Interval Timer
8254 Counter/Timer Counter Each of the three counter has 3 pins associated CLK: input clock frequency- 8 MHz OUT GATE: Enable (high) or disable.
ARM Timers.
System Clocks.
Timers ELEC 330 Digital Systems Engineering Dr. Ron Hayne
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.
MCU: Interrupts and Timers Ganesh Pitchiah. What’s an MCU ?
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.
© 2009, Renesas Technology America, Inc., All Rights Reserved 1 Course Introduction  Purpose This course provides an introduction to the peripheral functions.
Example. SBUF Register SCON Register(1) SCON Register(2)
1 68HC11 Timer Chapter HC11 Timer Subsystem Several timing functions: Basic timing Basic timing Real time interrupts Real time interrupts Output.
© 2008, Renesas Technology America, Inc., All Rights Reserved 1 Course Introduction Purpose This course provides an overview of the standard peripheral.
8254 Timer.
Intel 8051 Another family of microcontroller is the Intel 8051 family. The basic 8051 microcontroller has four parallel input/output ports, port 0, 1,
1 68HC11 Timer HC11 or HC12: Chapter HC11 Timer Subsystem  Several timing functions: Basic timing Basic timing Real time interrupts Real time.
© 2009, Renesas Technology America, Inc., All Rights Reserved 1 Course Introduction  Purpose This course provides an introduction to the peripheral functions.
Jump, Loop, and Call Instructions
#1 of 10 Tutorial Introduction PURPOSE -To explain how to configure and use the Timer Interface Module in common applications OBJECTIVES: -Identify the.
1 68HC11 Timer. 2 68HC11 Timer Subsystem Several timing functions: Basic timing Basic timing Real time interrupts Real time interrupts Output compare.
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..
Why are Timer Functions Important?
V.V.P. ENGINEERING COLLEGE,RAJKOT
Timer and Interrupts.
8051 Timers Timers are the peripherals of the 8051 Microcontroller.
Timer Source: under
AVR Addressing Modes Subject: Microcontoller & Interfacing
MSP432 ARM Timer Programming
BVM Engineering College Electrical Engineering Department : Microprocessor and Microcontroller Interfacing Interrupts of 8051 Prepared by:
ECE 3430 – Intro to Microcomputer Systems
An Introduction to Microprocessor Architecture using intel 8085 as a classic processor
Timer Operations and Programming
EMT 348: Microcontroller Timer/counter
Introduction to Micro Controllers & Embedded System Design Timer Operation Department of Electrical & Computer Engineering Missouri University of Science.
8254 Timer and Counter (8254 IC).
Timer.
Timer Source: under
PIC18 Timer Programming “Explain the assembly language programming for the timer and counter module”
Important 8051 Features On chip oscillator 4K bytes ROM 128 bytes RAM
8051 Micro Controller.
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.
Timer/Counter Timer/Counter 0 Timer/Counter 1 Timer/Counter 2 8 bit
Presentation transcript:

4-1 Timers Timers can be used for  timing  event counting  pulse width measurement  pulse generation  frequency multiplication There are 8 Timers (T0 – T7)  T0 and T1 – CAPCOM1 [CAPture and COMpare]  T7 and T8 – CAPCOM2  T2, T3, T4, T5 and T6 – General Purpose Timers (GPT)

4-2 General Purpose Timers (GPTs) The five GPT’s are 16-bit timers that are grouped into the two timer blocks GPT1 and GPT2. Block GPT1 contains 3 timers/counters with a maximum resolution of 16 TCL(TCL = 50ns for f CPU = 20MHz) Block GPT2 contains 2 timers/counters with a maximum resolution of 8 TCL and a 16-bit Capture/Reload register (CAPREL).

4-3 GPT1 Block From a programmer’s point of view, the GPT1 block is composed of a set of SFR’s as summarized below. Those portions of port and direction registers which are used for alternate functions by the GPT1 block are shaded.

4-4 Timers T2, T3 and T4 Four basic modes  Timer  Gated timer  Counter  Incremental interface mode – for incremental encoders All timers can count up or down When a timer register overflows from FFFFH to 0000H (when counting up), or when it underflows from 0000H to FFFFH (when counting down), its interrupt request flag (T2IR, T3IR orT4IR) in register TxIC will be set. Each timer has an alternate input function pin (TxIN) associated with it which serves as the count input in counter mode, or as the gate control in gated timer mode. x – refers to the timer number

4-5 Timer 2, 3 and 4 Physical microcontroller pin TxUD – External Timer Up/Down control TxIN – External clock input T3OUT – External output pin from Timer3 fcpu – CPU clock input to prescaler (which divides by 8,16, 32, …1024)

4-6 T2, T3 and T4 Timers (contd.) T3 is the called core timer The count direction (Up/Down) may be programmed via software or may be dynamically altered by a signal at an external control input pin. Each overflow/underflow of core timer T3 is latched in the toggle Flip-Flop T3OTL and may be indicated on an alternate output function pin. T2 and T4 do not have this feature. Some timer modes require the use of more than one timer. For example : The auxiliary timers T2 and T4 may additionally be concatenated with the core timer, or used as capture or reload registers for the core timer.

4-7 Timer Control Register T3CON – Timer 3 Control Register (bit addressable)

4-8 T3 in Timer mode n = Note the x in TxUD, TxUDE, TxI etc. refers to the timer number The 3 TxI bits in TxCON determine the precaler factor as shown in the table below.

4-9 T3 in Timer mode UP(0)/DOWN(1)

4-10 Timer 3 generating a fixed delay // Initialise timer 3 for Timer mode, prescaler 101 (÷256), timer stopped // count down, disable external up/down, T3OTL output disabled T3CON = 0x0085;// // timer period = prescaler / fcpu = 256/20MHz = 12.8uS // delay required = uS. Timer value = /12.8 = // Clear T3 interrupt request bit, load timer value and run timer T3IR = 0; T3 = 31249; // 1 less than number of counts required T3R = 1; /* T3 is now decremented by hardware every 12.8uS, after decrements the interrupt request flag is set. The program should poll/test this flag. */ while (T3IR == 0); // wait until interrupt request is set

4-11 #include /* standard I/O.h-file */ #include /* special function registers for 167’s */ /*************************************************/ /* Use Timer 3 to generate a delay of 0.4 seconds*/ /*************************************************/ void main (void) { /* initialize the serial interface */ #ifndef MCB167 /* do not initialize with Monitor-166 */ P3 |= 0x0400; /* SET PORT 3.10 OUTPUT LATCH (TXD) */ DP3 |= 0x0400; /* SET PORT 3.10 DIRECTION CONTROL(TXD O/P)*/ DP3 &= 0xF7FF; /* RESET PORT 3.11 DIRECTION CONTROL(RXD i/p)*/ S0TIC = 0x80; /* SET TRANSMIT INTERRUPT FLAG */ S0RIC = 0x00; /* DELETE RECEIVE INTERRUPT FLAG */ S0BG = 0x40; /* SET BAUDRATE TO 9600 BAUD */ S0CON = 0x8011; /* SET SERIAL MODE */ #endif... see next slide, which goes here... } Example - Timer delay

4-12 //Initialise timer 3 for timer mode, prescaler=256, timer stopped //count down, disable external up/down T3CON = 0x0085;// while (1)//do this endlessly! { printf("\nPress a key to start timer\n"); _getkey();// special Keil function to wait for a key // Clear T3 interrupt request bit, load timer value and run timer T3IR = 0; T3 = 31249; T3R = 1; printf("Timing started\n"); // Now wait for T3 interrupt request bit to be set to 1 // This should take x 12.8uS = uS = 400ms = 0.4S // based on a 20MHz cpu clock frequency while( T3IR == 0); T3R = 0; //Stop timer //When loop terminates we know the required delay has elapsed printf("400 milliseconds has elapsed\n"); }

4-13 Gated Timer Mode Timer mode bits TxM TxIN – provides the gating of the clock This mode is used for measuring the period of pulses gate open n = 3..10

4-14 Counter mode The 3 bits TxI determine the transition for counter increment/decrement

4-15 Timer T2 and T4

4-16 Concatenation of Timers Concatenation of Core Timer T3 and an Auxiliary Timer