ECE251: Thursday September 27

Similar documents
Design and Implementation Interrupt Mechanism

The ARM Cortex-M0 Processor Architecture Part-1

Interrupts. Why Interrupts

Lab 4 Interrupt-driven operations

ARM Interrupts. EE383: Introduction to Embedded Systems University of Kentucky. James E. Lumpp

ECE251: Tuesday September 18

COEN-4720 Embedded Systems Design Lecture 4 Interrupts (Part 1) Cristinel Ababei Dept. of Electrical and Computer Engineering Marquette University

ECE251: Thursday September 13

ECE251: Tuesday September 11

ECE251: Tuesday September 12

EE251: Tuesday October 23

Interrupt-Driven Input/Output

introduction to interrupts

Interrupts (Exceptions) (From LM3S1968) Gary J. Minden August 29, 2016

Interrupts and Low Power Features

Program SoC using C Language

Interrupts (Exceptions) Gary J. Minden September 11, 2014

EE4144: ARM Cortex-M Processor

Multitasking on Cortex-M(0) class MCU A deepdive into the Chromium-EC scheduler

Exceptions and Interrupts ARM Cortex M3

ECE251: Intro to Microprocessors Name: Solutions Mid Term Exam October 4, 2018

Embedded Systems. October 2, 2017

ELC4438: Embedded System Design ARM Cortex-M Architecture II

EE251: Tuesday September 5

Cortex-M4 Processor Overview. with ARM Processors and Architectures

Computer Organization Laboratory. Class Notes. Instructor: Ken Q. Yang Dept. of ECE, URI

Application Note. Analyzing HardFaults on Cortex-M CPU

ECE254 Lab3 Tutorial. Introduction to Keil LPC1768 Hardware and Programmers Model. Irene Huang

Embedded System Design

8086 Interrupts and Interrupt Responses:

EE251: Tuesday December 4

ARM Architecture and Assembly Programming Intro

ARM architecture road map. NuMicro Overview of Cortex M. Cortex M Processor Family (2/3) All binary upwards compatible

ECE254 Lab3 Tutorial. Introduction to MCB1700 Hardware Programming. Irene Huang

EE251: Thursday November 30

ARM Cortex core microcontrollers

LDR R0,=0x L: LDREX R1, [R0] ORR R1, #4 STR R1, [R0] (5) Part a) Why does the 9S12 code not have a critical section?

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 09, SPRING 2013

Real Time Operating Systems

Grundlagen Microcontroller Interrupts. Günther Gridling Bettina Weiss

Timers and Pulse Accumulator

Stacks and Subroutines

ARM PROGRAMMING. When use assembly

Migrating ARM7 Code to a Cortex-M3 MCU By Todd Hixon, Atmel

Lecture 10 Exceptions and Interrupts. How are exceptions generated?

EECS 373 Design of Microprocessor-Based Systems

Interrupts and Exceptions

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

ECE 598 Advanced Operating Systems Lecture 8

Developing a Generic Hard Fault handler for ARM Cortex-M3/Cortex-M4

Introduction. ! Exception*are*events*! They*occur*during*the*execution*of*the*program! Type*of*ARM*exceptions*! Exceptions*that*result*by*a*command

Subroutines and the Stack

The Definitive Guide to the ARM Cortex-M3

Lecture notes Lectures 1 through 5 (up through lecture 5 slide 63) Book Chapters 1-4

Implementing Secure Software Systems on ARMv8-M Microcontrollers

M2351 TrustZone Program Development

ARM Cortex-M4 Architecture and Instruction Set 1: Architecture Overview

Input/Output Programming

538 Lecture Notes Week 5

OUTLINE. STM32F0 Architecture Overview STM32F0 Core Motivation for RISC and Pipelining Cortex-M0 Programming Model Toolchain and Project Structure

ARM Cortex-M and RTOSs Are Meant for Each Other

ECE 485/585 Microprocessor System Design

Cortex-M3 Reference Manual

NET3001. Advanced Assembly

ECE 3210 Lab 4: Calculator

EE251: Thursday September 20

EEL 4744C: Microprocessor Applications. Lecture 7. Part 1. Interrupt. Dr. Tao Li 1

Reading Assignment. Interrupt. Interrupt. Interrupt. EEL 4744C: Microprocessor Applications. Lecture 7. Part 1

