How Interrupts Work
1. Interrupt Must Occur
For the processor to respond to an interrupt, it must have occurred. There are many possible
sources of interrupts. Later in this chapter we will delve into the MSP430 datasheet which lists all
of the interrupt sources.
How do Interrupts Work?
• UART
• GPIO
• Timers
• ADC
• Etc.
1. An interrupt occurs
…currently executing code
interrupt occurs
next_line_of_code
}
Suffice it to say that most peripherals can generate interrupts to provide status and information to
the CPU. Most often, the interrupt indicates that data is available (e.g. serial port) and/or an event
has occurred that needs processing (e.g. timer). In some cases, though, an interrupt may be used
to indicate an error or exception in a peripheral that the CPU needs to handle.
Interrupts can also be generated from GPIO pins. This is how an external peripheral, or some
other controller, can signal the MSP430 CPU. Most MSP430 devices allow the pins from the first
two I/O ports (P1 and P2) to be individually configured for interrupt inputs. On the larger devices,
there may be additional ports that can be configured for this, as well.
Finally, your software can often generate interrupts. The logic for some interrupts on the
processor allow you to manually set a flag bit, thus ‘emulating’ a hardware interrupt. Not all
interrupts provide this feature, but when available, it can be a handy way to test your interrupt
service routine.
MSP430 Workshop - Interrupts 5 - 9