MCS51 - lecture 3. Lecture 3 2/30 Timers/counters MCS51.

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.
Microcontroller Programming II MP6-1
8051 Core Specification.
8-Bit Timer/Counter 0 Counter/Timer 0 and 2 (TCNT0, TCNT2) are nearly identical. Differences: -TCNT0 can run off an external 32Khz clock (Tosc) or 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 
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.
16-Bit Timer/Counter 1 and 3 Counter/Timer 1,3 (TCNT1, TCNT3) are identical in function. Three separate comparison registers exist. Thus, three separate.
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
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.
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.
16F877A. Timer 0 The Timer0 module timer/counter has the following features: –8-bit timer/counter –Readable and writable –8-bit software programmable.
Timers ELEC 330 Digital Systems Engineering Dr. Ron Hayne
Chapter 4 TIMER OPERATION
CoE3DJ4 Digital Systems Design Chapter 4: Timer operation.
Timers The timers of the PIC16C7X microcontroller can be briefly described in only one sentence. There are three completely independent timers/counters.
ECE 447 Fall 2009 Lecture 10: TI MSP430 Timers and Capture Modes.
MCS51 - part 1.
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.
1. Registers Used in Timer/Counter  TH0, TL0, TH1, TL1  TMOD (Timer mode register)  TCON (Timer control register) 2.
MCS51 - lecture 4. Lecture 3 1/27 Serial ports MCS51 Standard SIO Some extensions and modifications.
ELE22MIC Lecture 18 The AVR Sleep Modes The ATMEGA128’s Timer System
8051 Timer/Counter Lec note 7.
1 68HC11 Timer Chapter HC11 Timer Subsystem Several timing functions: Basic timing Basic timing Real time interrupts Real time interrupts Output.
MCS51 - lecture 6. Lecture 6 1/32 Extending MCS51 system Built-in peripherals MCS51 family.
© 2008, Renesas Technology America, Inc., All Rights Reserved 1 Course Introduction Purpose This course provides an overview of the standard peripheral.
MCS51 - lecture 5. Lecture 5 2/28 Interrupts in MCS51 Step work Power consumption reducing.
1 68HC11 Timer HC11 or HC12: Chapter HC11 Timer Subsystem  Several timing functions: Basic timing Basic timing Real time interrupts Real time.
Interrupts  An interrupt is any service request that causes the CPU to stop its current execution stream and to execute an instruction stream that services.
© 2009, Renesas Technology America, Inc., All Rights Reserved 1 Course Introduction  Purpose This course provides an introduction to the peripheral functions.
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,
#1 of 10 Tutorial Introduction PURPOSE -To explain how to configure and use the Timer Interface Module in common applications OBJECTIVES: -Identify the.
Timer Programming in Assembly and C Prepared By:
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.
16F877A.
Why are Timer Functions Important?
V.V.P. ENGINEERING COLLEGE,RAJKOT
80C51 Block Diagram ECE Overview.
Assembly Language * * * * * * * 8051 Timer
8051 Timers Timers are the peripherals of the 8051 Microcontroller.
Timer Source: under
UNIT 5 TIMRERS/COUNTERS
Timer Operations and Programming
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.
Pugazhendhi.M 11/12/2018 TIMERS 11/12/2018 CCET CCET.
Timer.
8051 Timers / Counters It has two timers Timer 0 and Timer 1.
8-bit Timer/Counter2 with PWM and Asynchronous Operation
Timer Source: under
UNIT 19 PWM 로봇 SW 교육원 조용수.
Lecture 12 Multi-Function Timer Pulse Unit 2 (MTU2a)
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
Programmable Interval Timer
Presentation transcript:

MCS51 - lecture 3

Lecture 3 2/30 Timers/counters MCS51

MCS51 - timer/counter #0 i #1 3/30 Common features: 16-bit; accessible in SFR as register pairs THx-TLx; counting up; count machine cycles (timer mode) or external pulses (counter mode); external pulses can be gated; controlled by special registers in SFR; overflow (from 0FFFF to 0) sets TFx flag, which can cause interrupt; 3 the same working mode: 0, 1 i 2. Timer/counter #0 can also work in mode 3, then timer/counter #1 is stopped.

