EasyManuals Logo

Texas Instruments MSP430 Student Guide

Texas Instruments MSP430
398 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #213 background imageLoading...
Page #213 background image
Coding Interrupts
We will use the following code example to demonstrate these three items.
#pragma vector=WDT_VECTOR
__interrupt void myWdtISR(void) {
GPIO_toggleOutputOnPin( ... );
}
Interrupt Service Routine (Dedicated INT)
#pragma vector assigns
myISR’ to correct location
in vector table
__interrupt keyword tells
compiler to save/restore
context and RETI
INT Source
IV Register
Vector Address
Loc’n
WDT Interval Timer
WDTIFG
WDT_VECTOR
57
For a dedicated
interrupt, the MSP430
CPU auto clears the
WDTIFG flag
Plug the Vector Table (#pragma vector)
In our example, the following line of code:
#pragma vector=WDT_VECTOR
tells the compiler to associate the function (on the following line) with the WDT_VECTOR.
Looking in the MSP430F5529 device-specific linker command file, you should find this vector
name (WDT_VECTOR) associated with vector #57. This matches with the datasheet
documentation we looked at earlier in the chapter.
Save/Restore CPU context (__interrupt keyword)
The __interrupt keyword tells the compiler that this function is an interrupt service routine and
thus it needs to save (and then restore) the context of the processor (i.e. CPU registers) before
(and after) executing the function’s code.
Don’t forget, functions using the __interrupt keyword cannot accept arguments or return values.
Hint: Empirical analysis shows that “__interrupt” and “interrupt” are both accepted by the
compiler.
Your Interrupt Code
In this example, the output of a GPIO pin is toggled every time the watchdog timer interrupt event
occurs. Not all ISRs will be this short, but we hope this gives you a good starting example to work
from.
MSP430 Workshop - Interrupts 5 - 23

Table of Contents

Other manuals for Texas Instruments MSP430

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Texas Instruments MSP430 and is the answer not in the manual?

Texas Instruments MSP430 Specifications

General IconGeneral
BrandTexas Instruments
ModelMSP430
CategoryMicrocontrollers
LanguageEnglish

Related product manuals