MCU: Interrupts and Timers. Ganesh Pitchiah

Similar documents
HC12 Built-In Hardware

Introduction to Embedded Systems

Course Introduction. 2009, Renesas Technology America, Inc., All Rights Reserved

General Purpose Programmable Peripheral Devices. Assistant Professor, EC Dept., Sankalchand Patel College of Engg.,Visnagar

Chapter 2. Overview of Architecture and Microcontroller-Resources

Design and development of embedded systems for the Internet of Things (IoT) Fabio Angeletti Fabrizio Gattuso

Introduction to the MC9S12 Hardware Subsystems

EE 308 Spring A software delay. To enter a software delay, put in a nested loop, just like in assembly.

Texas Instruments Mixed Signal Processor Tutorial Abstract

PIC Microcontroller Introduction

8051 Peripherals. On-Chip Memory Timers Serial Port Interrupts. Computer Engineering Timers

Laboratory 4 Usage of timers

EE 308 Spring A software delay

8051 Microcontroller

Timers and Interrupts. Mark Neil - Microprocessor Course

EE4390 Microprocessors. Lessons 2, 3 68HC12 Hardware Overview, Subsystems, and memory System

SquareWear Programming Reference 1.0 Oct 10, 2012

EECS 373 Midterm 2 Fall 2018

MACHINE CONTROL INSTRUCTIONS: 1. EI

Microprocessors & Interfacing

Topic 11: Timer ISMAIL ARIFFIN FKE UTM SKUDAI JOHOR

Interrupts (I) Lecturer: Sri Notes by Annie Guo. Week8 1

Architecture of Computers and Parallel Systems Part 2: Communication with Devices

By the end of Class. Outline. Homework 5. C8051F020 Block Diagram (pg 18) Pseudo-code for Lab 1-2 due as part of prelab

The 8051 microcontroller has two 16-bit timers/counters called T0 and T1.

For more notes of DAE

INTERRUPT, TIMER/COUNTER. KONKUK UNIV. VLSI Design Lab. LSI Design Lab

DAVE 3 Hands on / Quick Start Tutorial. Presentation Tutorial Start 1 v1.1: Creating a simple Project using PWM and Count Apps

COMP2121: Microprocessors and Interfacing. I/O Devices (I)


Embedded Systems. PIC16F84A Internal Architecture. Eng. Anis Nazer First Semester

Lesson-3: Counters and Timers

EE 308: Microcontrollers

There are four registers involved in the fetch cycle: MAR, MBR, PC, and IR.

Chapter 6 PROGRAMMING THE TIMERS

Physics 120B: Lecture 11. Timers and Scheduled Interrupts

8051 Microcontroller Interrupts

Design UART Loopback with Interrupts

Interrupts, timers and counters

timer 1 Fri Oct 13 13:00:

Laboratory 10. Programming a PIC Microcontroller - Part II

Summer 2003 Lecture 21 07/15/03

CPE/EE 421 Microcomputers

I/O Systems (3): Clocks and Timers. CSE 2431: Introduction to Operating Systems

Table of Figures Figure 1. High resolution PWM based DAC...2 Figure 2. Connecting the high resolution buck converter...8

Processor and compiler dependent

Module 2. Embedded Processors and Memory. Version 2 EE IIT, Kharagpur 1

Basic Embedded Software C Review Using MPLAB SIM. Loops. Embedded Systems Interfacing. 25 August 2011

Rapidly Developing Embedded Systems Using Configurable Processors

Special Memory (SM) Bits

In this tutorial, we will discuss the architecture, pin diagram and other key concepts of microprocessors.

Interface DAC to a PC. Control Word of MC1480 DAC (or DAC 808) 8255 Design Example. Engineering 4862 Microprocessors

Timer Module Timer A. ReadMeFirst

PSoC Designer Quick Start Guide

INTERFACING HARDWARE WITH MICROCONTROLLER

EE 308 Spring Lecture 28 March 30, 2012 Review for Exam 2. Introduction to the MC9S12 Expanded Mode

SECTION 5 RESETS AND INTERRUPTS

Lecture 14. Ali Karimpour Associate Professor Ferdowsi University of Mashhad

Microprocessor Architecture

