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.

CCS/TMS320F28335: Wrong size memory allocation

Part Number: TMS320F28335

Tool/software: Code Composer Studio

I have a problem with memory allocation.

I use CCS 7.1.0.00016.

When I put two structures into different ram sections, size of data is correct 22x16b + 44x16b.

typedef struct {
    float dat[2];
} complex_float;

typedef struct SlidingGoertzelDFT {
    float32 value[1];
    float32 phase[1];

    struct {
        float32* vr0k;
        float32* vr1k;
        float32* vr2k;
        float32  xn[1];
        complex_float vk[1];

        float32 vr0t[1];
        float32 vr1t[1];
        float32 vr2t[1];
    } tables;
} SlidingGoertzelDFT;

typedef struct PQAHarmonicsPhaseData {
    SlidingGoertzelDFT Voltage;
    SlidingGoertzelDFT Current;
} PQAHarmonicsPhaseData;

typedef struct PQAHarmonicsData {
    PQAHarmonicsPhaseData   L1;
} PQAHarmonicsData;

PQAHarmonicsData PQAHarmonicsMeasurement;


#pragma DATA_SECTION(PQAHarmonicsMeasurement, "DMARAML7");
PQAHarmonicsData PQAHarmonicsMeasurement;

typedef struct ttest {
    float32 value[1];
    float32 phase[1];

    struct {
        float32* vr0k;
        float32* vr1k;
        float32* vr2k;
        float32  xn[1];
        complex_float vk[1];

        float32 vr0t[1];
        float32 vr1t[1];
        float32 vr2t[1];
    } tables;
} ttest;


#pragma DATA_SECTION(ttesttt, "DMARAML6");
ttest ttesttt;


Result of compiler is:

**** Build of configuration Debug for project APF_v0_01 ****

"C:\\ti\\ccs710\\ccsv7\\utils\\bin\\gmake" -k -j 8 all -O 
'Building file: ../_APF/PQA_HarmMeasurement.c'
'Invoking: C2000 Compiler'
"C:/ti/ccs710/ccsv7/tools/compiler/ti-cgt-c2000_17.3.0.STS/bin/cl2000" -v28 -ml -mt --float_support=fpu32 -O1 --opt_for_speed=5 --include_path="C:/ti/workspace_v7/APF_v0_01/_DSP" --include_path="C:/ti/workspace_v7/APF_v0_01/_APF/Headers" --include_path="C:/ti/workspace_v7/APF_v0_01/_APF" --include_path="C:/ti/workspace_v7/APF_v0_01/_DSP/Headers" --include_path="C:/ti/workspace_v7/APF_v0_01/_PCB" --include_path="C:/ti/workspace_v7/APF_v0_01/_PCB/Headers" --include_path="C:/ti/workspace_v7/APF_v0_01/_APF Hardware" --include_path="C:/ti/workspace_v7/APF_v0_01/_APF Hardware/Headers" --include_path="C:/ti/workspace_v7/APF_v0_01" --include_path="C:/ti/ccs710/ccsv7/tools/compiler/ti-cgt-c2000_17.3.0.STS/include" --advice:performance=all --define=_INLINE --define=SAMPLING_51200 --define=DEBUG_DC_HISTOGRAM -g --symdebug:dwarf_version=3 --diag_warning=225 --diag_wrap=off --display_error_number --c_src_interlist --gen_func_info_listing --section_sizes=on --preproc_with_compile --preproc_dependency="_APF/PQA_HarmMeasurement.d" --obj_directory="_APF"  "../_APF/PQA_HarmMeasurement.c"
FILE: _APF\PQA_HarmMeasurement.obj
DATA  size (bytes): 66

But when I change DATA_SECTION of ttesttt also to DMARAML7, I have data size of 108x16b:

**** Build of configuration Debug for project APF_v0_01 ****

"C:\\ti\\ccs710\\ccsv7\\utils\\bin\\gmake" -k -j 8 all -O 
'Building file: ../_APF/PQA_HarmMeasurement.c'
'Invoking: C2000 Compiler'
"C:/ti/ccs710/ccsv7/tools/compiler/ti-cgt-c2000_17.3.0.STS/bin/cl2000" -v28 -ml -mt --float_support=fpu32 -O1 --opt_for_speed=5 --include_path="C:/ti/workspace_v7/APF_v0_01/_DSP" --include_path="C:/ti/workspace_v7/APF_v0_01/_APF/Headers" --include_path="C:/ti/workspace_v7/APF_v0_01/_APF" --include_path="C:/ti/workspace_v7/APF_v0_01/_DSP/Headers" --include_path="C:/ti/workspace_v7/APF_v0_01/_PCB" --include_path="C:/ti/workspace_v7/APF_v0_01/_PCB/Headers" --include_path="C:/ti/workspace_v7/APF_v0_01/_APF Hardware" --include_path="C:/ti/workspace_v7/APF_v0_01/_APF Hardware/Headers" --include_path="C:/ti/workspace_v7/APF_v0_01" --include_path="C:/ti/ccs710/ccsv7/tools/compiler/ti-cgt-c2000_17.3.0.STS/include" --advice:performance=all --define=_INLINE --define=SAMPLING_51200 --define=DEBUG_DC_HISTOGRAM -g --symdebug:dwarf_version=3 --diag_warning=225 --diag_wrap=off --display_error_number --c_src_interlist --gen_func_info_listing --section_sizes=on --preproc_with_compile --preproc_dependency="_APF/PQA_HarmMeasurement.d" --obj_directory="_APF"  "../_APF/PQA_HarmMeasurement.c"
FILE: _APF\PQA_HarmMeasurement.obj
DATA  size (bytes): 108

I can't undesrstand how 22x16 + 44x16 equals 108x16 ???

Because of this I can't fit my data inside ram section.

Can anyone help me in this matter?

  • Hi Lukas,

    Have you checked your .map file, after building your project, for clues as to what is going in to each memory section?

  • Lukas,

    What's happening is the linker is allocating each structure onto a data page boundary, so the structure elements can be accessed with a direct memory addressing mode. One of your structures is 22 words, the other 44 words. In the case you brought up, the 22 words structure is placed on one DP boundary, followed by a "hole" of 42 words, then the 44 words structure is placed on the next DP boundary. The total section size is: 22 + 42 + 44 = 108 words.

    You can reverse the link order to force the larger struct into the lower address, so the hole goes down from 42 words to 20 words. To do this, you would split the structure declarations into separate source files and reference them in your linker file something like this:

    DMARAML7
    {
    PQA_filename.obj (DMARAML7)
    ttesttt_filename.obj (DMARAML7)
    } > RAMX, PAGE = 1

    This way, the overall size will go down from 108 words to: 44 + 20 + 22 = 86 words. You can do something similar to push specific, named variables into those unused 20 words, but the structs need to be DP aligned.

    Regards,

    Richard
  • This is OK. Thank you for your answer.