11.07.2015 Views

Imagecraft c compiler and development environment for the atmel avr

Imagecraft c compiler and development environment for the atmel avr

Imagecraft c compiler and development environment for the atmel avr

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

ICCV8 <strong>for</strong> AVR – C Compiler <strong>for</strong> Atmel AVRStack <strong>and</strong> Heap FunctionsBesides static program areas, <strong>the</strong> C runtime <strong>environment</strong> contains two additional dataregions: <strong>the</strong> stack area <strong>and</strong> <strong>the</strong> heap area. The stack is used <strong>for</strong> procedure calls, local<strong>and</strong> temporary variables, <strong>and</strong> parameter passing. The heap is used <strong>for</strong> dynamicallyallocated objects created by <strong>the</strong> st<strong>and</strong>ard C malloc(), calloc(), <strong>and</strong> realloc()calls. To use <strong>the</strong> heap functions, you must first initialize <strong>the</strong> heap region. See St<strong>and</strong>ardLibrary And Memory Allocation Functions.There is no provision <strong>for</strong> stack overflow checking, so you must be careful not tooverrun your stack. For example, a series of recursive calls with a large amount oflocal variables would eat up <strong>the</strong> stack space quickly. When <strong>the</strong> stack runs into o<strong>the</strong>rvalid data, or if it runs past valid addresses, <strong>the</strong>n Bad Things Can Happen (tm). Thestack grows downward toward <strong>the</strong> lower addresses. IIf you use #pragma text / data / lit / abs_address to assign your ownmemory areas, you must manually ensure that <strong>the</strong>ir addresses do not overlap <strong>the</strong>ones used by <strong>the</strong> linker. As an attempt to overlap allocation may or may not cause <strong>the</strong>linker to generate an error, you should always check <strong>the</strong> .mp map file. Use <strong>the</strong> IDEmenu selection (View->Map File) <strong>for</strong> potential problems.152

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

Saved successfully!

Ooh no, something went wrong!