EECS 373: Design of Microprocessor-Based Systems Timers, count, capture and PWM Some material from Thomas Schmid, Mark Brehob.

Slides:



Advertisements
Similar presentations
MOTION CONTROL ECE 105 Industrial Electronics Engr. Jeffrey T. Dellosa College of Engineering and Information Technology Caraga State University Ampayon,
Advertisements

More fun with Timer/Counters
Lecture 9: D/A and A/D Converters
Introduction of Holtek HT-46 series MCU
1 EECS 373 Design of Microprocessor-Based Systems Prabal Dutta University of Michigan Lecture 8: Clocks, Counters, Timers, Capture, and Compare September.
1 Autonomously Controlled Vehicles with Collision Avoidance Mike Gregoire Rob Beauchamp Dan Holcomb Tim Brett.
A look at interrupts What are interrupts and why are they needed in an embedded system? Equally as important – how are these ideas handled on the Blackfin.
ATtiny2313 Timers/Counters CS-423 Dick Steflik. What Do You Use Timers For? Timing of events (internal or external)‏ Scheduling Events Measuring the width.
Timers and Interrupts Shivendu Bhushan Summer Camp ‘13.
Digital I/O Connecting to the Outside World
Digital to Analog Converters
Micromouse Meeting #3 Lecture #2 Power Motors Encoders.
Engineering 1040: Mechanisms & Electric Circuits Fall 2011 Introduction to Embedded Systems.
1 Physical Clocks need for time in distributed systems physical clocks and their problems synchronizing physical clocks u coordinated universal time (UTC)
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.
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.
ENGR 6806 – Motor Control Prepared By: Rob Collett September 15, Office: EN2074.
ENEE 440 Chapter Timer 8254 Register Select The 8254 timer is actually 3 timers in one. It is an upgraded version of the 8253 timer which was.
7/23 Timers in Coldfire Processor Computer Science & Engineering Department Arizona State University Tempe, AZ Dr. Yann-Hang Lee (480)
ARM Timers.
8254 SOFTWARE PROGRAMMABLE TIMER/COUNTER
Teachers Name : Suman Sarker Telecommunication Technology Subject Name : Microcontroller & Embedded System Subject Code : 6871 Semester : 7th Department.
DLS Digital Controller Tony Dobbing Head of Power Supplies Group.
MCU: Interrupts and Timers Ganesh Pitchiah. What’s an MCU ?
CS 478: Microcontroller Systems University of Wisconsin-Eau Claire Dan Ernst Hybrid I/O – Pulses.
IT253: Computer Organization
1 EECS 373 Design of Microprocessor-Based Systems Mark Brehob University of Michigan Lecture 6: Interrupts Sept. 19 th 2013 Slides developed in part by.
Astable Multivibrators ©Paul Godin Created February 2007 Modified March 2015 Oscillator Basics Technician Series.
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.
STEPPER MOTORS Name: Mr.R.Anandaraj Designation: Associate. Professor Department: Electrical and Electronics Engineering Subject code :EC 6252 Year: II.
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.
Time Management.  Time management is concerned with OS facilities and services which measure real time, and is essential to the operation of timesharing.
Astable Multivibrators ©Paul Godin Created February 2007 Oscillator Basics.
Lecture 16: Digital to Analog Converter - PWM Implementation
By Tony Hoff ECE 4220 – Real Time Embedded Computing University of Missouri - Columbia Course Instructor: Dr. Guiherme DeSouza.
CHAPTER 19 Data Conversion. Objectives Describe and Analyze: Analog vs. Digital Signals Resolution Digital-to-Analog Conversion Analog-to Digital Conversion.
Embedded Systems Design: A Unified Hardware/Software Introduction 1 Chapter 4 Standard Single Purpose Processors: Peripherals.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
The Cortex-M3 Embedded Systems: LM3S9B96 Microcontroller – Pulse Width Modulator (PWM) Refer to Chapter 21 in the reference book “Stellaris® LM3S9B96 Microcontroller.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Network and Systems Laboratory nslab.ee.ntu.edu.tw.
Lecture 4 General-Purpose Input/Output NCHUEE 720A Lab Prof. Jichiang Tsai.
CSE466 - Fall What is an Embedded System  Its not a desktop system  Fixed or semi-fixed functionality (not user programmable)  Lacks some or.
Time Management.  Time management is concerned with OS facilities and services which measure real time.  These services include:  Keeping track of.
Time Sources and Timing David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis St. Louis, MO
1 4-Integrating Peripherals in Embedded Systems (cont.)
Seth Schwiethale James Crosetto James Ellison.  square pulse of ms, repeats every 20 ms  It is the same for both steering and acceleration 
Closed Loop Temperature Control Circuit with LCD Display Mike Wooldridge ECE 4330 Embedded Systems.
Networked Embedded Systems Pengyu Zhang & Sachin Katti EE107 Spring 2016 Lecture 4 Timers and Interrupts.
1 4-Integrating Peripherals in Embedded Systems (cont.)
Module 8 Tutorial  An 8086 system is used for controlling the speed of a motor. The motor can operate at 5 different speeds (1- 5).  The speed.
-AT91SAM7X256 – Pulse Width Modulation YoonMo Yeon
Timers and Event Counters
Networked Embedded Systems Sachin Katti
Homework Reading Machine Projects Labs
Counters Next, we’ll look at different kinds of counters and discuss how to build them. These are not only examples of sequential analysis and design,
AVR Addressing Modes Subject: Microcontoller & Interfacing
Time Sources and Timing
ECE 3430 – Intro to Microcomputer Systems
EECS 373 Design of Microprocessor-Based Systems Mark Brehob
EECS 373: Design of Microprocessor-Based Systems
Counters Next, we’ll look at different kinds of counters and discuss how to build them. These are not only examples of sequential analysis and design,
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.
Wireless Embedded Systems
Timer/Counter Timer/Counter 0 Timer/Counter 1 Timer/Counter 2 8 bit
Counters Next, we’ll look at different kinds of counters and discuss how to build them. These are not only examples of sequential analysis and design,
What’s the Time? Geoff Huston APNIC.
Presentation transcript:

