Atmel CAVR-4 Manual De Usuario

Descargar
Página de 323
CAVR-4
20
Memory types and memory attributes
AVR® IAR C/C++ Compiler
Reference Guide
The keywords are only available if language extensions are enabled in the AVR IAR 
C/C++ Compiler.
In IAR Embedded Workbench, language extensions are enabled by default.
Use the 
-e
 compiler option to enable language extensions. See -e, page 179 for 
additional information.
POINTERS AND MEMORY TYPES
Pointers are used for referring to the location of data. In general, a pointer has a type. 
For example, a pointer that has the type 
int
 
*
 points to an integer. 
In the AVR IAR C/C++ Compiler, a pointer also points to some type of memory. The 
memory type is specified using a keyword before the asterisk. 
For example, a pointer that points to an integer stored in farflash memory is declared by: 
int
 
_ _farflash *
 p;
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 tiny memory. Like 
p
p2
 points to a character in farflash memory.
char _ _farflash * _ _tiny p2; 
Whenever possible, pointers should be declared without memory attributes. For 
example, the functions in the standard library are all declared without explicit memory 
types.
_ _generic
2 bytes
3 bytes
Data or Code
The most significant bit (MSB) 
determines whether this pointer 
points to code space (1) or data 
space (0). The small generic 
pointer is generated for the 
processor options -v0 and -v1.
32 Kbytes
8 Mbytes
_ _regvar
N/A
Data
0x4–0x0F
4 bytes
Memory 
attribute
Pointer size Memory space
Address range
Max object 
size
Table 7: Memory attributes for data  (Continued)