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.

Data storageThis chapter gives a brief introduction to the memory layout of the <strong>MSP430</strong>microcontroller and the fundamental ways data can be stored in memory: onthe stack, in static (global) memory, or in heap memory. For efficient memoryusage, <strong>MSP430</strong> <strong>IAR</strong> C/<strong>C++</strong> <strong>Compiler</strong> provides a set of data models and datamemory attributes, allowing you to fine-tune the access methods, resulting insmaller code size. The concepts of data models and memory types aredescribed in relation to pointers, structures, Embedded <strong>C++</strong> class objects, andnon-initialized memory. Finally, detailed information about data storage on thestack and the heap is provided.IntroductionThe <strong>MSP430</strong> <strong>IAR</strong> C/<strong>C++</strong> <strong>Compiler</strong> supports <strong>MSP430</strong> devices with both the <strong>MSP430</strong>instruction set and the <strong>MSP430</strong>X extended instruction set, which means that 64 Kbytesand 1 Mbyte of continuous memory can be used. However, the extended instruction setrequires that data—including constant data—interrupt functions, and interrupt vectorsmust be located in the lower 64 Kbytes of memory.Different types of physical memory can be placed in the memory range. A typicalapplication will have both read-only memory (ROM or flash) and read/write memory(RAM). In addition, some parts of the memory range contain processor control registersand memory-mapped registers for peripheral units.The <strong>MSP430</strong>X architecture can access the lower 64 Kbyte using normal instructions andthe entire memory range using more expensive extended instructions. The compilersupports this by means of memory types, where data16 memory corresponds to the lower64 Kbytes and the data20 memory the entire 1 Mbyte memory range. To read more aboutthis, see Memory types (<strong>MSP430</strong>X only), page 15. The data model specifies whichmemory that is used by default, see Data models (<strong>MSP430</strong>X only), page 14.In a typical application, data can be stored in memory in three different ways:●●On the stack. This is memory space that can be used by a function as long as it isexecuting. When the function returns to its caller, the memory space is no longervalid.Static memory. This kind of memory is allocated once and for all; it remains validthrough the entire execution of the application. Variables that are either global ordeclared static are placed in this type of memory. The word static in this contextPart 1. Using the compiler 13

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

Saved successfully!

Ooh no, something went wrong!