全局变量一般都是编译器自动分配在RAM中,
如果我想把全局变量放在固定的地址(绝对地址中)怎么定义?
函数一般是编译器自动分配FLASH地址
如果我想把函数放在固定的地址(绝对地址)怎么办?
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.
peter,
针对变量,
1,在cmd文件中定义一个段
MEMORY {
Memory block for variables : origin = 0x0000, length = 0x000080 /*设置一段存储,用来存放该变量,如果只有一个变量,可以将长度设置为1*/
……
}
SECTIONS {
Section for variable : > Memory block for variables PAGE = 1
……
2,在变量定义的地方,使用下面的语句
#pragma DATA_SECTION(X, "section for variables");
int16 variable;
针对函数,也是类似,
只不过在函数定义的地方
#pragma CODE_SECTION(func, "section for functions");
void func
……
Eric