Microcontroller5

Microcontroller5 - 3/13/2011 1 Interrupts (Chapter 6) A.H....

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 3/13/2011 1 Interrupts (Chapter 6) A.H. Mohsenian-Rad (U of T) 1 Networking and Distributed Systems Basics of Interrupts Dr. Hamed Mohsenian-Rad Texas Tech University ECE 3362: Microcontrol ers Spring 2011 5-2 What is an interrupt? s A special event that requires the CPU to stop normal program execution and perform some special service related to the event. Example in daily life: s You are studying for your exam. [This is the main program.] s Your cell phone rings. [The Interrupt] s You answer the phone. [Service Routine] s You come back to your study. [Return to main program] Functions of Interrupts Dr. Hamed Mohsenian-Rad Texas Tech University ECE 3362: Microcontrol ers Spring 2011 5-3 Coordinating I/O activities and preventing CPU from being tied up . s Remember we used to use a LOOP to scan switches. s Alternatively, we can use interrupts . s We can take actions only if a switch is pressed. s We no longer need to stay in a loop. This will allow the program to do other things as well. Functions of Interrupts Dr. Hamed Mohsenian-Rad Texas Tech University ECE 3362: Microcontrol ers Spring 2011 5-4 Providing a graceful way to exit from errors . Have you seen exceptions in programming languages. Interrupts can act similarly. For example, if the CPU sees an unimplemented OPCODE . Timers can also use interrupts to do periodic tasks . For example, doing a task every 1 ms through a timer interrupt. 3/13/2011 2 Interrupt Maskability Dr. Hamed Mohsenian-Rad Texas Tech University ECE 3362: Microcontrol ers Spring 2011 5-5 Maskable Interrupts: s Interrupts that can be ignored by the CPU. s They must be enabled before they can interrupt the CPU. s An interrupt is enabled by setting an enable flag. s Example: Timer Interrupts , IRQ , Non-maskable Interrupts: s Interrupts that cannot be ignored by the CPU. s Example: swi and reset . Interrupt Service and Interrupt Vector Dr. Hamed Mohsenian-Rad Texas Tech University ECE 3362: Microcontrol ers Spring 2011 5-6 Once an interrupt occurs: The CPU executes a program called the interrupt service routine . The starting address of the service routine is called interrupt vector . $....... $....... $....... $....... $....... $....... Service Routine Interrupt Vector Interrupt Service Cycle Dr. Hamed Mohsenian-Rad Texas Tech University ECE 3362: Microcontrol ers Spring 2011 5-7 Saving the program counter value in the stack . Saving the CPU status and registers in the stack . ( Q: Why?) Identifying the cause of interrupt . Obtaining the starting address of the corresponding service routine. Executing the interrupt service routine ....
View Full Document

This document was uploaded on 10/27/2011 for the course EE 3362 at Texas Tech.

Page1 / 18

Microcontroller5 - 3/13/2011 1 Interrupts (Chapter 6) A.H....

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online