If you want to place global variables in your external memory, you can use the section pragmas. The Default LDF has sections and commands defined to allow the placement of data in external memory. For example, the MEMORY{...} block in the LDF contains the section:seg_ext_dmda { TYPE(DM RAM) START(0x00900000) END(0x01DFFFFD) WIDTH(16) }

So, if you wanted to place a global variable in this location, and ensure it doesn't get placed in internal memory, just use either of the two 'input section' names listed here that are not "seg_dmda". So, either of these would work:#pragma input_section("seg_ext_data")int GlobalVariable1#pragma input_section("seg_sdram")int GlobalVariable2

Similarly, if you wanted to make sure a function is placed in SDRAM, there is a "seg_ext_code" section defined in the MEMORY{...} block, with a matching set of INPUT_SECTIONS commands, and a 'section' pragma can be used to force the function in here.

If you want to allocate local data from SDRAM, you would need to move the stack/heap to SDRAM by editing the LDF. It is possible to work with multiple heaps (see the section "C/C++ Compiler Manual for SHARC(r) Processors > 1 Compiler > C/C++ Run-Time Model and Environment > Using Multiple Heaps"), however there can only be one stack.

3. Can I modified the LDF to resize the data memory space as I want? How to do it?

ANS>>

To modify the LDF can you please refer the below linked Ezone FAQ which might help you:FAQ: How do you modify a generated LDF during project creation in CCES?https://ez.analog.com/docs/DOC-2404

4. sometimes l find variable will modified by unkown reason, what should I do to protect these global variable? using "static"?

ANS>>

If you are reporting that the global variables in an application (using default ldf) get reset to "zero" (statically) explicitly. Please note that this is a feature of the C programming languages - static storage duration objects that are not explicitly initialized are implicitly initialized to zero. When an application is downloaded using VisualDSP++ or CCES initializations are done by the emulation support. When not connecting using VisualDSP++ or CCES, initializations are done by the boot kernel.

You can avoid specific global or static variable being initialized using #pragma section with the NO_INIT section qualifier to place the data in a non-default input section. That would also require an LDF addition to map the new section containing the NO_INIT variables to memory appropriately.

For example in C source you would have:

#pragma section("no_init_data", NO_INIT)char noInitBuffer[N];

And in the LDF would include the input as follows in the SECTION() area: