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...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Efficient coding for embedded applications●●different parts of memory. To read more about data models, see Data models(<strong>MSP430</strong>X only), page 14.Memory attributes (<strong>MSP430</strong>X only)Use memory attributes to override the default addressing mode and placement ofindividual data objects. To read more about memory attributes for data, see Usingdata memory attributes, page 16.The @ operator and the #pragma location directive for absolute placementUse the @ operator or the #pragma location directive to place individual globaland static variables at absolute addresses. The variables must be declared either__no_init or const. This is useful for individual data objects that must be locatedat a fixed address, for example variables with external requirements, or forpopulating any hardware tables similar to interrupt vector tables. Note that it is notpossible to use this notation for absolute placement of individual functions.● The @ operator and the #pragma location directive for segment placementUse the @ operator or the #pragma location directive to place groups of functionsor global and static variables in named segments, without having explicit control ofeach object. The variables must be declared either __no_init or const. Thesegments can, for example, be placed in specific areas of memory, or initialized orcopied in controlled ways using the segment begin and end operators. This is alsouseful if you want an interface between separately linked units, for example anapplication project and a boot loader project. Use named segments when absolutecontrol over the placement of individual variables is not needed, or not useful.At compile time, data and functions are placed in different segments as described inData segments, page 35, and Code segments, page 41, respectively. At link time, one ofthe most important functions of the linker is to assign load addresses to the varioussegments used by the application. All segments, except for the segments holdingabsolute located data, are automatically allocated to memory according to thespecifications of memory ranges in the linker command file, as described in Placingsegments in memory, page 32.DATA PLACEMENT AT AN ABSOLUTE LOCATIONThe @ operator, alternatively the #pragma location directive, can be used for placingglobal and static variables at absolute addresses. The variables must be declared__no_init and/or const. If declared const, they must have an initializer unless theyare declared __no_init. To place a variable at an absolute address, the argument to the@ operator and the #pragma location directive should be a literal number,representing the actual address. The absolute location must fulfill the alignmentrequirement for the variable that should be located.<strong>C++</strong> static member variables can be placed at an absolute address just like any otherstatic variable.Part 1. Using the compiler117

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

Saved successfully!

Ooh no, something went wrong!