Timers and Event Counters

Slides:



Advertisements
Similar presentations
Jordan Barry Victor Brzeski
Advertisements

More fun with Timer/Counters
Microcontroller Programming II MP6-1
Module 4: Analog programming blocks. Module Objectives Analyze a control task that uses analog inputs. Connect a potentiometer to LOGO! controller and.
Drives & Control June 2003 A. Jansen 1 Brushless DC Motor Control with C868 and CAPCOM6.
Introduction of Holtek HT-46 series MCU
COMP3221: Microprocessors and Embedded Systems Lecture 20: Analog Output Lecturer: Hui Wu Session 2, 2004.
Timers and Interrupts Shivendu Bhushan Summer Camp ‘13.
Electronic Instrumentation 1 Experiment 7 Digital Logic Devices and the 555 Timer Part A: Basic Logic Gates Part B: Flip Flops Part C: Counters Part D:
Micromouse Meeting #3 Lecture #2 Power Motors Encoders.
Indian Institute of Technology Hyderabad CONTACTLESS TACHOMETE R Group members: Moruboyina Alekhya Kodi Padmasree D.Hima Varsha.
T IMERS - 2. O UTPUT U NIT Each capture/compare block contains an output unit. The output unit is used to generate output signals such as PWM signals.
1 Timing System Timing System Applications. 2 Timing System components Counting mechanisms Input capture mechanisms Output capture mechanisms.
Module 4: Analog programming blocks. Module Objectives Analyze a control task that uses analog inputs. Connect a potentiometer to LOGO! controller and.
7/23 Timers in Coldfire Processor Computer Science & Engineering Department Arizona State University Tempe, AZ Dr. Yann-Hang Lee (480)
ARM Timers.
System Clocks.
Timers and Event Counters
Timer Peripherals.
AT91 Embedded Peripherals
MCU: Interrupts and Timers Ganesh Pitchiah. What’s an MCU ?
1 ARM University Program Copyright © ARM Ltd 2013 Timer Peripherals.
SIGMA-DELTA ADC SD16_A Sigma-Delta ADC Shruthi Sujendra.
CS 478: Microcontroller Systems University of Wisconsin-Eau Claire Dan Ernst Hybrid I/O – Pulses.
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 Lecture on Lab 6 Lab 7 Lab 8. 2 Lab 6: Open Loop Controller As you learned in lab 5, there are two kinds of control systems: open loop and closed loop.
CCP MODULES  The CCP module (Capture/Compare/PWM) is a peripheral which allows the user to time and control different events.  Capture Mode provides.
© 2008, Renesas Technology America, Inc., All Rights Reserved 1 Course Introduction Purpose This course provides an overview of the standard peripheral.
Embedded Systems Design: A Unified Hardware/Software Introduction 1 Chapter 4 Standard Single Purpose Processors: Peripherals.
Automatic accident avoiding system PROJECT MEMBERS MUTHUKUMAR.K (05ME33) SAKTHIDHASAN.S (05ME39) SAKTHIVEL.N (05ME40) VINOTH.S (05ME56) PROJECT GUIDE:
The Cortex-M3 Embedded Systems: LM3S9B96 Microcontroller – Pulse Width Modulator (PWM) Refer to Chapter 21 in the reference book “Stellaris® LM3S9B96 Microcontroller.
Electronic. Analog Vs. Digital Analog –Continuous –Can take on any values in a given range –Very susceptible to noise Digital –Discrete –Can only take.
© 2009, Renesas Technology America, Inc., All Rights Reserved 1 Course Introduction  Purpose This course provides an introduction to the peripheral functions.
1 Timers and Event Counters Lecture In These Notes... We learn the basics of the Timer/Counter peripheral –Called timers by Renesas We examine how.
Network and Systems Laboratory nslab.ee.ntu.edu.tw.
ATV INSTRUMENTATION DISPLAY System Design Ed Raezer Senior Project Western Washington University.
1. PIC ADC  PIC18F877 has 8 analog input channels i.e. port A pins(RA0 to RA5) and port E pins(RE1 and RE2). These pins are used as Analog input pins.
-AT91SAM7X256 – Pulse Width Modulation YoonMo Yeon
Electronic Devices and Circuit Theory
Application Case Study Christmas Lights Controller
RASH DRIVING WARNING SYSTEM FOR HIGHWAY POLICE
SENSORS.
Why are Timer Functions Important?
UP AND DOWN CONTROLLED SPEED OF DC MOTOR IN EMBEDDED SYSTEM
Application Case Study Security Camera Controller
LED LAMP DIMMER CIRCUIT
ECE 3430 – Intro to Microcomputer Systems
PWM and DC Motor Control
555 Timer EEE DEPARTMENT KUMPAVAT HARPAL( )
EMBEDDED SYSTEMS Unit 3.
Timer and Interrupts.
Microcontroller Applications
Chapter 13 Linear-Digital ICs
4-Integrating Peripherals in Embedded Systems
BITS EDU. CAMPUS , VARNAMA
8051 Timers Timers are the peripherals of the 8051 Microcontroller.
4-Integrating Peripherals in Embedded Systems
AVR Addressing Modes Subject: Microcontoller & Interfacing
AQA GCSE 7 Electronic systems processing Design and Technology 8552
PWM BASED SPEED CONTROL FOR DC MOTOR
Pulse Width Modulation (PWM) Motor Feedback - Shaft Encoder
RX 8-Bit Timer (TMR) 4/20/2011 Rev. 1.00
SUBMITTED BY EDGEFX TEAM
8-bit Timer/Counter0 with PWM
ECE 3430 – Intro to Microcomputer Systems
Introduction to Microprocessors and Microcontrollers
Programmable Interval timer 8253 / 8254
Programmable Interval timer 8253 / 8254
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 Event Counters Embedded Systems

