可以使用绝对定址符"@"或预处理命令#pragma location来指定一个变量的地址。 1. 对于不需要初始化的变量: __no_init int x @ 0x20001000; 或: #pragma location=0x20001000 __no_init int x; 2. 对于不需要指定初值的常量: __no_init const int y @ 0x08010000; 或: #pragma location=0x08010000 __no_init const int y; 3. 对于需要指定初值的常量: 在定义该常量时,把它分配到自定义的section中,例如MYCONST: const int a @ "MYCONST" = 0x12345678; 或: #pragma location="MYCONST" const int a = 0x12345678; 然后在icf文件中指定MYCONST的地址: place at address mem:0x08010000 { section MYCONST }; |
|
来自: BeautymengRoom > 《嵌入式系统》