Microcontrollers. Outline. Class 4: Timer/Counters. March 28, Timer/Counter Introduction. Timers as a Timebase.

Similar documents
Design and Implementation of Timer, GPIO, and 7-segment Peripherals

Counter/timer 2 of the 83C552 microcontroller

M68HC11 Timer. Definition

o The 9S12 has a 16-bit free-running counter to determine the time and event happens, and to make an event happen at a particular time

o The 9S12 has a 16-bit free-running counter to determine the time and event happens, and to make an event happen at a particular time

Menu. 68HC12 Timer Block Diagram EEL 3744 EEL Input Capture (IC)

ASYNCHRONOUS COUNTER CIRCUITS

AT03716: Implementation of SAM L Configurable Custom Logic (CCL) Peripheral. Description. SMART ARM-based Microcontrollers APPLICATION NOTE

IT T35 Digital system desigm y - ii /s - iii

TV Synchronism Generation with PIC Microcontroller

VARIABLE FREQUENCY CLOCKING HARDWARE

Digital (5hz to 500 Khz) Frequency-Meter

STA2051E VESPUCCI 32-BIT SINGLE CHIP BASEBAND CONTROLLER FOR GPS AND TELEMATIC APPLICATIONS 1 FEATURES. Figure 1. Packages

Chapter 4: One-Shots, Counters, and Clocks

Smart Night Light. Figure 1: The state diagram for the FSM of the ALS.

To fully utilize Media 100 s genlocking capability, you ll need the following equipment connected to your system:

Netzer AqBiSS Electric Encoders

ADC Peripheral in Microcontrollers. Petr Cesak, Jan Fischer, Jaroslav Roztocil

LED Array Board.

Data Conversion and Lab (17.368) Fall Lecture Outline

Hello and welcome to this training module for the STM32L4 Liquid Crystal Display (LCD) controller. This controller can be used in a wide range of

Fast Quadrature Decode TPU Function (FQD)

Figure 30.1a Timing diagram of the divide by 60 minutes/seconds counter

Hello and welcome to this presentation of the STM32L4 Analog-to-Digital Converter block. It will cover the main features of this block, which is used

AVRcam Code Commentary. Version 1.3

Introduction. NAND Gate Latch. Digital Logic Design 1 FLIP-FLOP. Digital Logic Design 1

16 Stage Bi-Directional LED Sequencer

Fig. 1 Analog pins of Arduino Mega

Counters

Long and Fast Up/Down Counters Pushpinder Kaur CHOUHAN 6 th Jan, 2003

Digital Clock. Perry Andrews. A Project By. Based on the PIC16F84A Micro controller. Revision C

EECS145M 2000 Midterm #1 Page 1 Derenzo

8-BIT MCU WITH SINGLE VOLTAGE FLASH MEMORY, DATA EEPROM, ADC, TIMERS, SPI

Point System (for instructor and TA use only)

Lecture 14: Computer Peripherals

Logic Gates, Timers, Flip-Flops & Counters. Subhasish Chandra Assistant Professor Department of Physics Institute of Forensic Science, Nagpur

Laboratory 9 Digital Circuits: Flip Flops, One-Shot, Shift Register, Ripple Counter

UNIT V 8051 Microcontroller based Systems Design

OpenXLR8: How to Load Custom FPGA Blocks

Embedded System Training Module ABLab Solutions

Keyboard Controlled Scoreboard

IS01BFRGB LCD SmartDisplay from NKK Switches Simple implementation featuring the ATmega88PA from Atmel Complete software solution

NS8050U MICROWIRE PLUSTM Interface

ELE2120 Digital Circuits and Systems. Tutorial Note 8

Step 1 - shaft decoder to generate clockwise/anticlockwise signals

AD9884A Evaluation Kit Documentation

Radio Clock with DCF77

Using the Synchronized Pulse-Width Modulation etpu Function by:

NI-DAQmx Device Considerations

PC BOARD MOUNT DISPLAYS

Solutions to Embedded System Design Challenges Part II

NH 67, Karur Trichy Highways, Puliyur C.F, Karur District UNIT-III SEQUENTIAL CIRCUITS

SWITCH: Microcontroller Touch-switch Design & Test (Part 2)

CARLETON UNIVERSITY. Facts without theory is trivia. Theory without facts is bull 2607-LRB

SHENZHEN H&Y TECHNOLOGY CO., LTD

N3ZI Digital Dial Manual For kit with Backlit LCD Rev 4.00 Jan 2013 PCB

Sequential Logic and Clocked Circuits

Designing Intelligence into Commutation Encoders

Logic Analyzer Triggering Techniques to Capture Elusive Problems

COSC3215. Input Capture Output Compare

Decade Counters Mod-5 counter: Decade Counter:

BASCOM-TV. TV Code Features: ICs supported: BASCOM versions:

Introduction. Serial In - Serial Out Shift Registers (SISO)

EE 109 Homework 6 State Machine Design Name: Score:

Timing Pulses. Important element of laboratory electronics. Pulses can control logical sequences with precise timing.

Lab 3: Timer and Clock

Triple RTD. On-board Digital Signal Processor. Linearization RTDs 20 Hz averaged outputs 16-bit precision comparator function.

CSE 352 Laboratory Assignment 3

Revision 1.2d

Logic Design Viva Question Bank Compiled By Channveer Patil

AL330B-DMB-A0 Digital LCD Display SOC Demo Board

Advanced Devices. Registers Counters Multiplexers Decoders Adders. CSC258 Lecture Slides Steve Engels, 2006 Slide 1 of 20

Review of digital electronics. Storage units Sequential circuits Counters Shifters

