Grundlagen Microcontroller Counter/Timer. Günther Gridling Bettina Weiss

Similar documents
Timer 0 Modes of Operation. Normal Mode Clear Timer on Compare Match (CTC) Fast PWM Mode Phase Corrected PWM Mode

Course Introduction. Content 20 pages 3 questions. Learning Time 30 minutes

Chapter 6 PROGRAMMING THE TIMERS

ATmega16A Microcontroller

Counter/Timers in the Mega8

PWM System. Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff

Hardware Flags. and the RTI system. Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff

Microcontroller: Timers, ADC

Graphical Control Panel User Manual

CprE 288 Introduction to Embedded Systems (Output Compare and PWM) Instructors: Dr. Phillip Jones

MICROCONTROLLER TUTORIAL II TIMERS

Grundlagen Microcontroller Analog I/O. Günther Gridling Bettina Weiss

Lab 5 Timer Module PWM ReadMeFirst

LM4: The timer unit of the MC9S12DP256B/C

Timer A (0 and 1) and PWM EE3376

Atmel ATmega328P Timing Subsystems. Reading

Microprocessor & Interfacing Lecture Programmable Interval Timer

TKT-3500 Microcontroller systems

Oct 30 Announcements. Bonus marked will be posted today Will provide 270 style feedback on multiple-choice questions. [3.E]-1

Measuring Distance Using Sound

DASL 120 Introduction to Microcontrollers

Timer/Counter with PWM

Hello and welcome to this Renesas Interactive Course that provides an overview of the timers found on RL78 MCUs.

Hello, and welcome to this presentation of the STM32L4 comparators. It covers the main features of the ultra-lowpower comparators and some

PIC Functionality. General I/O Dedicated Interrupt Change State Interrupt Input Capture Output Compare PWM ADC RS232

ESE 350 Microcontroller Laboratory Lab 5: Sensor-Actuator Lab


PAK-VIIIa Pulse Coprocessor Data Sheet by AWC

ECE251: Tuesday October 3 0

EEL 4744C: Microprocessor Applications Lecture 8 Timer Dr. Tao Li

Reading Assignment. Timer. Introduction. Timer Overview. Programming HC12 Timer. An Overview of HC12 Timer. EEL 4744C: Microprocessor Applications

uc Crash Course Whats is covered in this lecture Joshua Childs Joshua Hartman A. A. Arroyo 9/7/10

Electronic Counters. Sistemi Virtuali di Acquisizione Dati Prof. Alessandro Pesatori

A MORON'S GUIDE TO TIMER/COUNTERS v2.2. by

ECED3204: Microprocessor Part IV--Timer Function

EXAMINATION PAPER EMBEDDED SYSTEMS 6EJ005 UNIVERSITY OF DERBY. School of Computing and Technology DATE: SUMMER 2003 TIME ALLOWED: 2 HOURS

Microcontrollers: Lecture 3 Interrupts, Timers. Michele Magno

Lecture #4 Outline. Announcements Project Proposal. AVR Processor Resources

EE 308 Spring 2013 The MC9S12 Pulse Width Modulation System

Lecture 12 Timer Functions

EECS 270: Lab 7. Real-World Interfacing with an Ultrasonic Sensor and a Servo

The Need. Reliable, repeatable, stable time base. Memory Access. Interval/Event timers ADC DAC

Exercise 3: Sound volume robot

Human-Robot Interaction Class Koosy Human-Robot Interaction Class

Timing System. Timing & PWM System. Timing System components. Usage of Timing System

Hello, and welcome to this presentation of the FlexTimer or FTM module for Kinetis K series MCUs. In this session, you ll learn about the FTM, its

The MC9S12 Pulse Width Modulation System. Pulse Width Modulation

EE 308 Lab Spring 2009

Using the Z8 Encore! XP Timer

ECE 511: FINAL PROJECT REPORT GROUP 7 MSP430 TANK

ELEC 3040/3050 Lab #7

Roland Kammerer. 13. October 2010

ELCT 912: Advanced Embedded Systems

LV-Link 3.0 Software Interface for LabVIEW

PIC ADC to PWM and Mosfet Low-Side Driver

Lecture #19 Digital To Analog, PWM, Stepper Motors Embedded System Engineering Philip Koopman Monday, 28-March-2016

Timer A. Last updated 8/7/18

Using the HCS08 TPM Module In Motor Control Applications

Exercise 5: PWM and Control Theory

dspic30f Quadrature Encoder Interface Module

Part (A) Using the Potentiometer and the ADC* Part (B) LEDs and Stepper Motors with Interrupts* Part (D) Breadboard PIC Running a Stepper Motor

µchameleon 2 User s Manual

EE 308 Spring S12 SUBSYSTEMS: PULSE WIDTH MODULATION, A/D CONVERTER, AND SYNCHRONOUS SERIAN INTERFACE

Hello, and welcome to this presentation of the STM32 Digital Filter for Sigma-Delta modulators interface. The features of this interface, which

VORAGO Timer (TIM) subsystem application note

PIC Analog Voltage to PWM Duty Cycle

Embedded Systems and Software

AN2581 Application note

Topics Introduction to Microprocessors

CS/ECE 6780/5780. Al Davis. Today s topics: Output capture Pulse Width Modulation Pulse Accumulation all useful options for Lab7 1 CS 5780

8253 functions ( General overview )

DAC A (VCO) Buffer (write) DAC B (AGC) Buffer (write) Pulse Code Buffer (write) Parameter Buffer (write) Figure A.1. Receiver Controller Registers