In These Notes . . . We learn the basics of the Timer/Counter peripheral Called timers by Renesas We examine how to set up the timers for different operation: Timer mode Event counting mode Pulse Width Modulation (PWM) mode One-shot timer mode We then examine how to use a microcontroller in these modes Embedded Systems

Timer/Counter Introduction Current Count Reload Value Presettable Binary Counter Events Reload or ÷2 or RS PWM Clock Interrupt Common peripheral for microcontrollers Based on pre-settable binary counter, enhanced with configurability Count value can be read and written by MCU Count direction can often be set to up or down Counter’s clock source can be selected Counter mode: count pulses which indicate events (e.g. odometer pulses) Timer mode: clock source is periodic, so counter value is proportional to elapsed time (e.g. stopwatch) Counter’s overflow/underflow action can be selected Generate interrupt Reload counter with special value and continue counting Toggle hardware output signal Stop! Embedded Systems

Timer A Block Diagram Each timer has one input, which is selectable from several different sources. Embedded Systems

High-Level Timer A Block Diagram Timer A devices will be the most frequently used Flexible – can be cascaded to create larger timers (i.e. 32 bits long) Embedded Systems

Timer A Mode Register To use the timer, you must set up how you wish to use it (i.e. via TA0MR). After that, the mode register has different settings depending on bits 1 and 0. Embedded Systems

Timer A “Data” Register Embedded Systems

Count Start Register Once the timer has been loaded with a value, start it counting. Embedded Systems

Counter Mode Count pulses representing events Odometer example Measure total distance your car has traveled Events are wheel rotations, measured with magnetic sensors (dirt-proof!) Distance traveled = counter value * 100.53” Assume 16” tire radius. Tire circumference = 2pr = 100.53” Will limited range of 16 bit counter be a problem? 100.53” * 216-1 = 1247.78 miles Yes. So need to extend range in software. Enable overflow interrupt for the timer Create an ISR to count overflows Embedded Systems

TAiMR in Event Counting Mode Embedded Systems

Up/Down Flag The default is that the timer will count down. Embedded Systems

Trigger Select Register You can set the trigger pulse of Timers A1 to A4 Embedded Systems

Example – Setting-up Event Mode #define TIME_CONFIG 0x01 /* 00000001 val to load into timer mode reg ||||||||_ TMOD0,TMOD1: EVENT COUNTR MODE ||||||____ MR0: NO PULSE OUTPUT |||||_____ MR1: COUNT FALLING EDGES ||||_______MR2: USE UP/DOWN FLAG |||_______ MR3: = 0 IN EVENT COUNTER MODE ||________ TCK0: RELOAD TYPE |__________TCK1: BIT NOT USED */ #define CNTR_IPL 0x03 // TA2 priority interrupt level #define LED p7_2 // LED port on MSV1632 board #define LED_PORT_DIRECTION pd7_2 // LED port dirn on MSV1632 board void init() { ta2 = 100; //e.g for an automated packaging line, 100 items per case // the following procedure for writing an Interrupt Priority Level follows // that as described in the M16C data sheets under 'Interrupts' _asm (" fclr i") ; // turn off interrupts before modifying IPL ta2ic |= CNTR_IPL; // use read-modify-write instruction to write IPL ta2mr = TIME_CONFIG; _asm (" fset i"); ta2s = 1; //start counting } Embedded Systems

TAiMR in Timer Mode Embedded Systems

Example – Timer & Event Mode The maximum amount of time one can count using two timers is: Cascade Timer A0 to Timer A1 Use the 1/32 clock (bits 7 and 6 of TA0MR set to ’10’) Set both timer values to xFFFF Timer A1 output generates an interrupt This would create a timer event which would interrupt the CPU every ______ seconds (almost __ hours!) Embedded Systems

Pulse-Width Modulation Often need to generate an analog value: motor speed, servo motor position, incandescent light dimmer, adj. switch-mode power supply Analog circuits have some disadvantage Generating the voltage accurately – circuits drift with temperature and time Analog power amplifiers are inefficient (P = E*I) Analog signals are much more sensitive to noise than digital signals PWM provides a digital encoding of an analog value Now circuits are digital: more efficient, less sensitive to noise, temperature, aging effects PWM signal characteristics Modulation frequency – how many pulses occur per second (fixed) Period – 1/(modulation frequency) On-time – amount of time that each pulse is on (asserted) Duty-cycle – on-time*period Adjust on-time (hence duty cycle) to create encoded analog value Embedded Systems

Pulse-Width Modulation We rely on low-pass filtering to “decode” (convert) this high-frequency PWM signal to an analog DC value Variable speed motor control: Motor has inertia (will coast if power is turned off) Incandescent Lamp Dimmer: Human eye has persistence of vision (retina averages signals above 30 Hz), and filament takes time to cool down and stop emitting visible light Adjustable switch-mode power supply: Rely on inductor and capacitor to maintain current and voltage when not drawing current from battery Many Timer/Counter peripherals can also generate PWM signal For example Count up Set PWM output when counter value reaches 0 Reset PWM output when counter value reaches n When counter reaches 11.111, overflow and continue counting Read Michael Barr’s Embedded Systems Programming article “Pulse Width Modulation” for more PWM information Embedded Systems

Timer A PWM Description Embedded Systems

Timer A Mode Register for PWM Embedded Systems

One-Shot Flag Embedded Systems