首先在main文件中定义下列全局变量
#pragma define_section My_vars "My_vars.bss" RW
/* 1. Define your External memory variables */
#pragma section My_vars begin
Int My_var;
Int My_var1;
Int My_var2;
Int My_var3;
int xTable[100];
#pragma section My_vars end
然后在ldm_pROM_xRAM.cmd 文件中定义下列区间,比如你的RAM从0x10000开始
.x_DataBSS (RW) : ORIGIN = 0x0010000, LENGTH = 0x0003FFFF
......
.....
.....
.ApplicationBSS:
{
# Special section that will be put in beginning of XRAM
* (My_vars.bss)
} > .x_DataBSS
这样连接(linker)过程就将变量放到外部中。注意一定要用ldm (large memory mode) |