Atmel CAVR-4 Manual De Usuario
CAVR-4
Part 1. Using the compiler
Data storage
19
By selecting a memory model, you have selected a default memory type that your
application will use. However, it is possible to specify—for individual variables or
pointers—different memory types. This makes it possible to create an application that
can contain a large amount of data, and at the same time make sure that variables that
are used often are placed in memory that can be efficiently accessed.
application will use. However, it is possible to specify—for individual variables or
pointers—different memory types. This makes it possible to create an application that
can contain a large amount of data, and at the same time make sure that variables that
are used often are placed in memory that can be efficiently accessed.
USING DATA MEMORY ATTRIBUTES
The AVR IAR C/C++ Compiler provides a set of extended keywords, which can be used
as data memory attributes. These keywords let you override the default memory type for
individual data objects, which means that you can place data objects in other memory
areas than the default memory. This also means that you can fine-tune the access method
for each individual data object, which results in smaller code size.
as data memory attributes. These keywords let you override the default memory type for
individual data objects, which means that you can place data objects in other memory
areas than the default memory. This also means that you can fine-tune the access method
for each individual data object, which results in smaller code size.
Summary of characteristics of memory attributes
The following table summarizes the available memory attributes:
Memory
attribute
Pointer size Memory space
Address range
Max object
size
_ _tiny
1 byte
Data
0-0xFF
128 bytes
_ _near
2 bytes
Data
0-0xFFFF
32 Kbytes
_ _far
3 bytes
Data
0-0xFFFFFF
(16-bit pointer
arithmetics)
32 Kbytes
_ _huge
3 bytes
Data
0-0xFFFFFF
8 Mbytes
_ _tinyflash
1 byte
Code
0-0xFF
128 bytes
_ _flash
2 bytes
Code
0-0xFFFF
32 Kbytes
_ _farflash
3 bytes
Code
0-0xFFFFFF
(16-bit pointer
arithmetics)
32 Kbytes
_ _hugeflash
3 bytes
Data
0-0xFFFFFF
8 Mbytes
_ _eeprom
1 bytes
EEPROM
0-0xFF
128 bytes
_ _eeprom
2 bytes
EEPROM
0-0xFFFFFF
32 Kbytes
_ _io
N/A
I/O space
0–0x3F
4 bytes
_ _io
N/A
Data
0x60–0xFF
4 bytes
_ _ext_io
N/A
Data
0x100–0xFFFF
4 bytes
Table 7: Memory attributes for data