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 in TM4C123GH6PM

Part Number: TM4C123GH6PM

Hi Everyone,

I am using TM4C123GH6PM controller. I want to store lookup table in FLASH. For that i have used #pragma DATA_SECTION, but during debugging it is giving me warning as described below and i am unable to call the value which i have stored.

Following Sequence i have followed, please guide me if i have missed something or did anything wrong.

1) In tm4c123gh6pm.cmd file

MEMORY
{

    CHANNEL0   : origin = 0x20009000, length = 0x0006000

}

SECTIONS
{

 .channel0   : {} > CHANNEL0

}

2) In main.c

#pragma DATA_SECTION (pwmlkp, ".channel0")

const unsigned int pwmlkp[18]={86,93,103,115,125,136,145,159,169,181,192,206,216,226,235,245,256,265};

3) Warning during debug

CORTEX_M4_0: GEL Output:
Memory Map Initialization Complete
CORTEX_M4_0: Loader: One or more sections of your program falls into a memory region that is not writable. These regions will not actually be written to the target. Check your linker configuration and/or memory map.

4) Expression Window

[0] unknown Memory map prevented reading 0x20009000

[1] unknown Memory map prevented reading 0x20009004 

.

.

.

[17] unknown Memory map prevented reading 0x20009044

  • CHANNEL0   : origin = 0x20009000, length = 0x0006000

    The TM4C123GH6PM has 32KB of SRAM from addresses 0x20000000 .. 0x20007FFF, and the CHANNEL0 memory region is in a reserved address space as shown by the datasheet::

    The CHANNEL0 memory region being in a reserved address space is what leads to the warnings. Also attempts to read or write addresses in reserved spaces result in a bus fault which will cause the program to fail when it attempts to read pwmlkp[].

    I want to store lookup table in FLASH.

    In which case, the CHANNEL0 memory region should be allocated from the memory range for the on-chip flash.

  • >    CHANNEL0   : origin = 0x20009000, length = 0x0006000

    Per data sheet (SPMS376E) Table 2-4, this is Reserved, i.e. not any kind of memory. Did you maybe mean:

    >    CHANNEL0   : origin = 0x00009000, length = 0x0006000

  • Hi Sir,

    Understood, because of out of the range, i am getting warning.

    Now i have changed the memory range

    CHANNEL0   : origin = 0x00001000, length = 0x0006000.

    So, now i am able compile without warning.

    But, still i am unable to store data.

    I have checked Memory browser its value is FFFFFFFF.

    Once, array is stored. Then how to recall/get that array?

  • Hello Divyesh,

    Can you post the full .cmd file here as an attachment so I can review the contents?

  • Hi Sir,

    Sure, please find below the details of .cmd file

    /******************************************************************************
    *
    * Default Linker Command file for the Texas Instruments TM4C123GH6PM
    *
    * This is derived from revision 15071 of the TivaWare Library.
    *
    *****************************************************************************/

    --retain=g_pfnVectors

    MEMORY
    {
    CHANNEL0 : origin = 0x00001000, length = 0x0006000
    FLASH (RX) : origin = 0x00012000, 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: > 0x00012000
    .text : > FLASH
    .const : > FLASH
    .cinit : > FLASH
    .pinit : > FLASH
    .init_array : > FLASH

    .channel0 : {} > CHANNEL0

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

    }

    __STACK_TOP = __stack + 512;

  • Hello Divyesh,

    You need to indicate what permissions this section of memory should have in your definition:

    CHANNEL0 : origin = 0x00001000, length = 0x0006000

    See how it is done for Flash:

    FLASH (RX) : origin = 0x00012000, length = 0x00040000

    R is for Read, X is for Execute, and W is for Write.