University of Victoria. Department of Electrical and Computer Engineering. CENG 290 Digital Design I Lab Manual

Alice EduPad Board. User s Guide Version /11/2017

DT9834 Series High-Performance Multifunction USB Data Acquisition Modules

Introduction. The Clock Hardware. A Unique LED Clock Article by Craig A. Lindley

The University of Texas at Dallas Department of Computer Science CS 4141: Digital Systems Lab

EDL8 Race Dash Manual Engine Management Systems

Digital Circuits 4: Sequential Circuits

HDL & High Level Synthesize (EEET 2035) Laboratory II Sequential Circuits with VHDL: DFF, Counter, TFF and Timer

Electromania Problem statement discussion

Digital Fundamentals: A Systems Approach

MODULAR DIGITAL ELECTRONICS TRAINING SYSTEM

Experiment 7 Fall 2012

Using an IEEE Test Bus for Fault Diagnosis of Analog Parts of Electronic Embedded Systems. Zbigniew Czaja 1, Bogdan Bartosinski 2

SDA 3302 Family. GHz PLL with I 2 C Bus and Four Chip Addresses

Read-only memory (ROM) Digital logic: ALUs Sequential logic circuits. Don't cares. Bus

MF 644 MULTIFUNCTION I/O DEVICE USER'S MANUAL

35058-TE. PLJ-6LED-A LED Frequency Display Module Manual

Flip-Flops. Because of this the state of the latch may keep changing in circuits with feedback as long as the clock pulse remains active.

Circuit Playground Express (& other ATSAMD21 Boards) DAC Hacks

Flexible Counter Series in DIN size 24 x 48 mm

Experiment # 9. Clock generator circuits & Counters. Digital Design LAB

DIGITAL ELECTRONICS: LOGIC AND CLOCKS

FRONT WIRING DIAGRAM FOR ProCommander 2Series

RS flip-flop using NOR gate

Computer Systems Architecture

Lesson 12. Advanced Digital Integrated Circuits Flip-Flops, Counters, Decoders, Displays

Digital Blocks Semiconductor IP

Transcription:

Microcontrollers Class 4: Timer/Counters March 28, 2011 Outline Timer/Counter Introduction Timers as a Timebase Timers for PWM

Outline Timer/Counter Introduction Timers as a Timebase Timers for PWM Outline Timer/Counter Introduction Timers as a Timebase Timers for PWM

Review The story so far... Bits and shifting Analog and Digital input and output Serial stuffies Interrupts Now we get to give our programs a sense of timing Timer/Counter Overview The big picture We ve been using lots of software counters: for(i=0; i<8; i++)... The Mega88 chip has 3 built-in hardware counters that we can use instead Why? They re more efficient, reliable, and they free up our software to do other things Why timer/counter? Well, internally they re really counters but if you hook them up to a clock, counting clock pulses, you ve got a timer. They can also count hardware events (pin toggling, etc) but I won t run any examples of that here. Bother me by e-mail if you re interested.

Timer/Counter Hardware Block Diagram Timers Setup Timers are my least-favorite thing to configure on the AVR, but it s not so bad once you ve got the basics down. First need a source: what you re counting we ll use built-in clocks, and will need to set a prescaler Hardware compares the contents of two special memory registers (OCR0A and OCR0B) to the current counter value When the counter equals TOP, three things can happen: reset the timer fire an OC interrupt set, clear, or toggle a dedicated output pin What happens depends on which mode you re in In addition to the OCRs, there is also an interrupt available for when the timer overflows (wraps back around to 0)

Modes What can we do with these timers? Normal mode: just counts up from 0 to 255. Boring, but useful for a quick-and-dirty timebase using the overflow interrupt. Clear Timer on Compare (CTC) mode: Count up to value in OCR0A (not necessarily 255), then go back to zero. Provides different timing cycle durations. Fast PWM mode: Counts 0..255, does things on output pins when counter hits the OCR0A/B values Phase-correct PWM mode: first counts up, then counts down Modes

Configuration Putting the right bits in the right registers Control registers: TCCR0A, TCCR0B selects clock source, counting mode, and pin-output Interrupt mask register: TIMSK0 selects which interrupts to fire (overflow, compare) Output compare registers: OCR0A, OCR0B put your compare-values in here, changes duty-cycle (both, in some modes) or frequency (OCR0A only) Examples for details! Waveform Select Modes (p. 108)

Clock Select (p. 110) Output Mode (p. 106)

Outline Timer/Counter Introduction Timers as a Timebase Timers for PWM Simple Clock Tick, tick, tick I m surprised by the number of times I see people buy clock modules for their hardware projects Add in a crystal (next class) and you ll have a pretty-darn accurate timebase The basics: Set up global time-keeping variables Set up a CTC timer to interrupt once every (howeverlong) In the interrupt, increment your various counters (lightweight!) In the mainloop, use the time variables Initialization for the timer: mode, clock prescale, interrupt enables See the example: counterclock.c

Outline Timer/Counter Introduction Timers as a Timebase Timers for PWM Timer-based PWM Dimming LEDs in hardware Pins labelled OCxxx are directly connected to the output compare logic Result: you can set OCR0A, OCR0B and get PWM done for you automatically Timer1 is a 16-bit timer: has enough resolution for easy servo driving Setup: Select PWM mode (we ll use fast) Set up the output pin modes See example: counterpwm.c

Next Class Odds and Ends Special requests?? PROGMEM, EEPROM, and funny memory types Moving past the classboard: how to wire up your own circuits from the ground up Turn your classboard into a bare-chip programmer! (Optional) The End Outline