EECS 373: Design of Microprocessor-Based Systems Timers, count, capture and PWM Some material from Thomas Schmid, Mark Brehob

Announcements HW1/Proj1 Status? Ira Glass:

Today Background on time and clocking on a processor SmartFusion clocks and features How we use timers Design of a memory-mapped Pulse-Width Modulation (PWM) circuit.

Time in Embedded Systems: Where do we need accurate time? Scheduling of computation – Scheduler in operating systems – Real time operating systems Signal sampling and generation – Audio sampling at 44.1 kHz – TV/video generation (sync, vsync) – Pulse Width Modulated (PWM) signals Communication – Media Access Control (MAC) protocols – Modulation Navigation – GPS

Fine grain motion control

Clock generation and use Resonating element/Driver: – Quartz crystal can be made to resonate due to Piezoelectric effect. Resonate frequency depends on length, thickness, and angle of cut. Issues: Very stable (<100ppm) but not all frequencies possible. – MEMS Resonator Arbitrary frequency, potentially cheap, susceptible to temperature variations. – Others: Inverter Ring, LC/RC circuits, Atomic clock, and many more.

Clock Driver

SmartFusion Clock Hierarchy Original figure from

MSS clock Configurator

Timers on the SmartFusion

SysTick Timer – ARM requires every Cortex-M3 to have this timer – Essentially a 24-bit down-counter to generate system ticks – Has its own interrupt – Clocked by FCLK with optional programmable divider See Actel SmartFusion MSS User Guide for register definitions

Timers on the SmartFusion

Timers on the SmartFusion System timer – “The System Timer consists of two programmable 32-bit decrementing counters that generate interrupts to the ARM® Cortex™-M3 and FPGA fabric. Each counter has two possible modes of operation: Periodic mode or One-Shot mode. The two timers can be concatenated to create a 64-bit timer with Periodic and One-Shot modes. The two 32-bit timers are identical”

Features of Timers a.k.a. “terms you need to know” Time is kept in the hardware counter – Resolution: How often the hardware counter is updated. – Precision: The smallest increment the software can read the counter. – Accuracy: How close we are to UTC – Range: The counter reads a value of (f*t) mod 2 n. Range is the biggest value we can read. UTC is Coordinated Universal Time (French is Temps Universel Coordonné). I just work here…

Who cares? There are two basic activities one wants timers for: – Measure how long something takes “Capture” – Have something happen every X time period. “Compare”

Example #1 -- Capture FAN – Say you have a fan spinning and you want to know how fast it is spinning. One way to do that is to have it throw an interrupt every time it completes a rotation. Right idea, but might take a while to process the interrupt, heavily loaded system might see slower fan than actually exists. This could be bad. – Solution? Have the timer note immediately how long it took and then generate the interrupt. Also restart timer immediately. Same issue would exist in a car when measuring speed of a wheel turning (for speedometer or anti-lock brakes).

Example #2 -- Compare Driving a DC motor via PWM. – Motors turn at a speed determined by the voltage applied. Doing this in analog land can be hard. – Need to get analog out of our processor – Need to amplify signal in a linear way (op-amp?) Generally prefer just switching between “Max” and “Off” quickly. – Average is good enough. – Now don’t need linear amplifier—just “on” and “off”. (transistor) – Need a signal with a certain duty cycle and frequency. That is % of time high.

Bonus slides

Timers and clock division Real quick define: – Duty cycle – PWM – Resolution – Range – Precision – Prescalar – “Capture” – “Compare” Using high-level devices, draw a circuit which takes in a 100MHz clock with a 10% duty cycle and generates a 5MHz clock with 50% duty cycle. How are these two topics related? We can use timers to divide clocks. Timers _are_ just counters.

Virtual timers You never have enough timers. – Never. So what are we going to do about it? – How about we handle in software?

Virtual Timers Simple idea. – Maybe we have 10 events we might want to generate. Just make a list of them and set the timer to go off for the first one. – Do that first task, change the timer to interrupt for the next task.

Problems? Only works for “compare” timer uses. Will result in slower ISR response time – May not care, could just schedule sooner…

Implementation issues Shared user-space/ISR data structure. – Insertion happens at least some of the time in user code. – Deletion happens in ISR. We need critical section (disable interrupt) How do we deal with our modulo counter? – That is, the timer wraps around. – Why is that an issue? What functionality would be nice? – Generally one-shot vs. repeating events – Might be other things desired though What if two events are to happen at the same time? – Pick an order, do both…

Implementation issues (continued) What data structure? – Data needs be sorted Inserting one thing at a time – We always pop from one end – But we add in sorted order.