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.

Compiler/TMS320F28375S: CGTv6.4.4 strange placement with DATA_SECTION

Part Number: TMS320F28375S

Tool/software: TI C/C++ Compiler

We ran into an issue with a data section pragma per below (F28375S, CGTv6.4.4)

 

Linker command simplified for example

MEMORY

{

PAGE 0 : /* Program*/

               MEM1   : origin = 0x00b000, length 0x004000

PAGE 1 : /* Data */

               RAM_STACKS: origin = 0x000002, length 0x0007FE

               CLA_RAM:           origin = 0x008000, length = 0x002000       /* CLA RAM LS0-3 */

}

SECTIONS

{

               My_CLA_RAM    : > CLA_RAM, PAGE =1

}

In a C file, a variable was declared as such

#pragma DATA_SECTION(sample,"CLA_RAM"); // Placed in CLA_RAM instead of MY_CLA_RAM

   Uint16 sample =0;

In the *.h file included by the *.cla file,

extern Uint16 sample;

When placed in CLA_RAM per above, the variable "sample" was located at 0x000002, in the stacks area. No warning was issued.  Of course, when placed in MY_CLA_RAM, no issues.

So just curious as to this placement in the stacks area and why no warning was issued.  This caused a strange debug session with root cause being a variable in RAM which the CLA could not access.

Thanks,

Eric

  • Note that CLA_RAM is a memory range, and My_CLA_RAM is the name of an output section.  Therefore you need to write ...

    #pragma DATA_SECTION(sample,"My_CLA_RAM"); // not CLA_RAM

    This creates an input section named My_CLA_RAM.  Here is the key: You have to match the output section name, not the memory range name.  Because of the name match, this input section becomes part of the My_CLA_RAM output section, and that output section is allocated to the memory range CLA_RAM.

    For more background on memory ranges, output sections, and input sections, please see the first part of the wiki article Linker Command File Primer.

    To keep this from happening again, consider adopting these informal coding conventions:

    • Memory range names are written in all upper case
    • Section names are written in all lower case, and begin with a "."

    Thanks and regards,

    -George