Timers Chapter 2.

Slides:



Advertisements
Similar presentations
The 8051 Microcontroller and Embedded Systems
Advertisements

More fun with Timer/Counters
ECT 357 Ch 16 Output Control. Today’s Quote: The measure of a man is not how great his faith is bt how great his love is. The measure of a man is not.
The PIC uCs PIC Microcontroller and Embedded Systems Muhammad Ali Mazidi, Rolin McKinlay and Danny Causey Eng. Husam Alzaq The Islamic Uni. Of Gaza 9-1.
5-1 Timer/Counters In many microprocessor systems we need to:  count logic pulses  measure the frequency of signals  measure the period of pulses 
Taking timing further Chapter Nine 9.1 – 9.8 Dr. Gheith Abandah1.
Today’s Lecture List the Timers of PIC18 and their associated registers Describe the various modes of the PIC18 timers Program the PIC18 timers in Assembly.
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).
7/23 Timers in Coldfire Processor Computer Science & Engineering Department Arizona State University Tempe, AZ Dr. Yann-Hang Lee (480)
Timer/counter Chapter 12
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
Timers The timers of the PIC16C7X microcontroller can be briefly described in only one sentence. There are three completely independent timers/counters.
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.
© 2009, Renesas Technology America, Inc., All Rights Reserved 1 Course Introduction  Purpose This course provides an introduction to the peripheral functions.
CCP MODULES  The CCP module (Capture/Compare/PWM) is a peripheral which allows the user to time and control different events.  Capture Mode provides.
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.
Saxion University of Applied Sciences Advanced Microcontrollers A practical approach.
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.
C Examples 1. Download Links dsPIC30F4011/4012 Data Sheet dsPIC30F4013/3014 dsPIC30F Family Reference Manual MikroC MikroC Manual MikroC Quick Reference.
#1 of 10 Tutorial Introduction PURPOSE -To explain how to configure and use the Timer Interface Module in common applications OBJECTIVES: -Identify the.
Microcontrollers session. What is Microcontroller? Microcontroller is composed of microprocessor,ram, flash memory,EEPROM and some modules like timers,
C Examples 6. Download Links MPLAB IDE dsPIC30F4011/4012 Data Sheet dsPIC30F Family Reference Manual MikroC MikroC Manual MikroC Quick Reference.
Special Features. Device Configuration bits Revision Device Configuration bits Revision On-chip Power-on Reset (POR) Revision On-chip Power-on Reset (POR)
One more PIC18F252 example and revision for exam B222L Branislav Vuksanovic, UoP, ECE.
Microcontrollers BME 201. Overview Microcontrollers Notation Registers Timer Concepts Equations.
TIMERS.
Timer modules in PIC 16F877.  The PIC 16F877 basically has three independent timer modules,  denoted by the symbols, TIMER-0, TIMER1,andTIMER2. . These.
16F877A.
Chapter 9 PIC18 Timer Programming in Assembly
Why are Timer Functions Important?
V.V.P. ENGINEERING COLLEGE,RAJKOT
Chapter 10 PIC18 Serial Port Programming in Assembly
8051 Timers Timers are the peripherals of the 8051 Microcontroller.
Timer Source: under
Programmable Interval Timer
Programmable Interval Timer
Microprocessors Timers
RX 8-Bit Timer (TMR) 4/20/2011 Rev. 1.00
Timer Operations and Programming
EMT 348: Microcontroller Timer/counter
8051 Timers Prof. Rajiv R Bhandari.
Pugazhendhi.M 11/12/2018 TIMERS 11/12/2018 CCET CCET.
Timer.
Serial Communication Interface
8051 Timers / Counters It has two timers Timer 0 and Timer 1.
Programmable Interval timer 8253 / 8254
Timer Source: under
Interrupt Source: under
PIC18 Timer Programming “Explain the assembly language programming for the timer and counter module”
Programmable Interval timer 8253 / 8254
UNIT 19 PWM 로봇 SW 교육원 조용수.
Lecture 12 Multi-Function Timer Pulse Unit 2 (MTU2a)
Figure CCP1 Control Register
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.
PIC18 Interrupt Programming
MCO556 Timer System Exercise.
Programmable Interval Timer
PIC18 Interrupt Programming
Presentation transcript:

Timers Chapter 2

Objectives Upon completion of this chapter, you will be able to: List the timers of the PIC18 and their associated registers Describe the various modes of the PIC18 timers Program the PIC18 counters in C as event counters

Timer0 16-bit wide Consists of a low-byte (TMR0L) and a high-byte (TMR0H) register Can be used as 8-bit or 16-bit timer Low byte (8-bit) High byte (8-bit)

