ECE 353 Introduction to Microprocessor Systems Discussion 11.

Slides:



Advertisements
Similar presentations
ECE 353 Introduction to Microprocessor Systems
Advertisements

The 8051 Microcontroller and Embedded Systems
1 Homework Reading –Intel 8254 Programmable Interval Timer (PIT) Data Sheet Machine Projects –Continue on MP3 Labs –Continue in labs with your assigned.
Lab III Real-Time Embedded Operating System for a SoC System.
Exceptions. Exception Types Exception Handling Vectoring Interrupts Interrupt Handlers Interrupt Priorities Interrupt applications 6-2.
Computertechniek Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology 1.
ECE 447 Fall 2009 Lecture 9: TI MSP430 Interrupts & Low Power Modes.
CSCI 4717/5717 Computer Architecture
COMP3221: Microprocessors and Embedded Systems Final Exam Lecturer: Hui Wu Session 1, 2005.
Lab. 2 – More details – Tasks 4 to 6 1. What concepts are you expected to understand after the Lab. 2 is finished? 2. How do you demonstrate that you have.
COMP3221: Microprocessors and Embedded Systems Lecture 16: Interrupts II Lecturer: Hui Wu Session 2, 2005.
Mark Neil - Microprocessor Course 1 Timers and Interrupts.
Interrupt Processing Haibo Wang ECE Department
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.
Computer System Structures memory memory controller disk controller disk controller printer controller printer controller tape-drive controller tape-drive.
Timers and Interrupts Shivendu Bhushan Summer Camp ‘13.
1 Timing System Timing System Applications. 2 Timing System components Counting mechanisms Input capture mechanisms Output capture mechanisms.
8254 Programmable Interval Timer
7/23 Timers in Coldfire Processor Computer Science & Engineering Department Arizona State University Tempe, AZ Dr. Yann-Hang Lee (480)
8253 TIMER. Engr 4862 Microprocessors 8253 / 8254 Timer A.k.a. PIT (programmable Interval Timer), used to bring down the frequency to the desired level.
PIT: Programmable Interval Timer
8254 Counter/Timer Counter Each of the three counter has 3 pins associated CLK: input clock frequency- 8 MHz OUT GATE: Enable (high) or disable.
ARM Timers.
ECE 353 Introduction to Microprocessor Systems Discussion 13.
8254 SOFTWARE PROGRAMMABLE TIMER/COUNTER
ECE 353 Introduction to Microprocessor Systems Discussion 8.
Chapter 4 TIMER OPERATION
Revised: Aug 1, ECE 263 Embedded System Design Lessons 23, 24 - Exceptions - Resets and Interrupts.
MCU: Interrupts and Timers Ganesh Pitchiah. What’s an MCU ?
Silberschatz, Galvin, and Gagne  Applied Operating System Concepts Module 2: Computer-System Structures Computer System Operation I/O Structure.
1 CSE Department MAITSandeep Tayal Computer-System Structures Computer System Operation I/O Structure Storage Structure Storage Hierarchy Hardware Protection.
2: Computer-System Structures
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.
CSNB374: Microprocessor Systems Chapter 5: Procedures and Interrupts.
Lecture Topics: 10/29 Architectural support for operating systems –timers –kernel mode –system calls –protected instructions.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 2 Computer-System Structures Slide 1 Chapter 2 Computer-System Structures.
8254 Timer.
Silberschatz, Galvin and Gagne  Applied Operating System Concepts Chapter 2: Computer-System Structures Computer System Architecture and Operation.
Real Time Interrupts Section Real-Time Interrupt (RTI) Most operating systems (OS) require an interrupt every T seconds by the RTI RTI interrupts.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
MICRO-CONTROLLER MOTOROLA HCS12 Interrupts Mechatronics Department Faculty of Engineering Ain Shams University.
MICROPROCESSOR DETAILS 1 Updated April 2011 ©Paul R. Godin prgodin gmail.com.
Introduction to Exceptions 1 Introduction to Exceptions ARM Advanced RISC Machines.
Ch 5. ARM Instruction Set  Data Type: ARM processors supports six data types  8-bit signed and unsigned bytes  16-bit signed and unsigned half-words.
INSTITUTE: INSTITUTE:PARUL INSTITUTE OF TECHNOLOGY BRANCH : BRANCH :B.E. E.C.5 TH SEM. SUBJECT:MICROCONTROLLER & INTERFACING TOPIC:AVR INTTRUPT TOPIC:AVR.
Microprocessor Systems Design I
Homework Reading Machine Projects Labs
Timer and Interrupts.
UNIT – Microcontroller.
Discussions on hw5 Objectives:
Protection of System Resources
Programmable Interval Timer
Programmable Interval Timer
AVR Addressing Modes Subject: Microcontoller & Interfacing
Interrupt Source: under
ATmega103 Timer0 and Interrupts
CENG2400 Revision Q1a A system has an ARM processor with a 32-bit General Purpose Input Output (GPIO) module. Two on/off switches are connected to bit-3.
Discussions on hw5 Objectives:
Computer-System Architecture
Module 2: Computer-System Structures
Md. Mojahidul Islam Lecturer Dept. of Computer Science & Engineering
Md. Mojahidul Islam Lecturer Dept. of Computer Science & Engineering
Module 2: Computer-System Structures
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.
Module 2: Computer-System Structures
Module 2: Computer-System Structures
COMP3221: Microprocessors and Embedded Systems
Presentation transcript:

ECE 353 Introduction to Microprocessor Systems Discussion 11

Topics Interrupts and Exceptions Q&A

