A Few Words From Dilbert

Slides:



Advertisements
Similar presentations
More fun with Timer/Counters
Advertisements

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
68HC11 Polling and Interrupts
Mark Neil - Microprocessor Course 1 Timers and Interrupts.
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.
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.
A look at interrupts What are interrupts and why are they needed.
Timers and Interrupts Shivendu Bhushan Summer Camp ‘13.
16.317: Microprocessor System Design I Instructor: Dr. Michael Geiger Spring 2012 Lecture 29: Microcontroller intro.
1 ECE 263 Embedded System Design Lessons 2, 3 68HC12 Hardware Overview, Subsystems, and memory System.
External & internal Interrupts. Interrupt Sources There are 21 different interrupts and each one has its own vector located in a predefined location at.
Embedded Systems Overview
Timers and Interrupts Shivendu Bhushan Sonu Agarwal.
Microcontrollers, Basics Fundamentals of Designing with Microcontrollers 16 January 2012 Jonathan A. Titus.
ECE 265 – LECTURE 12 The Hardware Interface 8/22/ ECE265.
Embedded System Design Laboratory September 27, 2002Stanford University - EE281 Lecture #1 Lecture #1 Outline Welcome Back AVR Hardware –Pins and Ports.
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.
Input/Output mechanisms
Timer/counter Chapter 12
ARM Timers.
System Clocks.
16F877A. Timer 0 The Timer0 module timer/counter has the following features: –8-bit timer/counter –Readable and writable –8-bit software programmable.
Timers ELEC 330 Digital Systems Engineering Dr. Ron Hayne
1 Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction.
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).
MCU: Interrupts and Timers Ganesh Pitchiah. What’s an MCU ?
Embedded System Design Laboratory October 11, 2002Stanford University - EE281 Lecture #4#1 Lecture #4 Outline Announcements Project Proposal AVR Processor.
Embedded System Design Laboratory October 4, 2002Stanford University - EE281 Lecture #3#1 Lecture #3 Outline Announcements AVR Processor Resources –UART.
Atmel Atmega128 Overview ALU Particulars RISC Architecture 133, Mostly single cycle instructions 2 Address instructions (opcode, Rs, Rd, offset) 32x8 Register.
ATtiny23131 A SEMINAR ON AVR MICROCONTROLLER ATtiny2313.
Timers and Interrupts Anurag Dwivedi. Let Us Revise.
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.
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.
Timers and Interrupts Mark Neil - Microprocessor Course.
Network and Systems Laboratory nslab.ee.ntu.edu.tw.
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.
TIMERS AND INTERRUPTS AVI SINGH KEVIN JOSE PIYUSH AWASTHI.
1 Lecture 1: Embedded Systems Overview, AVR Hardware/Software Introduction.
EE/CS-352: Embedded Microcontroller Systems Part V The 8051 Assembly Language Interrupts.
Mark Neil - Microprocessor Course 1 Timers and Interrupts.
Components of a typical full-featured microcontroller.
AVR Architecture Prepared By: Avdhesh Soni ( ) Sarthak Patel ( ) Akshay Parekh ( ) Fenil Sachla ( ) Guided.
Networked Embedded Systems Pengyu Zhang & Sachin Katti EE107 Spring 2016 Lecture 4 Timers and Interrupts.
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.
Embedded Systems Programming Interrupts and Handlers
Embedded Systems Programming
V.V.P. ENGINEERING COLLEGE,RAJKOT
BITS EDU. CAMPUS , VARNAMA
Overview of AVR Hardware/Software Introduction
AVR Addressing Modes Subject: Microcontoller & Interfacing
RX 8-Bit Timer (TMR) 4/20/2011 Rev. 1.00
Atmega32 Serial Programming Basics
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.
The Arduino Microcontroller: Atmel AVR Atmega 328
Timer/Counter Modified from Dr. Lam Phung’s Slides.
16-bit Timer/Counter1 Features
8-bit Timer/Counter0 with PWM
ATmega103 Timer0 and Interrupts
Introduction to Microprocessors and Microcontrollers
8-bit Timer/Counter2 with PWM and Asynchronous Operation
AVR – ATmega103(ATMEL) Architecture & Summary
Interrupt Chapter 10.
Wireless Embedded Systems
Timer/Counter Timer/Counter 0 Timer/Counter 1 Timer/Counter 2 8 bit
Presentation transcript:

A Few Words From Dilbert EE281 Lecture #2 October 2, 2002 A Few Words From Dilbert October 2, 2002 Stanford University - EE281 Lecture #2

Stanford University - EE281 Lecture #2 Lecture #2 Outline Status Check AVR Processor Resources Interrupts Timers Extra Lab Time? October 2, 2002 Stanford University - EE281 Lecture #2

Stanford University - EE281 Lecture #2 Status Check How is Lab #1 going? Got access to the EE281 lab yet? More STK500 kits are coming… October 2, 2002 Stanford University - EE281 Lecture #2

AVR Processor Resources Interrupts Timers UART (Universal Asynchronous Receiver/Transmitter) A/D Converters (Analog to Digital) SPI (Serial Peripheral Interface) Analog Comparator October 2, 2002 Stanford University - EE281 Lecture #2

