TIMERS AND INTERRUPTS AVI SINGH KEVIN JOSE PIYUSH AWASTHI.

Slides:



Advertisements
Similar presentations
More fun with Timer/Counters
Advertisements

Microcontroller Programming II MP6-1
MICRO-CONTROLLER: A microcontroller is the brain of the robot: These are: 1. Integrated Circuits (ICs) 2. Programmable.
EET 2261 Unit 10 Enhanced Capture Timer  Read Almy, Chapter 20.  Homework #10 and Lab #10 due next week.  Quiz next week.
Introduction of Holtek HT-46 series MCU
Mark Neil - Microprocessor Course 1 Timers and Interrupts.
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.
ATtiny2313 Timers/Counters CS-423 Dick Steflik. What Do You Use Timers For? Timing of events (internal or external)‏ Scheduling Events Measuring the width.
S. Barua – CPSC 240 CHAPTER 8 I/O How are I/O devices identified? Memory-mapped vs. special instructions.
Timers and Interrupts Shivendu Bhushan Summer Camp ‘13.
 Main Components:  Sensors  Micro controller  Motor drivers  Chasis.
Timers and Interrupts Shivendu Bhushan Sonu Agarwal.
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.
1 Timing System Timing System Applications. 2 Timing System components Counting mechanisms Input capture mechanisms Output capture mechanisms.
Input/Output mechanisms
7/23 Timers in Coldfire Processor Computer Science & Engineering Department Arizona State University Tempe, AZ Dr. Yann-Hang Lee (480)
ARM Timers.
System Clocks.
A Few Words From Dilbert
Timers ELEC 330 Digital Systems Engineering Dr. Ron Hayne
Chapter 4 TIMER OPERATION
Unit 10.2 Timer Examples. Example – Music Generation Channel 6 – Set up as a timer Output to Generate Square Waves Channel 4 – Set up as a timer Output.
Clock Options and Sleep Modes. Clock Sources Flash Fuse bits can be programmed to choose one of the following Clock sources: 1. External RC Osc. f = 1/(3RC).
The 8253 Programmable Interval Timer
MICROPROCESSOR INPUT/OUTPUT
MCU: Interrupts and Timers Ganesh Pitchiah. What’s an MCU ?
Lecture 11 Low Power Modes & Watchdog Timers
ELE22MIC Lecture 18 The AVR Sleep Modes The ATMEGA128’s Timer System
Timer Timer is a device, which counts the input at regular interval (δT) using clock pulses at its input. The counts increment on each pulse and store.
1 68HC11 Timer Chapter HC11 Timer Subsystem Several timing functions: Basic timing Basic timing Real time interrupts Real time interrupts Output.
ATtiny23131 A SEMINAR ON AVR MICROCONTROLLER ATtiny2313.
Timers and Interrupts Anurag Dwivedi. Let Us Revise.
1 © Unitec New Zealand Interrupt Lecture 6 Date: - 20 Sept, 2011 Embedded Hardware ETEC 6416.
CS-280 Dr. Mark L. Hornick 1 Atmel Timer/Counter System Most microcontrollers include some type of timer system Facilitates real-time monitoring and control.
1 Interrupts, Resets Today: First Hour: Interrupts –Section 5.2 of Huang’s Textbook –In-class Activity #1 Second Hour: More Interrupts Section 5.2 of Huang’s.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
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.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
I NTRODUCTION TO PIC PROGRAMMING By : S HERIF H ARHASH.
Chapter 5 - Interrupts.
Interrupt On a very basic level, an interrupt is a signal that interrupts the current processor activity. It may be triggered by an external event (change.
بسم الله الرحمن الرحيم MEMORY AND I/O.
#1 of 10 Tutorial Introduction PURPOSE -To explain how to configure and use the Timer Interface Module in common applications OBJECTIVES: -Identify the.
C Examples 6. Download Links MPLAB IDE dsPIC30F4011/4012 Data Sheet dsPIC30F Family Reference Manual MikroC MikroC Manual MikroC Quick Reference.
Interrupts and Exception Handling. Execution We are quite aware of the Fetch, Execute process of the control unit of the CPU –Fetch and instruction as.
EET 2261 Unit 13 Enhanced Capture Timer
Why are Timer Functions Important?
Basic Computer Organization and Design
ECE 3430 – Intro to Microcomputer Systems
ECE 3430 – Intro to Microcomputer Systems
Interrupts and signals
Analog Comparator An analog comparator is available on pins PE2(AIN0), PE3(AIN1) The comparator operates like any other comparator. -when (+) exceeds (-)
BRX Technical Training
Timer and Interrupts.
BITS EDU. CAMPUS , VARNAMA
AVR Addressing Modes Subject: Microcontoller & Interfacing
RX 8-Bit Timer (TMR) 4/20/2011 Rev. 1.00
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.
Timer/Counter Modified from Dr. Lam Phung’s Slides.
8-bit Timer/Counter0 with PWM
ATmega103 Timer0 and Interrupts
8-bit Timer/Counter2 with PWM and Asynchronous Operation
Interrupt Source: under
Lecture 12 Multi-Function Timer Pulse Unit 2 (MTU2a)
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
Presentation transcript:

TIMERS AND INTERRUPTS AVI SINGH KEVIN JOSE PIYUSH AWASTHI

RECAP Small computer Integrated in an single IC MCU Has I/O, Ram & Memory

REGISTERS DDR Decides whether pin is INPUT or OUTPUT PORT Used to specify the output value PIN Used to read the input value

SOFTWARE NEEDED CVAVR AVR STUDIO Extreme Burner AVR

TIMERS 8-bit register. Values starts from 0 and goes up to 255. Timer value increases by 1,after each period. (The standard issue MCU for Techkriti ‘15 will be Atmega16 which has a 16-bit clock register also. We will cover the theory of timer wrt 8 bit registers for the sake of clarity and ease of representation but all that is subsequently discussed can be applied to 16 bit registers with little or no modification) When the timer reaches its maximum value, in the next cycle, its value becomes 0 again and the process repeats itself. The timer frequency can be factors of the base frequency of the MCU. This process is independent of the CPU. t = 0T t = 1T t = 2T t = 255T t = 256T

SIMPLE STATISTICS Maximum value of timer is n and clock period is t, then: 1. Timer period = t 2. Timer cycle period = (+1)× 3. Frequency of timer (f) = 1/ 4. Frequency of timer cycle = 1/(+1)×

TIMER MODES A timer works in three modes: Normal, CTC and PWM Normal mode: Timer starts at zero, goes to maximum value and then resets itself CTC (Clear Timer on Compare), clearly the timer starts at zero as usual, but instead of resetting after maximum value, it resets after reaching value specified in OCR register PWM(Pulse Width Modulation) can be used to obtain analog values at the pins

SUPPOSE YOU NEED TO CHECK FOR A CONDITION A WHILE RUNNING ANOTHER CONDITION B while(1){ > if (Event A == true) > // print event A has occurred > Event B ---- } Do you see the problem in this approach?? -> Suppose Event A happens here

A BETTER SOLUTION: INTERRUPT Interrupts means causing a break in a continuing process. We execute the Event B in a normal while(1) loop.. while(1){ --- EVENT B --- }. We will consider the occurrence of event A as an interrupt

INTERRUPTS. while(1){ --- EVENT B --- }. handleA(){. --- } We execute the required code in handler of event A // print event A has occurred

MORE ON INTERRUPTS Interrupts are special events that can “interrupt” the normal flow of a program. Whenever an Interrupt is called, the processor stops the normal program, handles the interrupt, and then resumes its normal work. There are two types of interrupts: 1. External 2. Internal

EXTERNAL INTERRUPTS The controller monitors the input at the special pins INT0 and INT1, whenever external interrupt is set on. We can configure the program to call an external interrupt whenever any of the following conditions are met. Rising Edge Falling Edge Any change Low level

INTERNAL INTERRUPTS The internal interrupts are called when different specific conditions are met by the timer value. Timers can generate certain interrupts: two, to be precise. These are called OVERFLOW interrupt and COMPARE MATCH interrupt.

OVERFLOW INTERRUPTS An overflow interrupt is generated when the timer exceeds its maximum value and resets to 0. The interrupt may or may not have a handler. In either case, the timer continues to run; remember: timers are independent of the CPU. Suppose a timer of maximum value n has a time period t (also called as clock period). Then : 1. Timer cycle frequency = 1/(+1)× 2. OVERFLOW interrupt frequency = 1/(+1)× If OVERFLOW interrupt is enabled, then an interrupt is generated in every cycle.

COMPARE MATCH INTERRUPT A compare match interrupt is called when the value of the timer equals a specific value, set by the user. This value is set by setting the value of OCR register. Before incrementing, the value of the timer is compared to OCR. If the two are equal, a COMPARE MATCH interrupt is generated. Suppose a timer of maximum value n has a time period t (also called as clock period). Then : 1. Timer cycle frequency = 1/(+1)× 2. COMPARE MATCH interrupt frequency = 1/(+1)× If COMPARE MATCH interrupt is enabled, then an interrupt is generated in every cycle.

INTERRUPTS: OVERFLOW AND COMPARE MATCH

TIMERS AND INTERRUPTS All three timer modes differ in the response of the controller to the interrupts generated OVERFLOW and COMPARE MATCH interrupts generated as normal in NORMAL timer mode Compare match interrupt if enabled will be generated but not overflow interrupt (Why?)

ACCELEROMETER For Electromania this year, the standard issue board will be one based on an Analog 3-Axis MEMS Accelerometer Poll values using Analog Input pins and scale appropriately to acquire the acceleration due to gravity on each axis and hence orientation Refer to the datasheet for scaling information

CONTACT US Avi Singh A-129 / Hall Kevin Jose 366 / Hall Piyush Awasthi 150/Hall