Atmel CAVR-4 Manuale Utente
CAVR-4
18
Memory types and memory attributes
AVR® IAR C/C++ Compiler
Reference Guide
Your project can only use one memory model at a time, and the same model must be
used by all user modules and all library modules. If you do not specify a memory model
option, the compiler will use the Tiny memory model for all processor options, except
for
used by all user modules and all library modules. If you do not specify a memory model
option, the compiler will use the Tiny memory model for all processor options, except
for
-v4
and
-v6
, where the Small memory model will be used.
The following table summarizes the different memory models:
See the AVR® IAR Embedded Workbench™ IDE User Guide for information about
setting options in IAR Embedded Workbench.
setting options in IAR Embedded Workbench.
Use the
--memory_model
option to specify the memory model for your project; see -m,
Note that the default memory type can be overridden by explicitly specifying a memory
attribute, using either keywords or the
attribute, using either keywords or the
#pragma type_attribute
directive. For more
information about the different memory types, see Memory types and memory
attributes, page 18.
attributes, page 18.
Memory types and memory attributes
This section describes the concept of memory types used for accessing data by the AVR
IAR C/C++ Compiler. It also discusses pointers in the presence of multiple memory
types. For each memory type, the capabilities and limitations are discussed.
IAR C/C++ Compiler. It also discusses pointers in the presence of multiple memory
types. For each memory type, the capabilities and limitations are discussed.
The AVR IAR C/C++ Compiler uses different memory types to access data that is
placed in different areas of the memory. There are different methods for reaching
memory areas, and they have different costs when it comes to code space, execution
speed, and register usage. The access methods range from generic but expensive
methods that can access the full memory range, to cheap methods that can access limited
memory areas. Each memory type corresponds to one memory access method. By
mapping different memories—or part of memories—to memory types, the compiler can
generate code that can access data efficiently.
placed in different areas of the memory. There are different methods for reaching
memory areas, and they have different costs when it comes to code space, execution
speed, and register usage. The access methods range from generic but expensive
methods that can access the full memory range, to cheap methods that can access limited
memory areas. Each memory type corresponds to one memory access method. By
mapping different memories—or part of memories—to memory types, the compiler can
generate code that can access data efficiently.
For example, the memory accessible using the near memory access method is called
memory of near type, or simply near memory.
memory of near type, or simply near memory.
Memory
model
Default memory
attribute
Default data
pointer
Max stack size
Supported by processor
option
Tiny
_ _tiny
_ _tiny
≤ 256 bytes
-v0
, -v1, -v2, -v3, -v5
Small
_ _near
_ _near
≤ 64 Kbytes
-v1
, -v3, -v4, -v5, -v6
Large
_ _far
_ _far
≤ 16 Mbytes
-v4
, -v6
Table 6: Memory model characteristics