Atmel CAVR-4 Manual De Usuario

Descargar
Página de 323
CAVR-4
Part 1. Using the compiler
Placing code and data
41
address of a constant 
_ _flash
 object and use it as a default pointer object, the compiler 
will issue an error. If you make an explicit cast of the object to a default pointer object, 
the error message disappears, instead there will be problems at run-time as the cast 
cannot copy the object from the flash memory to the data memory.
Note: To access strings located in flash, you must use alternative library routines that 
expect flash strings. A few such alternative functions are provided in the 
pgmspace.h
 
header file. They are flash alternatives for some common C library functions with an 
extension 
_P
. For your own code, you can always use the 
_ _flash
 keyword when 
passing the strings between functions. For reference information about the alternative 
functions, see AVR–specific library functions, page 249.
SEGMENTS FOR STATIC DATA IN THE LINKER COMMAND 
FILE
As described in the section Static memory segments, page 37, static data can be placed 
in many different segments depending on the application requirements and your target 
system. In the linker command file the segment definitions can look like this:
/* First the segments to be placed in ROM are defined */
-Z(CODE)TINY_F=0-FF
-Z(CODE)NEAR_F=0-1FF
-Z(CODE)TINY_ID,NEAR_ID=0-1FFF
/* Then, the RAM data segments are defined */
-Z(DATA)TINY_I,TINY_Z,TINY_N=60-FF
-Z(DATA)NEAR_I,NEAR_Z=60-25F
/* Then the segments to be placed in external EPROM are defined 
*/ 
-Z(DATA)NEAR_C=_EXT_EPROM_BASE:+_EXT_EPROM_SIZE
/* The _EXT_EPROM_BASE and _EXT_EPROM_SIZE symbols are defined in 
the linker command file template, where they have the value 0. If 
you want to use those symbols, you must provide values that suit 
the hardware. This method can also be used for placing other 
types of objects in the external memory space. */
THE DATA STACK 
The data stack is used by functions to store auto variables, function parameters and 
temporary storage that is used locally by functions, as described in the chapter Data 
storage
. It is a continuous block of memory pointed to by the processor stack pointer 
register 
Y
The data segment used for holding the stack is called 
CSTACK
. The system startup code 
initializes the stack pointer to the end of the stack segment.