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/TMS320F28379D: Struct alignment in CPUtoCLA message RAM

Part Number: TMS320F28379D


Tool/software: TI C/C++ Compiler

Hello,

I defined to different struct for CPU to CLA communication:

#pragma DATA_SECTION(stCpuToClaTask1, "CpuToCla1MsgRAM");
CpuToClaTask1 stCpuToClaTask1;
#pragma DATA_SECTION(stCpuToClaTask2, "CpuToCla1MsgRAM");
CpuToClaTask2 stCpuToClaTask2;

The size of stuct stCpuToClaTask1 is 30 (0x1E) words and the size of stCpuToClaTask2 is 64 (0x40) words.

If I look in .map file, I see that the linker reserves 64 words for first struct (stCpuToClaTask1) so I can not add more variables in second struct. (stCpuToClaTask2):

page     address       name
---- ------- ----

1            00001500    _stCpuToClaTask1
1            00001540    _stCpuToClaTask2

Why the linker reserves more memory as needed for the first struct and what can I do to avoid it?

Thank you in advance!

Gennadi

  • Hi,

    How do you know the size of struct if 0x30 words? Can you share the definition of these struct?

    Regards,

    Vivek Singh

  • Hi,

    the size of the struct is 30d (hex 0x18) words. Here the definition:

    typedef union ThreePhaseABC
    {
        // Three phase values
        struct
        {
            FLOAT32 fl32A; // Phase A
            FLOAT32 fl32B; // Phase B
            FLOAT32 fl32C; // Phase C
        };
        FLOAT32 fl32Value[3];
    } ThreePhaseABC;

    typedef struct CpuToClaTask1
    {
        ThreePhaseABC stScaleFilterVoltage;
        FLOAT32 fl32ScaleDCLinkP;
        FLOAT32 fl32ScaleDCLinkM;
        FLOAT32 fl32FreqShift;
        FLOAT32 fl32Phi3rdHarmonicFreqShift;
        FLOAT32 fl32VrefADC;
        FLOAT32 fl32RotationDirectionFactor;
        UINT32 ui32ResetClaLoad;
        FLOAT32 fl32PrecalculatedPllPhi;
        FLOAT32 fl32FactorForPWMNormalization;
        FLOAT32 fl32AlphaForSync;
        FLOAT32 fl32BetaForSync;
        UINT32 ui32CpuHeartbeat;
    } CpuToClaTask1;

  • Gennadi Starobinski93 said:
    Why the linker reserves more memory as needed for the first struct and what can I do to avoid it?

    These structures ...

    Gennadi Starobinski93 said:
    #pragma DATA_SECTION(stCpuToClaTask1, "CpuToCla1MsgRAM");
    CpuToClaTask1 stCpuToClaTask1;
    #pragma DATA_SECTION(stCpuToClaTask2, "CpuToCla1MsgRAM");
    CpuToClaTask2 stCpuToClaTask2;

    ... are affected by data blocking.  To learn more about data blocking, and whether and how to disable it, please see the article Data blocking in the C2000 MCU compiler explained.

    Thanks and regards,

    -George