This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Heap Size and Stack Size in TM4C123GH6PM

Other Parts Discussed in Thread: TM4C123GH6PM

Hi,

I am having problems with stack size and/or heap size. I am programming in Keil 5 and the program run very well, but the same program in CCS 6 not working.

The file startup_ARMC4.s in Keil have:

; <h> Stack Configuration
;   <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>

Stack_Size      EQU     0x00000400

                AREA    STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem       SPACE   Stack_Size
__initial_sp


; <h> Heap Configuration
;   <o>  Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>

Heap_Size       EQU     0x00000C00

                AREA    HEAP, NOINIT, READWRITE, ALIGN=3
__heap_base
Heap_Mem        SPACE   Heap_Size
__heap_limit


                PRESERVE8
                THUMB

and the memory area are:

In the file tm4c123gh6pm.cmd say:

MEMORY
{
    FLASH (RX) : origin = 0x00000000, length = 0x00040000
    SRAM (RWX) : origin = 0x20000000, length = 0x00008000
}

/* The following command line options are set as part of the CCS project.    */
/* If you are building using the command line, or for some reason want to    */
/* define them here, you can uncomment and modify these lines as needed.     */
/* If you are using CCS for building, it is probably better to make any such */
/* modifications in your CCS project and leave this file alone.              */
/*                                                                           */
/* --heap_size=0                                                             */
/* --stack_size=256                                                          */
/* --library=rtsv7M4_T_le_eabi.lib                                           */

/* Section allocation in memory */

SECTIONS
{
    .intvecs:   > 0x00000000
    .text   :   > FLASH
    .const  :   > FLASH
    .cinit  :   > FLASH
    .pinit  :   > FLASH
    .init_array : > FLASH

    .vtable :   > 0x20000000
    .data   :   > SRAM
    .bss    :   > SRAM
    .sysmem :   > SRAM
    .stack  :   > SRAM
}

__STACK_TOP = __stack + 512;

Why the memory areas are differents?

For my program to work in CCS, I have to increase the size of the stack to 2048


The same program compiled in CCS and KEIL, how to compare the code size of both compilers?


For what the heap size is used and for what the stack size used?

Is it possible to determine the optimal stack size and heap size?, to avoid wasting memory.

Best Regards,

Fernando.

  • Hello Fernando,

    The CCS default and Keil defaults used are different, so the same appears in the startup file or cmd files. I am not sure but a monitor of the stack size using profiling tool should be useful (again I am not sure and hence would recommend CCS forum).

    Regards
    Amit