CprE 288 Translating C Control Statements and Function Calls, Loops, Interrupt Processing. Instructors: Dr. Phillip Jones Dr.

Advanced Assembly, Branching, and Monitor Utilities

University of Texas at Austin Electrical and Computer Engineering Department. EE319K, Embedded Systems, Spring 2013 Final Exam

ECE 362 Experiment 4: Interrupts

Troubleshooting Guide

ARM Cortex-M4 Programming Model

PC Interrupt Structure and 8259 DMA Controllers

Final Exam. Date: May 12, 2017

(5) Question 2. Give the two most important factors for effective debugging. Jonathan W. Valvano

ECE 341. Lecture # 19

ECE 598 Advanced Operating Systems Lecture 8

Job Posting (Aug. 19) ECE 425. ARM7 Block Diagram. ARM Programming. Assembly Language Programming. ARM Architecture 9/7/2017. Microprocessor Systems

538 Lecture Notes Week 5

ECE251: Thursday November 8

AND SOLUTION FIRST INTERNAL TEST

Reset, Interrupts, Exceptions, and Break ECE 3534

CHAPTER 11 INTERRUPTS PROGRAMMING

EE251: Thursday November 15

EE319K Fall 2013 Exam 1B Modified Page 1. Exam 1. Date: October 3, 2013

Introduction to C. Write a main() function that swaps the contents of two integer variables x and y.

Cortex-M4 Exceptions and Interrupts

ARM Embedded Systems: ARM Design philosophy, Embedded System Hardware, Embedded System Software

Input/Output. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Computer Organization & Assembly Language Programming (CSE 2312)

Chapters 2, 3: bits and pieces. Chapters 2 & 3. Chapters 2, 3: bits and pieces. Chapters 2, 3: bits and pieces. Using C. A last word about hardware

These three counters can be programmed for either binary or BCD count.

CSE 410. Operating Systems

Lab5 2-Nov-18, due 16-Nov-18 (2 weeks duration) Lab6 16-Nov-19, due 30-Nov-18 (2 weeks duration)

Interrupt/Timer/DMA 1

Computer Labs: I/O and Interrupts

ARM Cortex-M4 Architecture and Instruction Set 3: Branching; Data definition and memory access instructions

McGill University Department of Electrical and Computer Engineering. Course ECSE-322A -- Computer Engineering. MidTerm Test Version 1 Solutions

Transcription:

ECE251: Thursday September 27 Exceptions: Interrupts and Resets Chapter in text and Lab #6. READ ALL this material! This will NOT be on the mid-term exam. Lab Practical Exam #1 Homework # due today at 4:00 Mid-term exam on October 4, next Thursday. Review Tues. Be ready with questions! Practical Exam #1 on week of October 8 in lab Lecture # 1

Previous Homework Question 1. Write an assembly language program that calls a subroutine which replaces all ASCII digits (0-9) of a string with the # symbol. Memory location of the string is passed on the top of the stack. The string is terminated with the null symbol, value =0. Str DCB Te5t Str1ng 0 and 1, #0 main LDR, =Str PUSH {} BL Digit_replace... Lecture # 2

New Topic: Exceptions & Interrupts Exception: A break in normal program flow execution is interrupted by some event, usually external to the CPU. Common Examples of Exceptions: Reset: Power up or warm start NMI: Non-maskable interrupt usually an external NMI signal Memory Management Fault: memory protection violation Usage Fault: undefined instruction, SVCall: Supervisory call SysTick: System Timer (we will cover this in lecture/lab) Interrupt (IRQ): Typically created by peripherals External I/O device (e.g. keyboard, printer) Internal event (e.g. op code fault, timer) See TM4C Data Sheet, Section 2.5 Lecture #

Fundamental Concepts of Interrupts What is an interrupt? A special event that requires the CPU to stop normal program execution and perform some action (service) related to the event. Examples of interrupts include I/O completion and real-time interrupt. Functions of Interrupts - Coordinates I/O activities and prevents CPU from being tied up checking on these activities (polling) - Reminds the CPU to perform routine tasks (real-time interrupt) - Provides a graceful way to exit from errors Interrupt Maskability - Interrupts that can be ignored by the CPU are called maskable interrupts. A maskable interrupt must be enabled before it can interrupt the CPU. An interrupt is enabled by setting an enable flag. - Interrupts that are never ignored by the CPU are called nonmaskable interrupts and include things like special NMI hardware Lecture # 4

