SW006012 Microchip Technology, SW006012 Datasheet - Page 78

C COMPILER FOR DSPIC30F FAMILY

SW006012

Manufacturer Part Number
SW006012
Description
C COMPILER FOR DSPIC30F FAMILY
Manufacturer
Microchip Technology
Type
MPLAB® C30 Compilerr
Series
PIC24 & DsPICr
Datasheets

Specifications of SW006012

Supported Families
PIC24, DsPIC30F And DsPIC33F
Core Architecture
PIC, DsPIC
Kit Contents
Software And Docs
Mcu Supported Families
PIC24 MCUs And DsPIC DSCs
Tool Type
Compiler
Processor Series
PIC24, dsPIC
Lead Free Status / RoHS Status
Not applicable / Not applicable
For Use With/related Products
dsPIC30F
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
MPLAB
4.9
DS51284F-page 72
SOFTWARE STACK
®
C30 User’s Guide
The section attribute specifies that the function should be placed in a section named
.myDataSection, rather than the default .data section. It does not specify where
the user-defined section is to be located. Again, that must be done in a custom linker
script, as follows. Using the device-specific linker script as a base, add the following
section definition:
.myDataSection 0x1000 :
This specifies that the output file should contain a section named.myDataSection
starting at location 0x1000 and containing all input sections named.myDataSection.
Since, in this example, there is a single variable Mabonga in that section, then the
variable will be located at address 0x1000 in data memory.
The dsPIC DSC device dedicates register W15 for use as a software Stack Pointer. All
processor stack operations, including function calls, interrupts and exceptions, use the
software stack. The stack grows upward, towards higher memory addresses.
The dsPIC DSC device also supports stack overflow detection. If the Stack Pointer
Limit register, SPLIM, is initialized, the device will test for overflow on all stack opera-
tions. If an overflow should occur, the processor will initiate a stack error exception. By
default, this will result in a processor reset. Applications may also install a stack error
exception handler by defining an interrupt function named _StackError. See Chap-
ter 7. “Interrupts” for details.
The C runtime startup module initializes the Stack Pointer (W15) and the Stack Pointer
Limit register during the startup and initialization sequence. The initial values are
normally provided by the linker, which allocates the largest stack possible from unused
data memory. The location of the stack is reported in the link map output file.
Applications can ensure that at least a minimum-sized stack is available with the
--stack linker command-line option. See the “MPLAB
and Utilities User’s Guide” (DS51317) for details.
Alternatively, the stack of specific size may be allocated with a user-defined section in
a custom linker script. In the following example, 0x100 bytes of data memory are
reserved for the stack. Two symbols are declared, __SP_init and __SPLIM_init,
for use by the C runtime startup module:
.stack :
__SP_init defines the initial value for the Stack Pointer (W15) and __SPLIM_init
defines the initial value for the Stack Pointer Limit register (SPLIM). The value of
__SPLIM_init should be at least 8 bytes less than the physical stack limit, to allow
for stack error exception processing. This value should be decreased further to account
for stack usage by the interrupt handler itself, if a stack error interrupt handler is
installed. The default interrupt handler does not require additional stack usage.
{
} >data
{
} >data
. += 8
__SP_init = .;
. += 0x100
__SPLIM_init = .;
*(.myDataSection);
®
ASM30, MPLAB
© 2007 Microchip Technology Inc.
®
LINK30

Related parts for SW006012