MDK帮助文档里面写的还是比较清楚:
__attribute__((at(address))) variable attribute
| |||
Home > Compiler-specific Features > __attribute__((at(address))) variable attribute |
This variable attribute enables you to specify the absolute address of a variable.
The variable is placed in its own section, and the section containing the variable is given an appropriate type by the compiler:
-
Read-only variables are placed in a section of type RO.
-
Initialized read-write variables are placed in a section of type RW.
Variables explicitly initialized to zero are placed in:
-
A section of type ZI in RVCT 4.0 and later.
-
A section of type RW (not ZI) in RVCT 3.1 and earlier. Such variables are not candidates for the ZI-to-RW optimization of the compiler.
-
-
Uninitialized variables are placed in a section of type ZI.
The linker is not always able to place sections produced by the at
variable attribute.
The compiler faults use of the at
attribute when it is used on declarations with incomplete types.
The linker gives an error message if it is not possible to place a section at a specified address.
=====================================================================
关于RAM初始化不为0
Noinit selects areas that should be excluded from zero initialization。
NoInit | Specifies areas that should be excluded from zero initialization. |
NOINIT
Indicates that the data section is uninitialized, or initialized to zero. It contains only space reservation directives SPACE
or DCB
, DCD
, DCDU
, DCQ
, DCQU
, DCW
, or DCWU
with initialized values of zero. You can decide at link time whether an area is uninitialized or zero initialized.
NOINIT的资料网上非常少。看样子大家用的不多啊。
MDK的target界面有个选项NOINIT ,看样子只能靠这个设置了。还是比较靠谱。