Interrupts and Exceptions The ADuC7026 defines locations for each exception vector – the code must put the proper instructions there to handle each exception. Table 2-4Table 2-4 ADuc7026.s places the address of the IRQ handler in the proper vector location. Exception.s contains the actual exception handler routines. The interrupt checklist posted on the course web page gives guidelines of what needs to be done to correctly handle interrupts. The ADuC7026 has 23 sources of interrupts. Table 72Table 72

Interrupt Problem Assume that the CPU is being clocked at 41.78MHz (32768Hz x 1275). Set up timer #1 to generate a periodic interrupt at a frequency of 3.2kHz. Produce an output on pin 4.0 that will have a duty cycle given by duty/32, where duty is a byte memory variable. The ISR can only make one change to the P4.0 state in each invocation. Only use the five least significant bits of duty.

Answer Requirements: Timer – setup to give a 3.2 kHz periodic interrupt Timer ISR – use to handle generating the proper output Variables – Count (for timer period tracking) and Duty (for setting the duty cycle) Output pin – P4.0

Answer In Main, we need: Setup GPIO for P4.0 Setup Timer1 Setup ISR Initialize variables In ISR, we need: Update count Update output

Answer Variables: Count – to get duty cycle increments of 1/32, we need to keep track of Timer ISR occurrences – Count will need values of Each execution of the Timer ISR will need to increment or decrement Count, and if it reaches the limit, reload the start count. Duty – Duty will be set in main – will determine how many of the 32 occurrences of the Timer ISR in one period will need to set the output high. (Timer ISR will not modify this variable.)

Answer Timer1 config: System clock at MHz means clock period of ns. Timer frequency of 3.2 kHz means timer period of us. Using divide by one, we need a T1LD value of us/ ns = ISR config: CLR Timer 1 IRQ Enable Timer 1 IRQ Enable global IRQ bit in CPSR (use MSR and MRS instructions) GPIO config: Set GPIO P4.0 as GPIO, output Initialize P4.0 to zero

Answer ISR details: Get Count and Duty variables Test: if Count < Duty, then P4.0 = 1, else P4.0 = 0 If Count == 0, then Count = 31, else Count = Count - 1 Store updated Count

ConcepTest What is the frequency of the output waveform? 3.2 kHz / 32 = 100 Hz What is the minimum average value? 0 What is the maximum average value? 31/32 = To achieve 1.0, we would need to relax the restriction on the bits of Duty to allow using 6- bits so we could go 0 – 32.

Answer Code: Main.s ; Filename: main11.s ; Author: ECE 353 Staff ; Description: main program file for discussion 11 ARM;use ARM instruction set EXPORT __main EXPORT Count EXPORT Duty INCLUDEaduc7026.inc ;count down, periodic, binary, source/1 T1CON_VALUEEQU0x000000C0 ;need interrupt every us with MHz clock T1_PERIODEQU13056 ;timer1 interrupt TMR1_IRQ_ENEQU0x AREA SRAM, DATA, READWRITE ; variables for timerISR DCountDCD0x0 ;timer ISR counter DDutyDCD0x0 ;duty cycle parameter

Answer Code: Main.s (cont.) AREA FLASH, CODE, READONLY __main ; setup GPIO pin 4.0 as output, initially zero LDRR7, =(GPIO_MMR_BASE);MMR base address MOVR0, #0x00 LDRR1, [R7, #GP4CON];get P4 as GPIO BICR1, R1, #3; STRR1, [R7, #GP4CON];set P4.0 as GPIO LDRR1, [R7, #GP4DAT] ;get P4 as GPIO ORRR1, R1, #0x ;set P4.0 as output BICR1, R1, #0x ;set P4.0 as zero STRR1, [R7, #GP4DAT] ; intitialize variables LDRR7, =(DCount);count address MOVR0, #31 STRR0, [R7];store initial count value LDRR7, =(DDuty);duty cycle variable address MOVR0, #20 STRR0, [R7];store initial duty cycle value

Answer Code: Main.s (cont.) ; setup timer1 LDRR7, =(TIMER_MMR_BASE);register base LDRR0, =(T1_PERIOD) STRR0, [R7, #T1LD];set timer period LDRR0, =(T1CON_VALUE) STRR0, [R7, #T1CON];configure timer ; setup interrupt LDRR7, =(IRQCON_MMR_BASE);register base MOVR0, #TMR1_IRQ_EN STRR0, [R7, #IRQCLR];clear timer1 interrupt STRR0, [R7, #IRQEN];enable timer1 interrupt MRSR1, CPSR; read CPSR BICR1, R1, #0x80;clear bit7 - IRQ disable bit MSRCPSR_c, R1; enable IRQs spin B spin CountDCDDCount DutyDCDDDuty END

Answer Code: Exception.s INCLUDE ADuC7026.inc;MMR definitions IMPORT Duty IMPORT Count IRQ_Handler PUSH{R0-R4};context save LDR R2, Duty LDRR0, [R2];get current duty cycle LDR R2, Count LDRR1, [R2];get current count LDRR3, =(GPIO_MMR_BASE) LDRR4, [R3, #GP4DAT] ;get P4 as GPIO CMPR1, R0; Count less than Duty - put out one BICPLR4, R4, #0x ;set P4.0 to zero ORRMIR4, R4, #0x ;set P4.0 to one STRR4, [R3, #GP4DAT] MOVSR1, R1;set flags MOVEQR1, #31;count at zero - reload SUBNER1, R1, #1;count not zero - decrement STRR1, [R2];store updated count ;interrupt stuff LDRR3, =(TIMER_MMR_BASE);timer MMR base address MOVR1, #0xFF STRBR1, [R3, #T1CLRI];reset timer1 interrupt POP{R0-R4};context restore SUBSPC, LR, #4 ;interrupt return

Questions?