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/MSP430FR5969: Place part of a structure in specific memory location using DATA_SECTION pragma

Part Number: MSP430FR5969

Tool/software: TI C/C++ Compiler

I'm familiar with the DATA_SECTION #pragma directive and have used it.  What I want to do is just put part of a structure into a specific data section, specifically into non-volatile memory.  For example this structure.

typedef struct 
{
    uint16_t RegA_NonVolatile;
    uint16_t RegB_Volatile;
} RegStruct_t;

static RegStruct_t RegData;

// THIS WORKS, BUT PUTS THE WHOLE STRUCTURE IN customNV, not what I want.
#pragma DATA_SECTION (RegData, ".customNV") 

// THIS FAILS AT THE PERIOD
#pragma DATA_SECTION (RegData.RegA_NonVolatile, ".customNV")

The error that I get is "expected a ," right where I have the dot drilling down into the structure.

Is there any way to put just one part of a structure into memory using DATA_SECTION?

  • Russell Merrick said:
    Is there any way to put just one part of a structure into memory using DATA_SECTION?

    Unfortunately, no.  The C standard requires all members of a structure to be contiguous in memory, in the same order as the source.  Note that, due to alignment requirements, there may be gaps between members.

    Thanks and regards,

    -George

**Attention** This is a public forum