Smart.IO Host Interface Layer and Demo Programs

analogwrite(); The analogwrite function writes an analog value (PWM wave) to a PWM-enabled pin.

Prototyping Module Datasheet

Register Map for the PCM-QUAD02

Color 7 click. PID: MIKROE 3062 Weight: 19 g

PL2303TB USB-to-Serial Bridge Controller Demo Board User Manual

INTERRUPTS in microprocessor systems

Interrupt/Timer/DMA 1

University of Technology

ECE 353 Lab 4. General MIDI Explorer. Professor Daniel Holcomb Fall 2015

Chapter 09. Programming in Assembly

EECS 373 Midterm Winter 2017

Interrupts Arduino, AVR, and deep dark programming secrets. What is an Interrupt?

CHAPTER 5 : Introduction to Intel 8085 Microprocessor Hardware BENG 2223 MICROPROCESSOR TECHNOLOGY

80C51 Block Diagram. CSE Overview 1

EXPERIMENT NO.1. A Microcontroller is a complete computer system built on a single chip.

ECE3120: Computer Systems Chapter 8: Timer Module

An Interrupt is either a Hardware generated CALL (externally derived from a hardware signal)

FIFTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLOGY-MARCH 2014 EMBEDDED SYSTEMS (Common for CT,CM) [Time: 3 hours] (Maximum marks : 100)

CN310 Microprocessor Systems Design

Timer 32. Last updated 8/7/18

2. List the five interrupt pins available in INTR, TRAP, RST 7.5, RST 6.5, RST 5.5.

Study and implementation of RL78 low power mode

HT95R6x CPT (Call Progress Tone) Decoder Function

Using the HT16K33 in DVD Player Panel Applications

Microcomputer Architecture and Programming

COMP2121: Microprocessors and Interfacing

MPLAB SIM. MPLAB IDE Software Simulation Engine Microchip Technology Incorporated MPLAB SIM Software Simulation Engine

SH69P48A EVB. Application Notes for SH69P48A EVB SH69V48A JP2 J4(ICE_J4) S1 IDD TEST JP1 74HC273 JP4 JP3 74HC273 JP6 STKOVE JP7 SW1 J5(ICE_J5)

8051 Timers. Class 7 EE4380 Fall Pari vallal Kannan. Center for Integrated Circuits and Systems University of Texas at Dallas

Course Introduction. Purpose: Objectives: Content: 27 pages 4 questions. Learning Time: 20 minutes

The MCU s Pulse. Internal clock or oscillator to synchronize operation. One clock cycle = 1 TOSC = 1/fOSC. t TOSC

Lecture (03) PIC16F84 (2)

Physics 124: Lecture 12. Timer Basics. Timers and Scheduled Interrupts

Microprocessors B (17.384) Spring Lecture Outline

Pedometer 3 Click. PID: MIKROE 3259 Weight: 24 g

M16C/26 APPLICATION NOTE. Using Timer B in Pulse Period/Width Measurement Mode. 1.0 Abstract. 2.0 Introduction

EC2304-MICROPROCESSOR AND MICROCONROLLERS 2 marks questions and answers UNIT-I

Memory Expansion. Lecture Embedded Systems

8051 MICROCONTROLLER

PAN502x Capacitive Touch Controller Datasheet

Transcription:

MCU: Interrupts and Timers Ganesh Pitchiah

What s an MCU?

Frequency = 8 MHz Time Period = 1/f = 0.125 us

Code for Switching LED int a; voltage while(1) { a = PINA.0; input) If (a==1) PORTA.1=1; else PORTA.1=0; } // Define variable a to store value of // read value at pin A.0 (make sure it is // if voltage is 5V // Light the LED // Turn off the LED

The Problem ------while(1){ ---- -> Check value of a ---- -> Event A : a == 1 ---------- -> Event B : a == 0 ------------- -> Suppose event A occurs here ---}

