1、link文件(icf文件)中定义该段ram标识
如我定义到dtcm中:
define symbol __region_DTCM_RAM_start__ = 0x20000000;
define symbol __region_DTCM_RAM_end__ = 0x2003FFFF;
define region DTCM_RAM_region = mem:[from __region_DTCM_RAM_start__ to __region_DTCM_RAM_end__];
place in DTCM_RAM_region { readwrite section DTCM_Section_USR };
这里我定义了一个section DTCM_Section_USR,他的范围是从0x20000000到0x2003FFFF,共256k大小
2、在c中加入定义
.c的源文件
#include “xx.h”
#pragma default_variable_attributes = @ "DTCM_Section_USR"
全局变量1;
全局变量2;
全局变量3;
...
函数1;
函数2;
...
#pragma default_variable_attributes =
//结束
#pragma default_variable_attributes = @ "DTCM_Section_USR" //表示下面定义的变量定义在DTCM_Section_USR部分中
#pragma default_variable_attributes = //表示取消指定地址定义变量
---------------------------------我是分隔线--------------------------------------------------------------------------------
3、拓展,把source.c所有的函数指定到指定地址运行
place in DTCM_RAM_region { readonly object source.o };
这里是将所有函数放到DTCM_RAM_region 区域里
还有一种方法:使用default_function_attributes
//icf文件
define region FUNC_region = mem:[ from 0x70000 to 0x70FFF ];
place in FUNC_region { readonly section MY_FUNC };
//c文件
#pragma default_function_attributes = @ "MY_FUNC"
函数1;
函数2;
...
/* 停止函数安放在MY_FUNC段中 */
#pragma default_function_attributes =