Stanford University - EE281 Lecture #2 AVR AT90S8515 Pinout General Purpose Ports PORTA PORTB PORTC PORTD (Special Functions) Special Purpose Pins Crystal (XTAL1/XTAL2) RESET ICP, OLE, OC1B Power (VCC/GND) October 2, 2002 Stanford University - EE281 Lecture #2

‘8515 Functional Architecture 32 Registers (R0-R31) 4K Prog ROM 512 bytes RAM 512 bytes EEPROM 32 I/O lines 13 Interrupts Lots of fun built-in peripherals October 2, 2002 Stanford University - EE281 Lecture #2

Stanford University - EE281 Lecture #2 Interrupts Interrupts halt normal code execution in order to go do something more important or time sensitive Interrupt “Handlers” Using the Interrupt Vectors Interrupts are used for: RESET Timers and Time-Critical Code Hardware signaling “I’m done” “Something’s happened that you want to know about” “I have something for you” October 2, 2002 Stanford University - EE281 Lecture #2

Stanford University - EE281 Lecture #2 Interrupt Vectors October 2, 2002 Stanford University - EE281 Lecture #2

Interrupts: Code Example ; setup reset/interrupt vectors .cseg .org 0x000 rjmp reset ; $000 HW Reset or Watchdog Handler rjmp reset ; $001 External IRQ 0 Handler rjmp reset ; $002 External IRQ 1 Handler rjmp reset ; $003 Timer/Counter1 Capture Event Handler rjmp reset ; $004 Timer/Counter1 Compare Match A Handler rjmp reset ; $005 Timer/Counter1 Compare Match B Handler rjmp reset ; $006 Timer/Counter1 Overflow Handler rjmp Timer0Isr ; $007 Timer/Counter0 Overflow Handler rjmp reset ; $008 SPI Serial Transfer Complete Handler rjmp reset ; $009 UART Rx Complete Handler rjmp reset ; $00A UART Data Register Empty Handler rjmp reset ; $00B UART Tx Complete Handler rjmp reset ; $00C Analog Comparator Handler ; begin code reset: ; your main code goes here Timer0Isr: ; Timer0 overflow interrupt code here RETI ; don’t forget to return from your interrupt! October 2, 2002 Stanford University - EE281 Lecture #2

Timers: Why we need them Provide accurately timed delays or actions independent of code execution time How are Timers used? Accurate delay Read the timer, store value as K. Loop until timer reaches K+100. Schedule important events Setup an Output Compare to trigger an interrupt at a precise time Measure time between events When event#1 happens, store timer value as K When event#2 happens, read timer value and subtract K The difference is the time elapsed between the two events October 2, 2002 Stanford University - EE281 Lecture #2

Stanford University - EE281 Lecture #2 AVR Timer/Counter 0 8 Bit Up Counter counts from 0 to 255 (0xFF), then loops to 0 Internal or External Clock source Prescaler Interrupt on Overflow Transition from 255 to 0 can trigger interrupt if desired October 2, 2002 Stanford University - EE281 Lecture #2

AVR Timer/Counter 0 (cont’d) October 2, 2002 Stanford University - EE281 Lecture #2

Stanford University - EE281 Lecture #2 AVR Timer/Counter 1 16 Bit Up Counter Counts from 0 to 65535 (0xFFFF), then loops Internal clock source with prescaler or External Clock Dual Comparators Interrupts possible on: Overflow Compare A/B Input Capture of external event on ICP pin Can also act as an 8, 9 or 10 bit PWM Up-Down Counter October 2, 2002 Stanford University - EE281 Lecture #2

AVR Timer/Counter 1 (cont’d) October 2, 2002 Stanford University - EE281 Lecture #2

Timer 1 and Output Compare The 8515 has two output compares (OCR1A/B) OCR1A/B are 16-bit registers When the value of OCR1x matches that of Timer1: A user-defined action can take place on the OC1x pin (set/clear/inv) An interrupt can be triggered Timer1 can be cleared to zero Once set up, output compares operate continuously without software intervention Great for: Precise recurring timing Frequency/Tone generation (maybe sound effects) All kinds of digital signal generation Infrared communications Software-driven serial ports October 2, 2002 Stanford University - EE281 Lecture #2

Stanford University - EE281 Lecture #2 Timer 1 and PWM Pulse-Width Modulation Useful for using digital circuits to achieve analog-like control of motors, LEDs, etc Timer 1 has two channels of PWM output on OCR1A and OCR1B October 2, 2002 Stanford University - EE281 Lecture #2

Timer Control: I/O space Timer/Counter0 (TCNT0) Control Register (TCCR0) Timer 1 Timer/Counter1 (TCNT1) Control Register A & B (TCCR1A/B) Input Capture Register (ICR1) Timer/Counter1 Output Compare Register A and B (OCR1A/B) Timer Interrupt Registers Timer Interrupt Mask Register (TIMSK) Timer Interrupt Flag Register (TIFR) Common to Both Timers October 2, 2002 Stanford University - EE281 Lecture #2

Timer/Counter Clock Sources Prescaler Shut Off Divided System Clock External Input (rising or falling) October 2, 2002 Stanford University - EE281 Lecture #2

Stanford University - EE281 Lecture #2 Timer: Example Code Timer0.asm Gives a complete example of one way to use timer 0 with a timer interrupt handler Heavily commented Highlights helpful coding practices for all programs Use .equ to define constants Use .def to define register “nicknames” Available on the course website October 2, 2002 Stanford University - EE281 Lecture #2