Atmel CAVR-4 사용자 설명서

다운로드
페이지 323
CAVR-4
Part 2. Compiler reference
Extended keywords
207
_ _farfunc
Controls the storage of functions in code memory space.
The 
_ _farfunc
 memory attribute places a function in farfunc code memory space.
Functions declared 
_ _farfunc
 have no restrictions on code placement, and can be 
placed anywhere in code memory.
The default code pointer for the 
-v5
 and 
-v6
 processor options is 
_ _farfunc
, and it 
only affects the size of the function pointers. 
Note that pointers with function memory attributes have restrictions in implicit and 
explicit casts when casting between pointers and also when casting between pointers 
and integer types.
It is possible to call a 
_ _nearfunc
 function from a 
_ _farfunc
 function and vice versa. 
Only the size of the function pointer is affected.
_ _flash
Controls the storage of data objects in flash (code) memory space.
The 
_ _flash
 memory attribute places objects in flash (code) memory.
Note that it is preferable to declare flash objects as constant. The 
_ _flash
 keyword is 
available for all AVR chips.
Because the AVR microcontrollers have only a small amount of on-board RAM, this 
memory should not be wasted on data that could be stored in flash memory (of which 
there is much more). However, because of the architecture of the processor, a default 
pointer cannot access the flash memory. The 
_ _flash
 keyword is used to identify that 
the constant should be stored in flash.
A header file called 
pgmspace.h
 is installed in the 
avr\inc
 directory, to provide some 
standard C library functions for taking strings stored in flash memory as arguments.
Examples
A program defines a couple of strings that are stored in flash memory:
_ _flash char str1[] = "Message 1";
_ _flash char str2[] = "Message 2";
The program creates a 
_ _flash
 pointer to point to one of these strings, and assigns it 
to 
str1
:
char _ _flash *msg;
  msg=str1;
Address range
Pointer size
0-0x7FFFFE
 (8 Mbytes)
24 bits
Table 59: Farfunc pointer size