MCS51 - timer/counter #0 i #1 4/30 GATEC/TM1M0GATEC/TM1M0 TMOD89h Control registers: timer/counter #1timer/counter #0 GATE - set - enables gating of external pulses; C/T - set - counter mode, cleared - timer mode; M1,M0 - select one of working mode: timer/counter #1timer/counter # mode mode 0(13-bit) mode mode 1(16-bit) mode mode 2(8-bit with reload) disabled1 1 - mode 3(double 8-bit)

MCS51 - timer/counter #0 i #1 5/30 TF1 8F TR1 8E TF0 8D TR0 8C IE1 8B IT1 8A IE0 89 IT0 88 TCON88h TF1 - timer/counter #1 overflow flag TR1 - set - starts timer/counter 1 TF0 - timer/counter #0 overflow flag TR0 - set - starts timer/counter 0 8AhTL0 8BhTL1 8ChTH0 8DhTH1 Value registers:

MCS51 - timer/counter #0 i #1 6/30 Mode bit OSC TLx 5bTHx 8b :12 TRx C/T GATE TFx Tx INTx

MCS51 - timer/counter #0 i #1 7/30 Mode bit OSC TLx 8bTHx 8b :12 TRx C/T GATE TFx Tx INTx

MCS51 - timer/counter #0 i #1 8/30 Mode bit with automatic reload OSC TLx 8b THx 8b :12 TRx C/T GATE TFx Tx INTx

MCS51 - timer/counter #0 i #1 9/30 Timer/counter #0 mode 3 - double 8-bit OSC TL0 8b TH0 8b :12 TR0 C/T GATE TF0 Tx INT TF TR1

MCS51 - timer/counter #0 i #1 10/30 Counting external pulses (C/T=1): counted falling edges; falling edge on input Tx is detected, if during one machine cycle there is a high level and in the next - low; increment of counter content is done in machine cycle following detected edge; maximal frequency of counted pulses = f CLK :24. machine cycle N-1machine cycle Nmachine cycle N+1 detection of falling edge counter increment 3 / 4 m.c. 1 / 3 m.c.

MCS51 - timer/counter #0 i #1 11/30 Possible applications of timer/counter #0 & #1: time interval measure with time-end signalled by interrupt or only TFx flag; clock interrupt; in 8-bit mode with automatic reload on f CLK =12MHz clock interrupt period up to 256  s (3,9kHz); in 16-bit mode with program reload on f CLK =12MHz clock interrupt period up to 65,5ms (15,25Hz); counting external pulses/events.; counting programmed number of pulses and interrupt request; clocking of SIO - only timer #1 !.

MCS51 - timer/counter #2 12/30 Features: 16-bit; accessible in SFR as register pair TH2-TL2; counting up; count machine cycles (timer mode) or external pulses (counter mode); 16-bit compare-capture register RCAP2H-RCAP2L; controlled by special registers in SFR; overflow (from 0FFFF to 0) sets TF2 flag, which can cause interrupt; can clock SIO;

MCS51 - timer/counter #2 13/30 Control register: TF2 CF EXF2 CE RCLK CD TCLK CC EXEN2 CB TR2 CA C/T2 C9 CP/RL2 C8 T2CON C8h TF2 - timer/counter #2 overflow flag, set by hardware after counter overflow only if bits RCLK i TCLK are cleared EXF2 - falling edge on input T2EX (P1.1) flag, acting only if bit EXEN2 =1 EXEN2 - if set enables detecting of falling edge on T2EX input for example to capture/reload counter TR2 - if set starts timer/counter #2 C/T2 - set - counter mode, cleared - timer mode CP/RL2 - set - capture mode, cleared - reload mode RCLK, TCLK - if set, TF2 flag clocks SIO receiver & transmitter if cleared, timer/counter 1 clocks SIO

MCS51 - timer/counter #2 14/30 Work with automatic capture on CP/RL2=1 TCLK=RCLK=0 OSC TL2TH2 :12 TR2 C/T2 EXEN2 TF2 T2 T2EX RCAP2LRCAP2H EXF2 0101

MCS51 - timer/counter #2 15/30 Work with automatic reload on CP/RL2=0 TCLK=RCLK=0 OSC TL2TH2 :12 TR2 C/T2 EXEN2 TF2 T2 T2EX RCAP2LRCAP2H EXF2 0101

