Atmel CAVR-4 사용자 설명서
![Atmel](https://files.manualsbrain.com/attachments/0369829915bda09f9c2e00fb805a7753579683b5/common/fit/150/50/8d2bf08978ec3e5bc63f4343ac5e91ce8d0e40045619fa520d910d64af8f/brand_logo.png)
CAVR-4
48
Efficient usage of segments and memory
AVR® IAR C/C++ Compiler
Reference Guide
Note: Take care when explicitly placing a variable or function in a predefined segment
other than the one used by default. This is possible and useful in some situations, but
incorrect placement can result in anything from error messages during compilation and
linking to a malfunctioning application. Carefully consider the circumstances; there
might be strict requirements on the declaration and use of the function or variable.
other than the one used by default. This is possible and useful in some situations, but
incorrect placement can result in anything from error messages during compilation and
linking to a malfunctioning application. Carefully consider the circumstances; there
might be strict requirements on the declaration and use of the function or variable.
C++ static member variables can be placed at an absolute address or in named segments,
just like any other static variable.
just like any other static variable.
Variables and functions can also be placed into named segments using the
--segment
option, in which case you can override the default segment base name. Note that if you
use this method, the object does not need to be declared neither
use this method, the object does not need to be declared neither
_ _no_init
nor
const
as it is only the segment name that will be modified.
Data placement at an absolute location
To place a variable at an absolute address, the argument to the operator
@
and the
#pragma
location
directive should be a literal number, representing the actual
address.
Example
_ _no_init char alpha @ 0x2000;
/* OK */
#pragma location=0x2002
const int beta=5;
/* OK */
const int gamma @ 0x2004 = 3;
/* OK */
int delta @ 0x2006;
/* Error, neither */
/* "_ _no_init" nor "const".*/
See Located data, page 46 for information about how to handle this in the linker
command file.
command file.
Note: A variable placed in an absolute location should be defined in an include file, to
be included in every module that uses the variable. An unused definition in a module
will be ignored. A normal
be included in every module that uses the variable. An unused definition in a module
will be ignored. A normal
extern
declaration—one that does not use an absolute
placement directive—can refer to a variable at an absolute address; however,
optimizations based on the knowledge of the absolute address cannot be performed.
optimizations based on the knowledge of the absolute address cannot be performed.
Data placement into named segments
It is possible to place variables into named segments using either the
@
operator or the
#pragma
location
directive. A string should be used for specifying the segment name.