Microprocessors Timers

Slides:



Advertisements
Similar presentations
Working with time: interrupts, counters and timers Chapter Six Dr. Gheith Abandah1.
Advertisements

م/محمد علي عطية حسين. Pin Diagram DescriptionPin Name Oscillator crystal input/external clock source input. OSC1/CLKIN Oscillator crystal output.OSC2/CLKOUT.
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.
Introduction of Holtek HT-46 series MCU
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.
Timers and Interrupts Shivendu Bhushan Summer Camp ‘13.
Timers and Interrupts Shivendu Bhushan Sonu Agarwal.
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.
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
Interrupts, Counter and Timers. Interrupts (1) Interrupt-driven I/O uses the processor’s interrupt system to “interrupt” normal program flow to allow.
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.
I/O PORTS (Simplest Peripherals) PORT A: 6 bits wide (7th and 8th bit always read as 0) PORT B: 8 bits wide PORT C: 8 bits wide PORT D: 8 bits wide.
MCU: Interrupts and Timers Ganesh Pitchiah. What’s an MCU ?
Robotraffic software and programming aids Robotics Laboratory Faculty of Mechanical Engineering Technion Israel Institute of Technology.
© 2009, Renesas Technology America, Inc., All Rights Reserved 1 Course Introduction  Purpose This course provides an introduction to the peripheral functions.
Time Measurement Capture Mode of the Capture/Compare/PWM module is used for time measurement. TMR1 or TMR3 16-bit value transferred to 16-bit capture.
CCP MODULES  The CCP module (Capture/Compare/PWM) is a peripheral which allows the user to time and control different events.  Capture Mode provides.
1 68HC11 Timer Chapter HC11 Timer Subsystem Several timing functions: Basic timing Basic timing Real time interrupts Real time interrupts Output.
Timers and Interrupts Anurag Dwivedi. Let Us Revise.
1 © Unitec New Zealand Interrupt Lecture 6 Date: - 20 Sept, 2011 Embedded Hardware ETEC 6416.
Teachers Name : Suman Sarker Telecommunication Technology Subject Name : Microcontroller & Embedded System Subject Code : 6871 Semester : 7th Department.
Architecture and instruction set. Microcontroller Core Features:  Operating speed: DC - 20 MHz clock input DC ns instruction cycle Up to 8K x.
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.
TIMERS AND INTERRUPTS AVI SINGH KEVIN JOSE PIYUSH AWASTHI.
C Examples 1. Download Links dsPIC30F4011/4012 Data Sheet dsPIC30F4013/3014 dsPIC30F Family Reference Manual MikroC MikroC Manual MikroC Quick Reference.
Features of the PIC18 microcontroller - 8-bit CPU - 2 MB program memory space (internal 32KB to 128KB) bytes to 1KB of data EEPROM - Up to 4096 bytes.
PIC16F887.
Microcontrollers session. What is Microcontroller? Microcontroller is composed of microprocessor,ram, flash memory,EEPROM and some modules like timers,
Microprocessor and Microcontroller Based Systems Instructor: Eng.Moayed N. EL Mobaied The Islamic University of Gaza Faculty of Engineering Electrical.
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.
Microprocessors A practical approach..
TIMERS.
Chapter 10 Interrupts. Basic Concepts in Interrupts  An interrupt is a communication process set up in a microprocessor or microcontroller in which:
Timer modules in PIC 16F877.  The PIC 16F877 basically has three independent timer modules,  denoted by the symbols, TIMER-0, TIMER1,andTIMER2. . These.
An Introduction to Embedded Systems, and the PIC Microcontroller Lecture 8: Interrupts The aims of this session are to explore the structure and application.
16F877A.
Chapter 9 PIC18 Timer Programming in Assembly
Why are Timer Functions Important?
Microprocessor Systems Design I
Microprocessors and Programming Department of Mechatronics Engineering
Microprocessor Systems Design I
Microprocessor Systems Design I
Microprocessor Systems Design I
Interrupts, Counter and Timers
MSP432 ARM Timer Programming
BVM Engineering College Electrical Engineering Department : Microprocessor and Microcontroller Interfacing Interrupts of 8051 Prepared by:
RX 8-Bit Timer (TMR) 4/20/2011 Rev. 1.00
EE Embedded Systems Fall 2015
The PIC uCs PIC Microcontroller and Embedded Systems Muhammad Ali Mazidi, Rolin McKinlay and Danny Causey Eng. Husam Alzaq The Islamic Uni. Of Gaza 11-1.
Pugazhendhi.M 11/12/2018 TIMERS 11/12/2018 CCET CCET.
8051 Timers / Counters It has two timers Timer 0 and Timer 1.
PIC18 Timer Programming “Explain the assembly language programming for the timer and counter module”
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
Figure CCP1 Control Register
PIC18 Interrupt Programming
PIC18 Interrupt Programming
Timers Chapter 2.
Microprocessors and Programming Department of Mechatronics Engineering
Presentation transcript:

