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.

TM4C123GH6PM: #pragma DATA_SECTION cannot create a data section which i can use for an array

Part Number: TM4C123GH6PM

Tool/software:


I tried to modify SRAM in TM4C123GHPM into two parts one for MSP and system variables 0x20000000 ,length =0x1000; and for PSP i have set up ox20001000 ,length =0x7000 till end of SRAM . I have named region heap


--retain=g_pfnVectors

MEMORY
{
    FLASH (RX) : origin = 0x00000000, length = 0x00040000
    SRAM (RWX) : origin = 0x20000000, length = 0x00001000  // 32KB
  //  STACK (RW) : origin = 0x20000000, length = 0x00001000  // 4KB
    HEAP (RWX) : origin = 0x20001000, length = 0x00007000  // 28KB
}

/* 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
    .heap : ALIGN(4)> HEAP
}

__STACK_TOP = __stack + 512;

But when i write a DATA_SECTION pragma as follows it compiles but when i try to access array i get a bus fault

#pragma DATA_SECTION(myHeap, ".heap")
static uint8_t myHeap[16]; // Global heap memory

uint8_t *a=myHeap; // i can step through this line

*a=23; // but when i access memory allocated here i get bus fault
a=a+4;

*a=32;

My question is DATA_SECTION pragma , does it allocate memory for region i have mentioned . please suggest a better way to write cmd file data sections