11.07.2015 Views

MSP430 IAR C/C++ Compiler reference guide - Rice University

MSP430 IAR C/C++ Compiler reference guide - Rice University

MSP430 IAR C/C++ Compiler reference guide - Rice University

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Primitives for interrupts, concurrency, and OS-related programmingextremely important that the environment of the interrupted function is restored after theinterrupt has been handled; this includes the values of processor registers and theprocessor status register. This makes it possible to continue the execution of the originalcode when the code that handled the interrupt has been executed.The <strong>MSP430</strong> microcontroller supports many interrupt sources. For each interruptsource, an interrupt routine can be written. Each interrupt routine is associated with avector number, which is specified in the <strong>MSP430</strong> microcontroller documentation fromthe chip manufacturer. The interrupt vector is the offset into the interrupt vector table. Ifyou want to handle several different interrupts using the same interrupt function, you canspecify several interrupt vectors. For the <strong>MSP430</strong> microcontroller, the interrupt vectortable typically contains 16 vectors and the table starts at the address 0xFFE0. However,some devices contain more than 16 vectors, in which case the vectors start at a loweraddress. For example, if the device has 32 vectors, the table starts at address 0xFFC0.The interrupt vectors are placed in the segment INTVEC. The last entry in the tablecontains the reset vector, which is placed in a separate linker segment—RESET.The header file iodevice.h, where device corresponds to the selected device,contains predefined names for the existing exception vectors.To define an interrupt function, the __interrupt keyword and the #pragma vectordirective can be used. For example:#pragma vector=0x14__interrupt void my_interrupt_routine(void){/* Do something */}Note: An interrupt function must have the return type void, and it cannot specify anyparameters.If a vector is specified in the definition of an interrupt function, the processor interruptvector table is populated. It is also possible to define an interrupt function without avector. This is useful if an application is capable of populating or changing the interruptvector table at runtime. See the chip manufacturer’s <strong>MSP430</strong> microcontrollerdocumentation for more information about the interrupt vector table.Preventing registers from being saved at function entranceAs noted, the interrupt function preserves the content of all used processor register at theentrance and restores them at exit. However, for some very special applications, it canbe desirable to prevent the registers from being saved at function entrance.This can be accomplished by the use of the extended keyword __raw, for example:__raw __interrupt void my_interrupt_function()24<strong>MSP430</strong> <strong>IAR</strong> C/<strong>C++</strong> <strong>Compiler</strong>Reference Guide

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!