Atmel CAVR-4 Manuale Utente
![Atmel](https://files.manualsbrain.com/attachments/0369829915bda09f9c2e00fb805a7753579683b5/common/fit/150/50/8d2bf08978ec3e5bc63f4343ac5e91ce8d0e40045619fa520d910d64af8f/brand_logo.png)
CAVR-4
Part 1. Using the compiler
Data storage
17
Note that the location of the pointer variable
p
is not affected by the keyword. In the
following example, however, the pointer variable
p2
is placed in far memory. Like
p
,
p2
points to a character in EEPROM memory.
char _ _eeprom * _ _far p2;
Type definitions
Storage can also be specified using type definitions. The following two declarations are
equivalent:
equivalent:
typedef char _ _far Byte;
typedef Byte *BytePtr;
Byte b;
BytePtr bp;
and
_ _far char b;
char _ _far *bp;
Memory models
The AVR IAR C/C++ Compiler supports a number of memory models that can be used
for applications with different data requirements.
for applications with different data requirements.
Technically, the memory model specifies the default memory type attribute and default
data pointer attribute. This means that the memory model controls the following:
data pointer attribute. This means that the memory model controls the following:
●
The placement of static and global variables, as well as constant literals
●
Dynamically allocated data, for example data allocated with
malloc
, or, in C++,
the operator
new
●
The default pointer type
●
The placement of the runtime stack.
The memory model only specifies the default memory type. It is possible to override this
for individual variables and pointers. For information about how to specify a memory
type for individual objects, see Using data memory attributes, page 19.
for individual variables and pointers. For information about how to specify a memory
type for individual objects, see Using data memory attributes, page 19.
SPECIFYING A MEMORY MODEL
Three memory models are implemented: Tiny, Small, and Large. These models are
controlled by the
controlled by the
--memory_model
option. Each memory model has a default memory
type and a default pointer size. The code size will also be reduced somewhat if the Tiny
or Small memory model is used.
or Small memory model is used.