Timer0 (cont’d) Important Registers: i) T0CON (Timer0 Control Register) To start & stop Timer0 and other configurations ii) TMR0H:TMR0L (for counting purposes) Act as counting buffer iii) INTCON (Interrupt Control Register) D0 D7

T0CON (Timer0 Control) Register

Example 1 What is the value of T0CON if the Timer0 settings are as below ? 16-bit timer No pre-scaler Internal clock (from oscillator) source Increment on positive-edge Answer: T0CON = 00001000

Example 2 Calculate the amount of time delay generated by the Timer0 with the following specification: XTAL = 10MHz TMR0H:TMR0L = FFF2H Solution: TCY = 4/10MHz = 0.4us (Each tick consume 0.4us) How many tick? (FFFF-FFF2) + 1 = 14 ticks Time delay = 14 x 0.4us = 5.6us FFF2 FFF3 FFF4 FFFE FFFF 0000 TMR0IF=0 TMR0IF=1 1 2 14 13

Example 3 Write a C program to toggle all the bits of PORTB continuously with 1ms delay. Use Timer0, 16-bit mode, no prescaler options to generate the delay. (Assume XTAL=20MHz) Solution: TCY = 4/20MHz = 0.2us (Each tick consume 0.2us) How many ticks in 1ms delay? 1ms/0.2us = 5000 ticks = 1388H ticks! To find register value for TMR0H:TMR0L FFFF - register value + 1 = 1388H ticks register value = EC78H @ Simply take the negative value of the tick counts -1388H = EC78H This is much more easier!

Example 3 (cont’d)

Exercise 1 Write a C program to toggle only the PORTB.4 bit continuously every 50ms. Use Timer0, 16-bit mode and the 1:4 prescaler to create the delay. (Assume XTAL = 20MHz) Solution: TCY = 4/20MHz = 0.2us (Each tick consume 0.2us) How many ticks in 50ms delay? 50ms/0.2us = 250000 ticks = 3D090H ticks! (out of range!!) With 1:4 prescaller 250000/4 = 62500 ticks = F424H ticks! Therefore, register counts = -F424H = 0BDCH

Exercise 1 (cont’d)

Timer1 16-bit wide Consists of a low-byte (TMR1L) and a high-byte (TMR1H) register Can be used as 16-bit timer only! Low byte (8-bit) High byte (8-bit)

Timer1 (cont’d) Important Registers: i) T1CON (Timer1 Control Register) To start & stop Timer1 and other configurations ii) TMR1H:TMR1L (for counting purposes) Act as counting buffer iii) PIR1 (Peripheral Interrupt Request Register 1) D7

T1CON (Timer1 Control) Register

Exercise 2 Write a C program to create pulses with a frequency of 2500Hz with 50% duty cycle on pin PORTB.1. Use Timer1 to create the delay. (Assume XTAL = 20MHz) Solution: T = 1/2500 = 400us (HIGH: 200us; LOW: 200us) How many ticks in 200us delay? 200us/0.2us = 1000 ticks = 03E8H ticks! Therefore, register counts = - 03E8H = FC18H

Exercise 2 (cont’d)

Exercise 2 (cont’d) Approx.1000 ins. cycles Approx.1000 ins. cycles

Timer0 & Timer1 as Counter Can used as Counters Counter0 (Timer0 counter): Count pulses on T0CKI (RA4) pin Counter1 (Timer1 counter): Count pulses on T13CKI (RC0) pin

Example - Counter Please refer Example 9-35, 9-36 & 9-37 in the textbook

Timer2 8-bit wide Consists of a PR2 (Period Register 2) TMR2 will increment from 00 until reaches PR2 value before TMR2IF flag is set Consists of prescaler and postscaler No counter function

Timer2 (cont’d) Important Registers: i) T2CON (Timer2 Control Register) To start & stop Timer2 and other configurations ii) PR2 (to set the counting value) If TMR2 = PR2; TMR2IF flag is set iii) PIR1 (Peripheral Interrupt Request Register 1) D7

Timer2 (cont’d)

Timer3 16-bit wide Consists of a low-byte (TMR3L) and a high-byte (TMR3H) register Enable the CCP Mode for PWM Application

Timer3 (cont’d) Important Registers: i) T3CON (Timer3 Control Register) To start & stop Timer3 and other configurations ii) TMR3H:TMR3L (for counting purposes) Act as counting buffer iii) PIR2 (Peripheral Interrupt Request Register 2)

Timer3 (cont’d)

End of Chapter 2 Assignment Timer