Atmel CAVR-4 Manual De Usuario

Descargar
Página de 323
CAVR-4
Part 1. Using the compiler
Placing code and data
43
THE RETURN ADDRESS STACK 
The return address stack is used for storing the return address when a 
CALL
RCALL
ICALL
, or 
EICALL
 instruction is executed. Each call will use two or three bytes of return 
address stack. An interrupt will also place a return address on this stack. 
To determine the size of the return address stack, see Stack size considerations, page 42. 
Notice however that if the cross-call optimization has been used (
-z9
 without 
--no_cross_call
), the value can be off by as much as a factor of six depending on 
how many times the cross-call optimizer has been run (
--cross_call_passes
). Each 
cross-call pass adds one level of calls, for example, two cross-call passes may result in 
a tripled stack usage.
If external SRAM is available, it is possible to place the stack there. However, the 
external memory is slower than the internal memory so moving the stacks to external 
memory will normally decrease the system performance; se--enable_external_bus
page 181.
Allocating a memory area for the stack is done differently when you use the command 
line interface compared to when you use the IAR Embedded Workbench IDE.
RSTACK size allocation in IAR Embedded Workbench
Select Project>Options. In the General Options category, click the System page.
Add the required stack size in the Return address stack text box.
RSTACK size allocation from the command line
The size of the 
RSTACK
 segment is defined in the linker command file. 
The default linker file sets up a constant representing the size of the stack, at the 
beginning of the linker file:
-D_RSTACK_SIZE=size
Specify an appropriate size for your application. Note that the size is written 
hexadecimally without the 
0x
 notation. 
Placement of the RSTACK segment
Further down in the linker file, the actual stack segment is defined in the memory area 
available for the stack:
-Z(DATA)RSTACK+_RSTACK_SIZE=60-25F
Note: This range does not specify the size of the stack; it specifies the range of the 
available memory.