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.

Data segmentsThe data segment used for holding the stack is called CSTACK. The system startup codeinitializes the stack pointer to the end of the stack segment.Allocating a memory area for the stack is done differently when you use the commandline interface compared to when you use the <strong>IAR</strong> Embedded Workbench IDE.Stack size allocation in the <strong>IAR</strong> Embedded Workbench IDESelect Project>Options. In the General Options category, click the Stack/Heap tab.Add the required stack size in the Stack size text box.Stack size allocation from the command lineThe size of the CSTACK segment is defined in the linker command file.The default linker file sets up a constant representing the size of the stack, at thebeginning of the linker file:-D_CSTACK_SIZE=sizeNote: Normally, this line is prefixed with the comment character //. To make thedirective take effect, remove the comment character.Specify an appropriate size for your application. Note that the size is writtenhexadecimally without the 0x notation.Placement of stack segmentFurther down in the linker file, the actual stack segment is defined in the memory areaavailable for the stack:-Z(DATA)CSTACK+_CSTACK_SIZE#0200-09FFNote:●●This range does not specify the size of the stack; it specifies the range of theavailable memoryThe # allocates the CSTACK segment at the end of the memory area. In practice,this means that the stack will get all remaining memory at the same time as it isguaranteed that it will be at least _CSTACK_SIZE bytes. See the <strong>IAR</strong> Linker andLibrary Tools Reference Guide for more information.Stack size considerationsThe compiler uses the internal data stack, CSTACK, for a variety of user programoperations, and the required stack size depends heavily on the details of theseoperations. If the given stack size is too large, RAM will be wasted. If the given stack38<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!