Interrupts vs. Polling Polling: Monitoring, waiting for flag to set Program is tied up waiting for flag Inefficient use of processor Easily programmed Interrupt: Processor tells program when event has occurred Program can be executing other tasks Processor can perform activities real-time Analogy: Waiting for incoming phone call. See following slide Lecture # 5

Polling vs. Interrupt Polling: You pick up the phone every few seconds to check whether you are getting a call. Interrupt: Do whatever you need to do and pick up the phone when it rings (or vibrates or ). Lecture # 6

Interrupt Processing Hardware Busy Done Busy Main Thread Interrupt Thread Hardware needs service Saves execution state ISR provides service Restores execution state time Lecture # 7

Interrupt Conditions Five conditions must be true simultaneously for an interrupt to occur: Software 1. Arm: control bit for each possible source is set or armed 2. Enable NVIC: Set NVIC_E register bit appropriately. Enable: interrupts globally enabled (I=0 in PRIMASK) 4. Level: interrupt must be less than BASEPRI (priority higher) 5. Trigger: hardware action sets source-specific flag Interrupt remains pending if trigger is set but any other condition is not true Interrupt serviced once all conditions become true Need to acknowledge interrupt Clear trigger flag or will get endless interrupts! Lecture # 8

What To Do When an Interrupt Occurs? Interrupt Service Routine (ISR): The software routine (subroutine) executed by a processor in response to an interrupt. This is similar to a normal software subroutine with important differences: Method by which system enters the subroutine (interrupt vs BL) What s saved when the subroutine is entered Instructions which complete and exit the subroutine, including restoring what was saved above. Lecture # 9

Interrupt Service Activity A complete interrupt service action includes: 0. Interrupt occurs during an instruction. Instruction is allowed to complete. 1. Saving r0-r,r,lr,pc,psr in the stack. Why do that? 2. LR set to 0xFFFFFFF9 indicating interrupt being serviced. Identifying the cause of interrupt-sets IPSR to interrupt number 4. Determining the starting address of the corresponding Interrupt Service Routine (ISR), based on the interrupt cause and Interrupt Vector Table entry (we will discuss this). 5. Executing this ISR. 6. Finally, executing BX LR, restoring register entries from stack and continuing execution of the interrupted program, exactly where it was interrupted. Lecture # 10

Interrupt Service Responsibilities Processor finishes the current instruction. Processor stores certain register contents on stack. Processor transfers control to ISR associated with that specific interrupt. ISR takes appropriate action including clearing trigger flag When complete, ISR executes BX LR instruction LR has a special meaning here! BX restores register values above BX transfers control to where it left off (next instruction, as if nothing had happened) when the interrupt event occurred Lecture # 11

Stack Activity on ISR Start and Exit Old SP Stack descends In memory. New SP SP + 0x20 SP + 0x1C SP + 0x18 SP + 0x14 SP + 0x10 SP + 0x0C SP + 0x08 SP + 0x04 SP + 0x00 xxxxxxxx xpsp PC (r15) LR (r14) r r r2 r1 r0 The processor automatically pushes these eight registers into the main stack before an interrupt handler starts The processor automatically pops these eight register out of the main stack when an interrupt hander exits using BX LR Lecture #

How does the CPU find the ISR? Interrupt Vector Starting Address of the Interrupt Service Routine. Programmer must initialize this! Interrupt Vector Table A table (in read-only memory) where all interrupt vectors are stored. Method of Determining Interrupt Vectors 1. Fetching the vector from a predefined location in the Interrupt Vector Table. See next slides. Steps of Programming for an Interrupt Step 0. Interrupt vector table entry and ISR loaded into ROM by assembler/linker/loader at location supplied by programmer Step 1. Enable the specific interrupt Step 2. Set NVIC_E register appropriately Step. Enable global Interrupts (PRIMASK = 0) Lecture # 1

Lecture # 14 Interrupt Vector Table