Interrupt Means To cause or make a break in the continuity or uniformity of (a course, process, condition, etc.

The Problem & Solution ------while(1){ ---- -> Check value of a ---- -> Event A : a == 1 ---------- -> Event B : a == 0 ------------- -> Suppose event A occurs here ---}

Interrupts Software Interrupt while (1) { keep checking all events only } Hardware Interrupt

Why Interrupts? Interrupts are special events that can interrupt the normal flow of a program. The processor stops the normal program, handles the interrupt, and then resumes its normal work.

Registers Small amount of storage available in MCU/PC. Ex: A flip flop stores 1-bit of memory.

Timers

Timers A timer is a register. 7 6 5 4 3 2 255 -> Maximum value 254... 0 -> Starting value 1 0

Timers 8-bit Register and Starts with 0 7 0 1 6 0 1 5 0 1 4 0 1 3 0 1 2 0 1 0 1 0 1 Increase by 1,after each period. When the timer reaches its maximum value, in the next cycle, its value becomes 0 again and the process repeats itself. This process is independent of the CPU.

Simple statistics Maximum value of timer is n and clock period is t, then: 1. Timer period =t 2. Timer cycle period = ( +1) 3. Frequency of timer (f) = 1/ 4. Frequency of timer cycle = 1/ ( +1)

Timers and Interrupts Timers can generate certain two interrupts: 1. OVERFLOW interrupt and 2. COMPARE MATCH interrupt.

OVERFLOW interrupt OVERFLOW is generated when a timer tries to exceed its maximum 0 and 0 0 0 to0 0. 0 0 0 value resets The interrupt may or may not have a handler. In either case, the timer continues to run; remember: timers are independent of the CPU.

OVERFLOW statistics Suppose a timer of maximum value n has a time period t (also called as clock period). 1. Timer cycle frequency = 1/( +1) 2. OVERFLOW interrupt frequency = 1/ ( +1) If OVERFLOW interrupt is enabled, then an interrupt is generated in every cycle.

OVERFLOW and COMPARE MATCH

COMPARE MATCH interrupt There is a register called as OCR (Output Compare Register), whose value we can set. Before incrementing, the value of the timer is compared to OCR. If the two are equal, a COMPARE MATCH interrupt is generated.

COMPARE MATCH statistics Suppose a timer of maximum value n has a time period t (also called as clock period). 1. Timer cycle frequency = 1/( +1) 2. COMPARE MATCH interrupt frequency = 1/ ( +1) If COMPARE MATCH interrupt is enabled, then an interrupt is generated in every cycle.

OVERFLOW and COMPARE MATCH

Summary of Timers A timer is not affected by interrupts: it generated interrupts, but it does not stop running because of them. Interrupts is how timers are useful. Sample applications: digital clock, periodic events (such as blinking LEDs quickly for POV globe), etc.

Timer Modes A timer works in three modes: Normal, CTC and PWM. All three modes are again unaffected by interrupts, but all three modes can generate interrupts. The timer mode used so far in this presentation is normal mode.

Normal Mode Standard mode: Timer starts at 0, goes to maximum value and then resets itself. OVERFLOW and COMPARE MATCH interrupts generated as normal.

CTC (Clear Timer on Compare) Mode Timer starts at 0 as usual, but instead of resetting after maximum value, it resets after reaching value specified in OCR register.

CTC mode statistics If clock time period is t: 1. Timer cycle time period = ( +1) 2. Frequency = 1/( +1) COMPARE MATCH interrupt will work normally, but OVERFLOW interrupt will not work (Why?).

PWM (Pulse Width Modulation) Mode Simple method of obtaining analog output of any value between 0 and 5V. Desired output is x% of 5V. If Ton = x% then average value is x% of 5V.

PWM(Pulse Width Modulation) mode

PWM mode A specific pin is set as output. When the timer reaches 0, the voltage of the pin is set to 5V. When the timer reaches the value specified by OCR, on the next clock, the pin voltage is set to 0 until the timer resets itself.

PWM statistics If clock time period is t and maximum timer value is n: 1.Timer cycle time period =( +1) 2.Frequency =1/( +1) 3.Duty cycle =[ / ( +1)] 100% 4.Output voltage =[ /( +1)] 5 COMPARE MATCH interrupt and OVERFLOW interrupt will work properly.

Using CVAVR Open CVAV R Go to File New Proje ct

CVAVR Home

Go to File

Choose New

Choose Project

Press Yes

Select Chip

Using CVAVR

Demo