cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 stack and heap

Moamen Ayman
Associate III

Hello I want to understand allocating stack and heap size, I am using stm32f767zi with 512Kbyte RAM memory (0x80000 bytes) so what I understand is this memory should be split between only the stack and heap (if there is something else please tell me) so I gave the stack 0x60000 and the heap 0x20000 as in the attached photo. I am using IAR v8.

4 REPLIES 4

No.

You need RAM also for global and static variables.

Stack is where the return addresses and register content and some other "helper" data are stored when calling subroutines, together with variables declared locally in functions (without static specifier).

Heap is where dynamically allocated (usually through calling malloc()) variables are stored.

JW

> Heap is where dynamically allocated (usually through calling malloc()) variables are stored.

Actually, most toolchains set a default value of zero for the heap size. Many embedded projects do not use dynamic memory allocation at all.

Moamen Ayman
Associate III

So the RAM for only (global/static) (stack) (heap) is there something else?

You can read up about C language memory/section management (variable placement) in general C tutorials.

And virtually all toolchains can create a map file during the linker run, an exhausting list of object (variable, code) sizes and placement.