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.

Placing code and datasize is too small memory might be overwritten leading to undefined behavior. Becauseof this, you should consider placing the stack at the end of the RAM memory.THE HEAPThe heap contains dynamic data allocated by use of the C function malloc (or one ofits relatives) or the <strong>C++</strong> operator new.If your application uses dynamic memory allocation, you should be familiar with thefollowing:●●●Linker segments used for the heapAllocating the heap size, which differs depending on which build interface you areusingPlacing the heap segments in memory.Heap segments in DLIBFor <strong>MSP430</strong> devices and <strong>MSP430</strong>X devices in the Small data model, one heap isavailable. It is placed in default memory; data16 in the Small and Medium data model(the DATA16_HEAP segment), and data20 in the Large data model (the DATA20_HEAPsegment).For <strong>MSP430</strong>X devices, the DLIB runtime environment supports heaps in both data16and data20 memory. The heaps are placed in segments named DATA16_HEAP andDATA20_HEAP.To use a heap in a specific memory, use the appropriate memory attribute as a prefix tothe standard functions malloc, free, calloc, and realloc, for example:__data16_mallocIf you use any of the standard functions without a prefix, memory is allocated on theheap that corresponds to the default memory type. That is, data16 in the Small andMedium data model, and data20 in the Large data model.For more information about heaps, see Heaps, page 68.Heap segments in the CLIB runtime environmentIn the CLIB runtime environment one heap is available. It is placed in default memory;data16 in the Small and Medium data model (the DATA16_HEAP segment), and data20in the Large data model (the DATA20_HEAP segment).Heap size allocation in the <strong>IAR</strong> Embedded Workbench IDESelect Project>Options. In the General Options category, click the Stack/Heap tab.Part 1. Using the compiler39

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

Saved successfully!

Ooh no, something went wrong!