Lazy Clock Electronics and Software

νµθωερτψυιοπασδφγηϕκλζξχϖβνµθωερτ ψυιοπασδφγηϕκλζξχϖβνµθωερτψυιοπα σδφγηϕκλζξχϖβνµθωερτψυιοπασδφγηϕκ χϖβνµθωερτψυιοπασδφγηϕκλζξχϖβνµθ

Real time digital audio processing with Arduino

Design of a Frequency Counter Based on Input Capture Function of a. Single Chip Computer. Wang Yanshuang; Liu Yuelong

Rochester Institute of Technology Real Time and Embedded Systems: Project 2a

EE445L Fall 2012 Final Version B Page 1 of 7

UNIVERSITY OF CALIFORNIA. EECS 145M: Microcomputer Interfacing Lab

For reference only Refer to the latest documents for details

Programming and Interfacing

OBSOLETE. Bus Compatible Digital PWM Controller, IXDP 610 IXDP 610

UNIVERSITY OF VICTORIA FACULTY OF ENGINEERING. SENG 466 Software for Embedded and Mechatronic Systems. Project 1 Report. May 25, 2006.

High Resolution Pulse Generation

An Arduino-based DCC Accessory Decoder for Model Railroad Turnouts. Eric Thorstenson 11/1/17

EE 314 Spring 2003 Microprocessor Systems

Safety Mechanism Implementation for Motor Applications in Automotive Microcontroller

Course Introduction. Purpose: Objectives: Content: 24 pages 3 questions. Learning Time: 35 minutes

Design with Microprocessors

Project Final Report: Directional Remote Control

Micromouse Meeting #3 Lecture #2. Power Motors Encoders

µtasker Document µtasker Hardware Timers

Building Interactive Devices and Objects. Prof. Dr. Michael Rohs, Dipl.-Inform. Sven Kratz MHCI Lab, LMU München

Pulse Width Modulation

ME 333 Assignment 7 and 8 PI Control of LED/Phototransistor Pair. Overview

L13: (25%), (20%), (5%) ECTE333

FPGA based digital current controllers

EE251: Thursday October 25

UM2068 User manual. Examples kit for STLUX and STNRG digital controllers. Introduction

Timer System Applications. Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff

Transcription:

Grundlagen Microcontroller Counter/Timer Günther Gridling Bettina Weiss 1

Counter/Timer Lecture Overview Counter Timer Prescaler Input Capture Output Compare PWM 2

important feature of microcontroller many applications require timers controllers include one or more timers width typically 8 or 16 bit "resolution": width of the timer "granularity": duration of 1 timer tick 3

timers are actually counters: have a timer count register (TCNT) that contains current count value count register can be read & set anytime be careful when acessing 16 bit count register on 8 bit machine > ensure atomic access! beware side effects when writing to running timer 4

timer may count up or down (sometimes configurable) several sources for clock possible system clock (possibly prescaled) external clock (pulse accumulator) asynchronous clock: external quartz (e.g. watch quartz, 32.768 khz) 5

typical use of timer: wait for some time count to given number of cycles, then raise interrupt (on timer overflow) user loads timer with value, timer counts down to 0 user loads timer with 2^n value, timer counts up to 0 maximum wait period: 2^n * clock period Example: 8 bit timer, 1 Mhz (1 cycle = 1 us) > can wait for 256 us 6

Prescaler: divides system clock normally, timer counts with every clock pulse prescaler: only lets every 2 nd, 4 th,... 1024 th pulse through timer counts more slowly is used to extend the range of the timer Example: 8 bit timer, 1 Mhz (1 cycle = 1 us) > can wait for ~260 ms with prescaler 1024 7

Prescaler problem : granularity gets larger no prescaler: 1 timer tick = 1 clock cycle 1024 prescaler: 1 timer tick = 1024 cycles Example: 8 bit timer, 1 Mhz (1 cycle = 1 us) no prescaler: 1 us with prescaler: 1.024 ms 8

Sometimes available: modulus mode user loads start value when timer reaches 0 > automatically loads start value again get periodic interrupts of given period 9

other typical features of timers: Input Capture Output Compare PWM (Pulse Width Modulation) 10

Input Capture: read timer value on external event used to timestamp external events if event happens, current value of count register is saved in input capture register rising edge, falling edge, toggle interrupt may be raised semi internal events (e.g., analog comparator) may trigger input capture 11

nice to measure intervals between events (with accuracy of +/ 1 clock cycle) problems when events too close together like digital I/O, input capture suffers from glitches noise cancellation through several samples delays timestamping of one event interval stays the same 12

Output Compare: set output on timer event event: timer count register has reached given value compare value is set by user in compare register, timer is started with 0 when counter value reaches compare value > something happens interrupt may be raised output pin may be changed 13

Different Output Compare Modes: set output pin to 0 set output pin to 1 toggle output Counter/Timer nice for doing something after a delay nice for periodic signals with equal high/low time 14

PWM (Pulse Width Modulation): periodic signal with variable high time period is adjustable (within range of timer) PWM has many uses: control speed of motor control position of servo motor dim LEDs cheap d/a conversion 15

PWM (Pulse Width Modulation): registers for period and high time counter starts from 0, counts to period toggles output pin according to high time value interrupts at reaching high time & period problem of glitches when updating registers 16

Lecture Summary controller has 8 bit, 16 bit timers (or mixed) Overflow, Modulus, Input Capture, Output Compare, PWM careful when accessing a running timer practically everything is an interrupt source 17