Startup.s to Initialize Interrupt Vector Table EXPORT Vectors Vectors DCD StackMem + Stack ; Top of Stack DCD Reset_Handler ; Reset Handler DCD NMI_Handler ; NMI Handler DCD HardFault_Handler ; Hard Fault Handler DCD MemManage_Handler ; MPU Fault Handler DCD BusFault_Handler ; Bus Fault Handler DCD UsageFault_Handler ; Usage Fault Handler DCD 0,0,0,0 ; Reserved DCD SVC_Handler ; SVCall Handler DCD DebugMon_Handler ; Debug Monitor Handler DCD 0 ; Reserved DCD PendSV_Handler ; PendSV Handler DCD SysTick_Handler ; SysTick Handler DCD GPIOPortA_Handler ; GPIO Port A DCD GPIOPortB_Handler ; GPIO Port B DCD GPIOPortC_Handler ; GPIO Port C DCD GPIOPortD_Handler ; GPIO Port D DCD GPIOPortE_Handler ; GPIO Port E DCD UART0_Handler ; UART0 Rx and Tx DCD UART1_Handler ; UART1 Rx and Tx Lecture # 15

Interrupt Handling Sequence Lecture # 16

Interrupt Context Switch Assume GPIO Port C Interrupt (#18) I 0 IPSR 0 BASEPRI 0 Before interrupt I 0 RAM Context Switch Finish instruction IPSR 18 a) Push registers b) PC = {0x00000048} BASEPRI 0 c) Set IPSR = 18 d) Set LR = 0xFFFFFFF9 Use as stack pointer Stack After interrupt old old old old old 2 old LR old PC old PSR Stack Vector address for GPIO Port C Interrupt Number 18 corresponds to GPIO Port C Lecture # 17

Overhead Time for Interrupts The interrupt itself causes the saving of 8 CPU registers then branching to the ISR. Plus the execution of the BX LR instruction restoring these same 8 registers and then branching back to the executing program. Plus the execution time of instructions of the interrupt service routine. SO: Keep ISR short if input/output responsiveness or performance is critical (and it often is). Lecture # 18

Stacking & Unstacking ISRs Interrupt Signal Interrupt Handler Interrupt Exit Unstacking User Program User Program Stacking Thread Mode Handler Mode Thread Mode Time Interrupt Handler User Program Lecture # 19

Stack Pointer Registers : Main Stack Pointer. We use only this one in ECE251 PSP: Process Stack Pointer Lecture # 20

Processor Mode: Handler Mode vs Thread Mode Handler mode for processing exceptions always use (Main Stack Pointer) Thread Mode for application software uses in our system so just forget about this! When the processor is reset, the default is the thread mode. The processor enters the handler mode when an interrupt occurs and returns to thread mode when ISR completes. Your program does not need to worry about this. It happens automatically. Not sure why text writers care so much about this. Lecture # 21

Register Values in an Interrupt Service Routine LR = 0xFFFFFFF9! See next slide! SP = ISR always in hander mode. Lecture # 22

Where does processing continue when exiting an interrupt? Link Register (LR) now has two usages! With Subroutine Call, LR = address of the instruction immediately after BL In ISR, LR indicates that the stack is used to restore register from when exiting an interrupt LR value generated by processor The processor sets LR to 0xFFFFFFFF on reset. The processor sets LR to 0xFFFFFFF9 on interrupt. Lecture # 2

EXAMPLE: Interrupt Stacking & Unstacking main PROC addr = 0x08000044 MOV r,#0 addr = 0x0800001C SysTick_Handler PROC EXPORT SysTick_Handler ADD r, #1 ADD r4, #1 BX lr R4 2 (SP) 4(LR) 5(PC) 0 1 2 4 0x08001000 0x08000044 xxxxxxxx 0x200001FC 0x200001F8 0x200001F4 0x200001F0 0x200001EC 0x200001E8 0x200001E4 0x200001E0 0x200001DC 0x200001D8 0x200001D4 0x200001D0 0x200001CF Memory Lecture # 24

EXAMPLE: Interrupt Suppose SysTick Stacking interrupt & Unstacking occurs when PC = 0x08000044 main PROC addr = 0x08000044 MOV r,#0 addr = 0x0800001C SysTick_Handler PROC EXPORT SysTick_Handler ADD r, #1 ADD r4, #1 BX lr R4 2 (SP) 4(LR) 5(PC) 0 1 2 4 0x08001000 0x08000044 xxxxxxxx 0x200001FC 0x200001F8 0x200001F4 0x200001F0 0x200001EC 0x200001E8 0x200001E4 0x200001E0 0x200001DC 0x200001D8 0x200001D4 0x200001D0 0x200001CF Memory Lecture # 25

EXAMPLE: Interrupt Stacking & Unstacking STACKING main PROC addr = 0x08000044 MOV r,#0 addr = 0x0800001C SysTick_Handler PROC EXPORT SysTick_Handler ADD r, #1 ADD r4, #1 BX lr R4 2 (SP) 4(LR) 5(PC) 0 1 2 4 0xFFFFFFF9 0x0800001C PC LR 2 xxxxxxxx 0x08000044 0x08001000 0x200001FC 0x200001F8 0x200001F4 0x200001F0 0x200001EC 2 0x200001E8 1 0x200001E4 0 0x200001E0 0x200001DC 0x200001D8 0x200001E0 0x200001D4 0x200001D0 0x200001CF Memory Lecture # 26

EXAMPLE: Interrupt Stacking & Unstacking STACKING main PROC addr = 0x08000044 MOV r,#0 addr = 0x0800001C SysTick_Handler PROC EXPORT SysTick_Handler ADD r, #1 ADD r4, #1 BX lr R4 2 (SP) 4(LR) 5(PC) 0 1 2 4 0xFFFFFFF9 0x0800001C PC LR 2 xxxxxxxx 0x08000044 0x08001000 0x200001FC 0x200001F8 0x200001F4 0x200001F0 0x200001EC 2 0x200001E8 1 0x200001E4 0 0x200001E0 0x200001DC 0x200001D8 LR = 0xFFFFFFF9 to indicate is used. 0x200001E0 Memory 0x200001D4 0x200001D0 0x200001CF Lecture # 27

Interrupt: Stacking & Unstacking main PROC addr = 0x08000044 MOV r,#0 addr = 0x0800001C SysTick_Handler PROC EXPORT SysTick_Handler ADD r, #1 ADD r4, #1 BX lr R4 2 (SP) 4(LR) 5(PC) 0 1 2 4 4 0xFFFFFFF9 0x0800001C PC LR 2 xxxxxxxx 0x08000044 0x08001000 0x200001FC 0x200001F8 0x200001F4 0x200001F0 0x200001EC 2 0x200001E8 1 0x200001E4 0 0x200001E0 0x200001DC 0x200001D8 0x200001E0 0x200001D4 0x200001D0 0x200001CF Memory Lecture # 28

Interrupt: Stacking & Unstacking main PROC addr = 0x08000044 MOV r,#0 addr = 0x0800001C SysTick_Handler PROC EXPORT SysTick_Handler ADD r, #1 ADD r4, #1 BX lr R4 2 (SP) 4(LR) 5(PC) 0 1 2 4 5 0xFFFFFFF9 0x08000020 PC LR 2 xxxxxxxx 0x08000044 0x08001000 0x200001FC 0x200001F8 0x200001F4 0x200001F0 0x200001EC 2 0x200001E8 1 0x200001E4 0 0x200001E0 0x200001DC 0x200001D8 0x200001E0 0x200001D4 0x200001D0 0x200001CF Memory Lecture # 29

Interrupt: Stacking & Unstacking main PROC addr = 0x08000044 MOV r,#0 addr = 0x0800001C SysTick_Handler PROC EXPORT SysTick_Handler ADD r, #1 ADD r4, #1 BX lr R4 2 (SP) 4(LR) 5(PC) 0 1 2 4 5 0xFFFFFFF9 0x08000024 PC LR 2 xxxxxxxx 0x08000044 0x08001000 0x200001FC 0x200001F8 0x200001F4 0x200001F0 0x200001EC 2 0x200001E8 1 0x200001E4 0 0x200001E0 0x200001DC 0x200001D8 LR = 0xFFFFFFF9 to indicate is used. 0x200001E0 Memory 0x200001D4 0x200001D0 0x200001CF Lecture # 0

Interrupt: Stacking & Unstacking UNSTACKING main PROC addr = 0x08000044 MOV r,#0 addr = 0x0800001C SysTick_Handler PROC EXPORT SysTick_Handler ADD r, #1 ADD r4, #1 BX lr R4 2 (SP) 4(LR) 5(PC) 0 1 2 4 5 0xFFFFFFF9 0x08000024 PC LR 2 xxxxxxxx 0x08000044 0x08001000 0x200001FC 0x200001F8 0x200001F4 0x200001F0 0x200001EC 2 0x200001E8 1 0x200001E4 0 0x200001E0 0x200001DC 0x200001D8 LR = 0xFFFFFFF9 to indicate is used. 0x200001E0 Memory 0x200001D4 0x200001D0 0x200001CF Lecture # 1

Interrupt: Stacking & Unstacking main PROC addr = 0x08000044 MOV r,#0 addr = 0x0800001C SysTick_Handler PROC EXPORT SysTick_Handler ADD r, #1 ADD r4, #1 BX lr R4 2 (SP) 4(LR) 5(PC) 0 1 2 5 0x08001000 0x08000044 xxxxxxxx 0x200001FC 0x200001F8 0x200001F4 0x200001F0 0x200001EC 0x200001E8 0x200001E4 0x200001E0 0x200001DC 0x200001D8 Note the new value of is lost!!! Memory 0x200001D4 0x200001D0 0x200001CF Lecture # 2

Interrupt: Stacking & Unstacking main PROC addr = 0x08000044 MOV r,#0 addr = 0x0800001C SysTick_Handler PROC EXPORT SysTick_Handler ADD r, #1 ADD r4, #1 BX lr R4 2 (SP) 4(LR) 5(PC) 0 1 2 5 0x08001000 0x08000044 xxxxxxxx 0x200001FC 0x200001F8 0x200001F4 0x200001F0 0x200001EC 0x200001E8 0x200001E4 0x200001E0 0x200001DC 0x200001D8 The Main program resumes. Memory 0x200001D4 0x200001D0 0x200001CF Lecture #

Interrupt: Stacking & Unstacking main PROC addr = 0x08000044 MOV r,#0 addr = 0x0800001C SysTick_Handler PROC EXPORT SysTick_Handler ADD r4, #1 BL sine BX lr R4 2 (SP) 4(LR) 5(PC) 0 1 2 4 0x08001000 0x08000044 xxxxxxxx 0x200001FC 0x200001F8 0x200001F4 0x200001F0 0x200001EC 0x200001E8 0x200001E4 0x200001E0 0x200001DC 0x200001D8 0x200001D4 0x200001D0 0x200001CF Memory Lecture # 4

Interrupt: Stacking & Unstacking STACKING main PROC addr = 0x08000044 MOV r,#0 addr = 0x0800001C SysTick_Handler PROC EXPORT SysTick_Handler ADD r4, #1 BL sine BX lr R4 2 (SP) 4(LR) 5(PC) 0 1 2 4 0xFFFFFFF9 0x0800001C PC SP LR xxxxxxxx 0x00000002 0x08001000 0x200001FC 0x200001F8 0x200001F4 0x200001F0 0x200001EC 2 0x200001E8 1 0x200001E4 0 0x200001E0 0x200001DC 0x200001D8 LR = 0xFFFFFFF9 to indicate is used. 0x200001E0 Memory 0x200001D4 0x200001D0 0x200001CF Lecture # 5

Interrupt: Stacking & Unstacking STACKING main PROC addr = 0x08000044 MOV r,#0 addr = 0x0800001C SysTick_Handler PROC EXPORT SysTick_Handler ADD r4, #1 BL sine BX lr R4 2 (SP) 4(LR) 5(PC) 0 1 2 4 0x080000F4 0x080000F0 PC SP LR xxxxxxxx 0x00000002 0x08001000 0x200001FC 0x200001F8 0x200001F4 0x200001F0 0x200001EC 2 0x200001E8 1 0x200001E4 0 0x200001E0 0x200001DC 0x200001D8 BL sine Updates LR register 0x200001E0 Memory 0x200001D4 0x200001D0 0x200001CF Lecture # 6

Interrupt: Stacking & Unstacking STACKING main PROC addr = 0x08000044 MOV r,#0 addr = 0x0800001C SysTick_Handler PROC EXPORT SysTick_Handler ADD r4, #1 BL sine BX lr R4 2 (SP) 4(LR) 5(PC) 0 1 2 4 0x080000F4 0x080000F0 PC SP LR xxxxxxxx 0x00000002 0x08001000 0x200001FC 0x200001F8 0x200001F4 0x200001F0 0x200001EC 2 0x200001E8 1 0x200001E4 0 0x200001E0 0x200001DC 0x200001D8 BL sine Updates LR register 0x200001E0 Memory 0x200001D4 0x200001D0 0x200001CF Lecture # 7

Interrupt: Stacking & Unstacking UNSTACKING won t occur! main PROC addr = 0x08000044 MOV r,#0 addr = 0x0800001C SysTick_Handler PROC EXPORT SysTick_Handler ADD r4, #1 BL sine BX lr R4 2 (SP) 4(LR) 5(PC) 0 1 2 4 0x080000F4 0x080000F0 PC SP LR xxxxxxxx 0x00000002 0x08001000 0x200001FC 0x200001F8 0x200001F4 0x200001F0 0x200001EC 2 0x200001E8 1 0x200001E4 0 0x200001E0 0x200001DC 0x200001D8 BL sine Updates LR register 0x200001E0 Memory 0x200001D4 0x200001D0 0x200001CF Lecture # 8

Interrupt: Stacking & Unstacking main PROC addr = 0x08000044 MOV r,#0 addr = 0x0800001C SysTick_Handler PROC EXPORT SysTick_Handler PUSH {lr} ADD r4, #1 BL sine POP {lr} BX lr R4 2 (SP) 4(LR) 5(PC) 0 1 2 4 0x080000F4 0x080000F0 0x200001E0 Fix the bug! PSP Save LR of course 0x00000000 PC SP LR xxxxxxxx 0x00000002 0x08001000 0x200001FC 0x200001F8 0x200001F4 0x200001F0 0x200001EC 2 0x200001E8 1 0x200001E4 0 0x200001E0 0x200001DC 0x200001D8 0x200001D4 0x200001D0 0x200001CF Memory Lecture # 9

Lab Practical #1 Some important things to note before you come for the practical. 1.The practical is closed book, open notes and access to the class website. 2.Make sure that you have access to all your code for all the labs you have done so far. The working code with its proper understanding will help you perform the practical properly..you will be given a simple problem to solve and you need to write a working program for that problem. The practical is worth 50 points (equivalent to all of the points you can receive for half of the lab experiments). 4.Make sure to go through the basics of writing the flow chart in Appendix E posted on the web site (follow the link Lab Assignments ). The flow chart for the program will be worth 10 points. The flow chart should be written in ENGLISH. If it contains any instructions specific to any software language, you will lose 2 points. If it does not contain proper shapes for the blocks, you will lose another 2 points. 5.The practical will have one easy section (worth 0 points) and one not so easy section (worth 40 points). If you choose to work with the easy section, you can score a maximum of 40 points. If you choose to work with the not so easy section, you can score the maximum of 50 points. Lecture # 40

Lab Practical #1-continued 6. You will work on the given problem for the first 90 minutes and the TA will check off your flow chart and working program after that. If you do not get your program checked off before the end of your session, you will not receive any credit for your work. 7. If the program is not working properly, you will receive partial credit on the basis of the working status of your program. 8. TA will not help you with the code; you need to work by yourself on the code and show the final results to the TA. 9. If you understand all the code for Labs 1 4 and if you have all the code with you, you should be able to perform the practical in no more than 50 minutes. 10. Do NOT discuss your practical with any other student until all practicals have been given (Friday noon). Not adhering to this could result in your failing the course. Lecture # 41

Lab Practical #1-Example Problem: Write a program that Uses the stored text above in memory. The end of text is marked by 0x04. (HINT: Which type of memory can be initialized?) Displays the original message on the screen. Copies the string to a new spot in memory starting at 0x20000B00 and changes every occurrence of certain letters in the message Waits for 5 seconds generated using a DELAY subroutine, Displays the new message store in memory Displays the (hexadecimal) number of occurrences a character change was made. Procedure: 1. Write a flow chart for the above problem (10 points). 2. Solve the Problem above (write a program) using one of the following methods:... Lecture # 42

Review Topics for Tuesday s Lecture What material would you like to review before mid-term exam? Lecture # 4