8051 Timers Timers are the peripherals of the 8051 Microcontroller.

Slides:



Advertisements
Similar presentations
The 8051 Microcontroller and Embedded Systems
Advertisements

4-1 Timers Timers can be used for  timing  event counting  pulse width measurement  pulse generation  frequency multiplication There are 8 Timers.
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.
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.
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.
1 Chapter 4 Timer Operation (I. Scott MacKenzie).
Chapter 9 Counter/Timer Programming in the 8051
Chapter 4 TIMER OPERATION
CoE3DJ4 Digital Systems Design Chapter 4: Timer operation.
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
Timer Programming in Assembly and C Prepared By:
HJD Institute of Technical Education & Research- Kera(Kutch) The 8051 Microcontroller architecture PREPARED BY: RAYMA SOHIL( )
DEPARTMENT OF ELECTRONICS ENGINEERING V-SEMESTER MICROPROCESSOR & MICROCONTROLLER 1 CHAPTER NO microcontroller & programming.
Timer modules in PIC 16F877.  The PIC 16F877 basically has three independent timer modules,  denoted by the symbols, TIMER-0, TIMER1,andTIMER2. . These.
Serial I/O Port.
80C51 Block Diagram ECE Overview.
Assembly Language * * * * * * * 8051 Timer
Source: Serial Port Source:
Timer and Interrupts.
8051 Microcontroller Features and its Applications
Timer Source: under
Programmable Interval Timer
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.
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.
8254 Timer and Counter (8254 IC).
Timer.
8051 Timers / Counters It has two timers Timer 0 and Timer 1.
8051 Microcontroller.
Timer Source: under
Interrupt 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
JANAKIRAMAN E G S PILLAY ARTS AND SCIENCE COLLAGE NAGAPATTINAM DEPARTMENT OF PHYSICS.
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.
Compiled by Dr. N.Shanmugasundaram, HOD, ECE Dept, SECE.
Programmable Interval Timer
Source: Serial Port Source:
Timers Chapter 2.
Presentation transcript:

8051 Timers Timers are the peripherals of the 8051 Microcontroller. Timers are peripherals in any of the controllers. This peripheral is mainly used in time based applications. A timer is a specialized type of clock. It can be used to control the sequence of an event or process. The 8051 comes equipped with two timers (Timer 0 and Timer 1). These timers are 16 bit registers.

General Functions of the Timer Keeping time and/or calculating the amount of time between the events. Counting the Events themselves, or Generating baud rate for the serial port. Note: While generating delay this circuitry worked as Timer. While counting the number of events occurred at the particular time this circuitry worked as counter.

Baud Rate A number related to the speed of data transmission in a system. The rate indicates the number of electrical oscillations per second that occurs within a data transmission. The higher the baud rate, the more bits per second that are transferred.

For Timer: (Internal Pulses Working) Crystal Oscillator / 12 Circuitry TIMER “X” 11.0592 MHz f = 921.6 KHz Timer will get clock frequency from the crystal oscillator that is 11.0592 MHz. This frequency is given as input the circuitry that is called /12 (Divide by 12) circuitry. Because one machine cycle is nothing but 12 clock cycles.

For Counter : (External Pulses Working) Timer 0 T1 Timer 1 T0 and T1 is the external input. So counter will get external input from the T0 and T1

SFRs relating to Timers SFR Name Description SFR Address TH0 TIMER 0 Higher byte 8Ch TL0 TIMER 0 Lower byte 8Ah TH1 TIMER 1 Higher byte 8Dh TL1 TIMER 1 Lower byte 8Bh TCON TIMER Control 88h TMOD TIMER Mode 89h

TMOD Register If we program lower nibble, Timer 0 will get affected. Gate C/T M1 M0 Timer 1 Timer 0 If we program lower nibble, Timer 0 will get affected. If we program higher nibble, Timer 1 will get affected.

Gate: 0 – Software Control 1 – H/W Control (Instruction with Interrupt Signal) C / T: 0 – Timer 1- Counter

Mode Bits Information M0 and M1 Description 13 bit Timer 1 16 bit Timer 8 bit Auto Load Split Timer

TCON Register LSB MSB Interrupts Timers TF1 TR1 TF0 TR0 IE1 IT1 IE0

External Interrupt 1 Edge Flag IT1 External Interrupt 1 Type Flag IE0 Bit Names Description TF1 Timer 1 Overflow Flag TR1 Timer Run Control bit TF0 Timer 0 Overflow Flag TR0 Timer 0 Run Control Bit IE1 External Interrupt 1 Edge Flag IT1 External Interrupt 1 Type Flag IE0 External Interrupt 0 Edge Flag IT0 External Interrupt 0 Type Flag

Hardware Configuration of Timers

Timer Mode Explanations Mode 0 : TLX = 5 bit, THX = 8 bit Timer Address : 0000H to 1FFFH TLX THX TFX Interrupt

Timer Address : 0000H to FFFFH Mode 1 : TLX = 8 bit, THX = 8 bit Timer Address : 0000H to FFFFH TLX THX TFX Interrupt

TLx = 8 bits THx = for storing Value, 00H to FFH Mode 2 : Auto Reload (It is 8 – bit Mode), Because we can supposed to use only TLX 8 – bit only. TLx = 8 bits THx = for storing Value, 00H to FFH We have to initialize the TL register with some value. TH register is initialized with auto reload value. Interrupt TLX TFX Reload TLx

Mode 3 : TL0 = Timer 0 and TH0 = Timer 1 Timer 1 = 16 bit Timer Interrupt TL0 TF0 Interrupt TH0 TF1

Time Delay Calculation If we want to generate a time delay of 10 microseconds (or) 1 milliseconds. Step 1: Divide the required time delay by 1.085 Microseconds. Why 1.085 Microseconds? 11.0582MHz / 12 = 9.216KHz So, T = 1/f = 1/9.216KHz = 1.085Microseconds.

Time Delay Calculation Step 2: (Maximum value of Timer + 1)10 – (n)10= (Z)10. Maximum value of timer is depending on the mode of a Timer. In case of Mode 0 : Maximum value is = 1FFF. In case of Mode 1 : Maximum Value is = FFFF. Note : FFFF + 1 = 65536.

Time Delay Calculation Step 3: Convert (Z)10 to (YYXX)10 It will be loaded into TH and TL with YY & XX Respectively. TH = YY. TL = XX.

Example: Generate a time a time delay of 250microsecods. Assume Timer mode is 1. 1) (n)10 = 250microsecods/1.085microseconds = 230microseconds. 2) (z)10 = (FFFF+1) – (n)10 = 65536 – 230 = 65306. 3) Hexadecimal Value of 65306 is FF1AH. YY = FF XX = 1A TH = FFH and TL = 1AH