Hardware Reference
In-Depth Information
6.2 Fundamental Concepts of Interrupts
Interrupts and resets are among the most useful mechanisms that a computer system provides.
With interrupts and resets, I/O operations are performed more efficiently, errors are handled more
smoothly, and CPU utilization is improved. This chapter begins with a general discussion of
interrupts and resets and then focuses on the specific features of the HCS12 interrupts and resets.
Examples are given to demonstrate how interrupts can be used to effectively trigger I/O operations.
6.2.1 What Is an Interrupt?
An interrupt is an event that requires the CPU to stop normal program execution and per-
form some service related to the event. An interrupt can be generated internally (inside the
chip) or externally (outside the chip). An external interrupt is generated when the external cir-
cuitry asserts an interrupt signal to the CPU. An internal interrupt can be generated by the
hardware circuitry inside the chip or caused by software errors. Most microcontrollers have
timers, I/O interface functions, and the CPU incorporated on the same chip. These subsystems
can generate interrupts to the CPU. Abnormal situations that occur during program execution,
such as illegal opcodes, overflow, divide by zero, and underflow, are called software interrupts .
The terms traps and exceptions are also used to refer to software interrupts.
A good analogy for an interrupt is how you act when you are sitting in front of a desk to
read this topic and the phone rings. You probably act like this.
1. Remember the page number or place a bookmark on the page that you are reading,
close the topic, and put it aside.
2. Pick up the phone and say, “Hello, this is so and so.”
3. Listen to the voice over the phone to find out who is calling or ask who is calling if
the voice is not familiar.
4. Talk to that person.
5. Hang up the phone when you finish talking.
6. Open the topic and turn to the page where you placed the bookmark and resume
reading this topic.
The phone call example spells out a few things that are similar to how the microprocessor
handles the interrupt.
1. As a student, you spend most of your time studying. Answering the phone call
happens only occasionally. Similarly, the microprocessor is executing application
programs most of the time. Interrupts will only force the microprocessor to stop
executing the application program briefly and take some necessary actions.
2. Before picking up the phone, you finish reading the sentence and then place a bookmark
to remind yourself of the page number that you are reading so that you can resume
reading after finishing the conversation over the phone. Most microprocessors will
finish the instruction they are executing and save the address of the next instruction in
memory (usually in the stack) so that they can resume the program execution later.
3. You find out who the person is by listening to the voice over the phone, or you ask
questions so that you can decide what to say. Similarly, the microprocessor needs to
identify the cause of the interrupt before it can take appropriate actions. This is built
into the microprocessor hardware.
4. After identifying the person who called you, you start the phone conversation with
that person on some appropriate subjects. Similarly, the microprocessor will take
some actions appropriate to the interrupt source.
 
Search WWH ::




Custom Search