Specifications
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.
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.
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