Microprocessors Timers Syed Hussain , Muhamad Sohaib Arif and Albert Abad Microprocessors Timers COSC 524 By Albert Abad, Muhamad Sohaib Arif & Syed Hussain Timers by: Syed Hussain , Muhamad Sohaib Arif & Albert Abad Syed Hussain , Muhamad Sohaib Arif

Timers by: Syed Hussain , Muhamad Sohaib Arif & Albert Abad Timer - Physically timer is a register whose value is continually increasing up to 255... 0,1,2,3,4....255 = Total 256 • After reaching its maximum value it starts over again. • All timers are independent. Timers by: Syed Hussain , Muhamad Sohaib Arif & Albert Abad

Timers by: Syed Hussain , Muhamad Sohaib Arif & Albert Abad PIC Microcontroller has three Timers Timer 0: 8-bit register TMR0 Timer 1: 16-bit register TMR1H | TMR1L Timer 2: 8-bit register TMR2 Timers by: Syed Hussain , Muhamad Sohaib Arif & Albert Abad

Timers by: Syed Hussain , Muhamad Sohaib Arif & Albert Abad Timer 0 (TMR0) Features: 8 bit register timer. We can set the bit register by using 1 and 0 to set the instructions that we need. Programmable Prescaler Read and write. We can change instructions anytime. • Internal and External clock. Internal is the clock ticking inside the PIC that we can call anytime. External is the clock outside the PIC that we can connect to RA4 / TOCKI Interrupt on overflow from FFh to 00h Timers by: Syed Hussain , Muhamad Sohaib Arif & Albert Abad

Timers by: Syed Hussain , Muhamad Sohaib Arif & Albert Abad Prescaler in Timers To slow down a Timer that is incrementing, instead of incrementing each clock cycle it can be adjusted to every 2nd, 4th,8th .. 256. We can use this prescaler to divide our timers clock. Prescaller is set here: With assigning 0 &1 to PS2,PS1 and PS0 Timers by: Syed Hussain , Muhamad Sohaib Arif & Albert Abad

External timer is connected to RA4/TOCKI Timers by: Syed Hussain , Muhamad Sohaib Arif & Albert Abad

Timers by: Syed Hussain , Muhamad Sohaib Arif & Albert Abad Timer0 Architecture Timers by: Syed Hussain , Muhamad Sohaib Arif & Albert Abad

Timers by: Syed Hussain , Muhamad Sohaib Arif & Albert Abad How the Timer0 works: RBPU (PORTB Pull-up) 0: Port B resistors pull ups disabled. 1: Port B resistors pull ups activated. INTEDG ( RB0/INT pin Interrupt Edge) 0: The RB0/INT interrupt will occur on the falling edge of the RB0/INT pin 1: The RB0/INT interrupt will occur on the rising edge of the RB0/INT pin T0CS (Timer 0 Clock Source) 0: Timer 0 clock source is the Internal instruction cycle clock (CLKO) 1: Timer 0 clock source is the RA4/TOCKI pin T0SE (Timer 0 Source Edge) – Used for external clock 0: Incremanet on high to low 1: increment low to high PSA 0: The prescaler is assigned to the Timer 0 module (TMR0) 1: The prescaler is assigned to the Watchdog timer (WDT) PS2,PS1,PS2 Prescaler Rate Bits Timers by: Syed Hussain , Muhamad Sohaib Arif & Albert Abad

Timers by: Syed Hussain , Muhamad Sohaib Arif & Albert Abad How the Timer0 works: Set the INTCON GIE= global interrupt, T0IE= Timer0 interrupt enabler and T0IF= Timer0 interrupt flag GIE: 0 ALL ITERRUPS ARE DISABLED, 1 ALL INTERRUPTS ENABLED T0IE : 1 = Enables the TMR0 interrupt 0 = Disables the TMR0 interrupt Timers by: Syed Hussain , Muhamad Sohaib Arif & Albert Abad

Timers by: Syed Hussain , Muhamad Sohaib Arif & Albert Abad

Timers by: Syed Hussain , Muhamad Sohaib Arif & Albert Abad To measure time: Reset the TMR0 register or write some well-known value to it; banksel OPTION_REG movlw b'10000110‘ ; = 128 movwf OPTION_REG bcf PORTB,4 movlw d‘100' movwf TMR0 Example : (256-100)*128 = 20,000 = 20milli Timers by: Syed Hussain , Muhamad Sohaib Arif & Albert Abad

