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.

Controlling data and function placement in memoryvoid f(void){st.l = 5;}The member names must be unique in the surrounding scope. Having an anonymousstruct or union at file scope, as a global, external, or static variable is also allowed.This could for instance be used for declaring I/O registers, as in the following example:__no_init volatileunion{unsigned char IOPORT;struct{unsigned char way: 1;unsigned char out: 1;};} @ 0x1234;This declares an I/O register byte IOPORT at the address 0x1234. The I/O register has 2bits declared, way and out. Note that both the inner structure and the outer union areanonymous.The following example illustrates how variables declared this way can be used:void test(void){IOPORT = 0;way = 1;out = 1;}Anonymous structures and unions are implemented in terms of objects named after thefirst field, with a prefix _A_ to place the name in the implementation part of thenamespace. In this example, the anonymous union will be implemented through anobject named _A_IOPORT.Controlling data and function placement in memoryThe compiler provides different mechanisms for controlling placement of functions anddata objects in memory. To use memory efficiently, you should be familiar with thesemechanisms to know which one is best suited for different situations. You can use:●Data models (<strong>MSP430</strong>X only)Use the compiler option for selecting a data model, to take advantage of the differentaddressing modes available for the microcontroller and thereby place data objects in116<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!