MCS51 - timer/counter #2 16/30 Work as SIO clock on RCLK=1 or TCLK=1 OSC TL2TH2 :2 TR2 C/T2 EXEN2 TF1 T2 T2EX RCAP2LRCAP2H EXF :2 :16 RxC TxC SMOD RCLK TCLK

MCS51 - timer/counter #2 17/30 Possible applications of timer/counter #2: time interval measure with time-end signalled by interrupt or only TF2 flag; clock interrupt; 16-bit reload constant allows to achieve long period of clock interrupt; counting external pulses/events; counting programmed number of external pulses and interrupt request; independent SIO receiver & transmitter clocking; SIO clocking in wide range of frequency; measure of phenomenon duration, which begin and end are signalled by falling edge on T2EX.

MCS51 - timer/counter #2 - other modifications 18/30 Work with automatic reload & rectangular waveform output on T OSC TL2TH2 :2 TR2 C/T2 EXEN2 optional do SIO T2 T2EX 0101 RCAP2LRCAP2H EXF :2 T2OE 0101 f OUT =f OSC /4/(65536-RCAP2)

MCS51 - timer/counter #2 - other modifications 19/30 0FFh OSC TL2TH2 :12 TR2 C/T2 TF2 T2 T2EX RCAP2LRCAP2H EXF counting direction: 0 - down; 1 - up counting up: from RCAP2 value up to 0FFFFh counting down: from 0FFFFh down to RCAP2 value Work with automatic reload & switched counting direction (up/down)

MCS51 - PCA 20/30 PCA - Programmable Counter Array Features: 16-bit counter accessible in SFR as register pair CH-CL, working as common time base for 5 units; counting up; can counts: divided internal clock pulses or external pulses or timer/counter 0 output pulses; 5 16-bit compare-capture units CCAPxH-CCAPxL; each unit can work in mode: capture, timing, PWM, pulse generation; one unit can work as watch-dog; interrupt request possible;

MCS51 - PCA 21/30 Main counter structure - time base IDL CIDL ECF CR CPS0 CPS1 OSC:4 :3 ECI T0OV CLCH CF CCU #0..#4 interrupt system 0101

MCS51 - PCA 22/30 Unit in capture mode CCAPnLCCAPnH CCFn interrupt system ECCFn CEXn CAPPn CAPNn CLCH

MCS51 - PCA 23/30 Unit in timing mode CCAPnLCCAPnH CLCH 0101 MATn CCFn interrupt system ECCFn E =? EQ ECOMn write to CCAPnL write to CCAPnH RESET 0 1

MCS51 - PCA 24/30 Unit in pulse generation mode CCAPnLCCAPnH CLCH 0101 MATn CCFn interrupt system ECCFn E =? EQ ECOMn write to CCAPnL write to CCAPnH RESET TOGn CEXn

MCS51 - PCA 25/30 Unit in PWM mode CCAPnL CCAPnH CL OV PWMn CL<CCAPnL E =? CL>CCAPnL ECOMn 0101 CEXn

MCS51 - PCA 26/30 Unit #4 as watch-dog CCAP4LCCAP4H CLCH 0101 WDTE RESET E =? EQ ECOM4 write to CCAP4L write to CCAP4H RESET 0 1

MCS51 - PCA 27/30 Possible applications of PCA: parallel execution up to 5 task synchronized by common time-base counter; simultaneous, 5-channel measure of phenomenon duration.

MCS51 - CCU Philips 28/30 OSC TL2TH2 :12 T2ER T2MS1,T2MS0 T2OV T2 RT CM0 external counter clear T2P1,T2P0 :1/:2 :4/:8 T2BO CML0 CMH0 =? CML1 CMH1 CML2 CMH2 =? CM1 CM2 CTL0CTH0 CT0I CTI0 CTL1CTH1 CT1I CTI1 CTL2CTH2 CT2I CTI2 CTL3CTH3 CT3I CTI3

MCS51 - CCU Siemens 29/30 Structure of CCU in 515, 515A of Siemens CCL1+CCH1 CCL2+CCH2 CCL3+CCH3 P1 CRCL+CRCH counter T2 prescaler OSC

MCS51 - CCU Siemens 30/30 Timer #2 structure in Siemens MCU with CCU