Timer Source: http://www.edsim51.com/8051Notes/8051/timers.html under http://www.edsim51.com/8051Notes/index.html.

Slides:



Advertisements
Similar presentations
The 8051 Microcontroller and Embedded Systems
Advertisements

8253/54 Timer Section /54 Timer Description and Initialization
8051 Core Specification.
CSC Timers Since this is a microcontroller it mainly finds itself in embedded devices Quite often embedded devices need to synchronize events The.
Chapter 6 Interrupts (I. Scott Mackenzie).
Microcontroller 8051.
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”
Lecture 9 Timer Operations and Programming. 2  Introduction  Summary of timers  Timer programming sequence  Summary of timer SFRs  Timer 0: 8-bit.
The 8051 Microcontroller architecture
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.
Lecture 9. - Synchronous Devices require a timing signal. Clock generated Interval Timer Microprocessor Interval Timer Clk PCLK = MHz PCLK (for.
8254 Programmable Interval Timer
1 Chapter 4 Timer Operation (I. Scott MacKenzie).
Chapter 9 Counter/Timer Programming in the 8051
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.
Timers ELEC 330 Digital Systems Engineering Dr. Ron Hayne
Chapter 4 TIMER OPERATION
CoE3DJ4 Digital Systems Design Chapter 4: Timer operation.
CoE3DJ4 Digital Systems Design Hardware summary. Microprocessors vs. Microcontrollers Microprocessors are single-chip CPU used in microcomputers Microcontrollers.
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.
MCS51 - lecture 3. Lecture 3 2/30 Timers/counters MCS51.
Intel 8051 Another family of microcontroller is the Intel 8051 family. The basic 8051 microcontroller has four parallel input/output ports, port 0, 1,
The 8051 Microcontroller Prepared By, R-THANDAIAH PRABU M.E.,
Jump, Loop, and Call Instructions
The Silicon Laboratories C8051F020
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,
Lecture 41 CSE 341 – Microprocessors Lecture 4 Md. Omar Faruqe UB 1228
kashanu.ac.ir Microprocessors Interrupts Lec note 8.
Timer Programming in Assembly and C Prepared By:
HJD Institute of Technical Education & Research- Kera(Kutch) The 8051 Microcontroller architecture PREPARED BY: RAYMA SOHIL( )
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.
Serial I/O Port.
80C51 Block Diagram ECE Overview.
Assembly Language * * * * * * * 8051 Timer
Source: Serial Port Source:
8051 Timers Timers are the peripherals of the 8051 Microcontroller.
Timer Source: under
Programmable Interval Timer
Programmable Interval Timer
BVM Engineering College Electrical Engineering Department : Microprocessor and Microcontroller Interfacing Interrupts of 8051 Prepared by:
Interrupt Source: under
Introduction to Micro Controllers & Embedded System Design Interrupt
UNIT 5 TIMRERS/COUNTERS
Introduction to Micro Controllers & Embedded System Design I/O Processing and Serial Port Operation Department of Electrical & Computer Engineering Missouri.
An Introduction to Microprocessor Architecture using intel 8085 as a classic processor
Timer Operations and Programming
EMT 348: Microcontroller Timer/counter
Source: Serial Port Source:
8051 Timers Prof. Rajiv R Bhandari.
Interrupt.
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.
8051 Microcontroller.
Interrupt Source: under
Interrupt Source: under
INTRODUCTION TO 8051, A 8-BIT MICROCONTROLLER
Source: Serial Port Source:
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:

Timer Source: http://www.edsim51.com/8051Notes/8051/timers.html under http://www.edsim51.com/8051Notes/index.html

The basic 8051 has two 16-bit on-chip timers: (1) Timer 0 (TH0TL0) & (2) Timer 1 (TH1TL1) They can be used for (1) timing durations, or (2) counting external events.

Timer Mode Register (TMOD) TMOD (Timer Mode Register ) Bit Name Timer Description 7 Gate 1 Gate bit; when set, timer only runs while INT-bar is high. This bit is used in conjunction with interrupts and will be dealt with later. 6 C/T-bar Counter/timer select bit; when set timer is an event counter, when cleared timer is an interval timer. 5 M1 Mode bit 1 4 M0 Mode bit 0 3 Gate bit; when set, timer only runs while INT-bar is high. 2

Timer Modes M1 M0 Mode Description 13-bit timer mode (this mode exists simply to keep the 8051 backwards compatible with its predecessor, the 8048, which had a 13-bit timer) - we will not be using mode 0. 1 16-bit timer mode 2 8-bit auto-reload mode 3 Split timer mode - this mode will be dealt with at a later stage X = 1 for Timer 1 X = 0 for Timer 0

Note on the 8-bit auto-reload mode Example 6 of edsim51 MOV TMOD, #2H ; set timer 0 as 8-bit auto-reload interval timer MOV TH0, #-50 ; | put -50 into timer 0 high-byte - this reload value, ; | with system clock of 12 MHz, will result in a timer 0 overflow every 50 us MOV TL0, #-50 ; | put the same value in the low byte to ensure the timer starts counting from ; | 236 (256 - 50) rather than 0 TL0 (binary) Signed value Unsigned value  00000010 2 00000001 1 00000000 Counting ends 11111111 -1 255 11111110 -2 254 11001100 -48 108 11001101 -49 107 Counting starts 11001110 -50 106

Timer Control Register TCON (Timer Control Register) Bit Symbol Bit Address Description 7 TF1 8FH Timer 1 overflow flag; set by hardware upon overflow, cleared by software. 6 TR1 8EH Timer 1 run-control bit; manipulated by software - setting starts timer 1, resetting stops timer 1. 5 TF0 8DH Timer 0 overflow flag; set by hardware upon overflow, cleared by software. 4 TR0 8CH Timer 0 run-control bit; manipulated by software - setting starts timer 0, resetting stops timer 0. 3 IE1 8BH The bottom four bits of TCON are used in conjunction with interrupts. ITx controls the triggering condition of external x interrupt. = 1: negative-edge triggering = 0: low-level triggering IEx is the interrupt flag for external interrupt x , where x = 0 or 1 2 IT1 8AH 1 IE0 89H IT0 88H SETB TR0; start timer 0 SETB TR1; start timer 1 CLR TR0; stop timer 0 CLR TR1; stop timer 1

Clock Source When the timer is operating as an interval timer it is being clocked by the internal clock. This internal clock, usually 12MHz, is actually divided by twelve to yield a reasonable clock frequency for most applications - therefore, the internal clocking signal is usually 1MHz). When the timer is operating as an event counter it is triggered by an external source connected to pin T0 (port 3, pin 4) for timer 0 and pin T1 (port 3, pin 5) for timer 1.