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.

MSP430F5338: Query related to place a variable in specified memory location

Part Number: MSP430F5338

Hi all,

I have gone through the following link to understand how to store a
variable in a specified memory location using #pragma in IAR compiler.
processors.wiki.ti.com/.../Placing_Variables_in_Specific_Memory_Location_-_MSP430
Regarding this I have the following queries
1. The statement #pragma location=0x1800 has been used to store the variable port_bit in to the
location of 0x1800. The preprocessor #pragma is replaced during the
preprocessing stage of compilation this preprocessor is replaced but for this case
how it is replaced since it is accessing memory location?
2. Does the code #pragma location=0x1800 is stored in memory? My understanding is this
code is no where stored since it is a preprocessor. Is that correct?

Thanks in advance

  • A "pragma" isn't really a preprocessor directive in the sense that "if" and "ifdef" are. If you would run a source file through a preprocessor, pragmas will be retained in the output.

    Instead, you should think about pragmas as directives to the compiler. In this case, the compiler will ensure that the variable following the directive will be placed on a specific location in memory. You can inspect the list file generated by the compiler to see the difference when you are using the directive as opposed to when it isn't specified.

    -- Anders Lindgren, IAR Systems

**Attention** This is a public forum