How Interrupts Work
Nesting Interrupts (not recommended)
Finally, while the MSP430 allows nesting of interrupts, it is not recommended.
• Nesting interrupts means one interrupt can interrupt another interrupt.
• You must manually configure nesting. That is, before running your interrupt handling code
you must:
− Disable any interrupts that you do not want to occur during your ISR. In other words, you
must first save, then disable, any IE bit that correlates to an interrupt that you do not want
to interrupt your ISR.
− Then, turn on interrupts globally by setting GIE = 1.
− At this point you can run your code that responds to the original interrupt. It may end up
being interrupted by any source that you left enabled.
− When you’ve completed your original interrupt code, you need to disable interrupts before
returning from the function. That is, set GIE = 0. (This is the state GIE was in when
entering your ISR code.
− You can now restore the IE bits that you saved before enabling GIE.
− At this point, you can return from the ISR and let the compiler’s code handle the
remaining context save and return branch back to the original thread.
• In general, it’s considered better programming practice to keep interrupt service routines very
short – i.e. lean-and-mean. Taking this further, with low-power and efficiency in mind, the
MSP430 team recommends you follow the no-nesting general principle.
Hint: We encourage you to avoid nesting, if at all possible. Not only is it difficult, and error
prone, it often complicates your programs ability to reach low-power modes.
5 - 16 MSP430 Workshop - Interrupts