Timers by: Syed Hussain , Muhamad Sohaib Arif & Albert Abad Diagram for Timer 0 Timers by: Syed Hussain , Muhamad Sohaib Arif & Albert Abad

Timers by: Syed Hussain , Muhamad Sohaib Arif & Albert Abad 16 bit timer Time value is in TMR1L and TMR1H When TMR1L overflows, TMR1H starts incrementing When TMR1H overflows, the TMR1IF interrupt is enabled The interrupt can be enabled or disabled by setting or clearing TMR1IE bit in PIE1 Can also run in counter mode where it increments on every rising edge of the external clock input Timers by: Syed Hussain , Muhamad Sohaib Arif & Albert Abad

Timer1 control T1CON register U-0 R/W-0 _ T1CKPS1 T1CKPS0 T1OSCEN T1SYNC TMR1CS TMR1ON Bit 7 Bit 0 T1CKPS1:T1CKPS0: Timer1 input clock prescale select bits 11 means 1:8 prescale value while 00 means 1:0 presale value T1CKSCEN: Timer1 oscillator enable control bit T1SYNC: External clock synchronize bit 1 means do not synchronize the external clock and 0 means to synchronize the external clock TMR1CS: Timer1 clock source select bit 1 means external clock at RB6 will be used 0 means internal clock(Fosc/4) will be used TMR1ON: Timer1 on bit Timers by: Syed Hussain , Muhamad Sohaib Arif & Albert Abad

Timer1 operation in timer mode Timer mode is selected by clearing the TMR1CS. Meaning it is set to use the internal Fosc/4 source. Timer1 in counter mode Timer1 can be used in two counter modes: Synchronous and Asynchronous Both modes require an external clock inputs which we are not using in this course Timers by: Syed Hussain , Muhamad Sohaib Arif & Albert Abad

Timers by: Syed Hussain , Muhamad Sohaib Arif & Albert Abad Timer 1 Architecture Timers by: Syed Hussain , Muhamad Sohaib Arif & Albert Abad

Associated registers with Timer1 Timers by: Syed Hussain , Muhamad Sohaib Arif & Albert Abad

Using timer1 with CCP Trigger Timer1 can be used with the capture/control/PWM CCP module It has to be in either timer mode or synchronized counter mode where its value TMR1L and TMR1H are compared to CCPR1L and CCPR1H on every cycle CCP is out of scope for this presentation Timers by: Syed Hussain , Muhamad Sohaib Arif & Albert Abad

Timers by: Syed Hussain , Muhamad Sohaib Arif & Albert Abad Timer2 is an 8 bit timer with a prescaler and postscaler This can be used as the PWM time-base for the CCP module It uses the ineranal clock Fosc/4 with a prescale options of 1:1, 1:4 and 1:16 which are selected using the P2CKPS1:P2CKPS0 bits of the Timer2 control(T2CON) register The value of the timer is compared to the PR2 register and resets to 00 when it reaches PR2 The output of timer1 goes through a 4-bit postscaler before generating an interrupt Timers by: Syed Hussain , Muhamad Sohaib Arif & Albert Abad

Timers by: Syed Hussain , Muhamad Sohaib Arif & Albert Abad The prescaler and postscaler values are cleared on writes to TMR2, T2CON and device reset. The TMR2 register itself is not cleared when T2CON is writen Timers by: Syed Hussain , Muhamad Sohaib Arif & Albert Abad

Timer2 control (T2CON) register U-0 R/W-0 _ TOUTPS3 TOUTPS2 TOUTPS1 TOUTPS0 TMR2ON T2CKPS1 T2CKPS0 Bit 7 Bit 0 TOUTPS3:TOUTPS0: The postscalar select bits 0000 means 1:1 postscale, 0001 means 1:2 postscale and so on until 1111 which means 1:16 postscale TMR2ON: Timer2 on bit 1 means timer2 is on and 0 means timer2 is 0 T2CKPS1:T2CKPS0: Timer2 clock prescale select bits 00 means 1:1 prescale 01 means 1:4 prescale 1x means 1:16 prescale Timers by: Syed Hussain , Muhamad Sohaib Arif & Albert Abad

Timers by: Syed Hussain , Muhamad Sohaib Arif & Albert Abad Timer 2 Architecture Timers by: Syed Hussain , Muhamad Sohaib Arif & Albert Abad

Associated registers with Timer2 Timers by: Syed Hussain , Muhamad Sohaib Arif & Albert Abad