SW006015 Microchip Technology, SW006015 Datasheet

C COMPILER MPLAB C32

SW006015

Manufacturer Part Number
SW006015
Description
C COMPILER MPLAB C32
Manufacturer
Microchip Technology
Type
Compilerr
Series
PIC32r
Datasheets

Specifications of SW006015

Supported Families
PIC32MX5, MX6, And MX7
Core Architecture
PIC
Kit Contents
Software And Docs
Mcu Supported Families
PIC32 MCUs
Tool Function
Compiler
Supported Devices
PIC32 MCUs
Tool Type
Compiler
Processor Series
PIC32
Lead Free Status / RoHS Status
Not applicable / Not applicable
For Use With/related Products
PIC32
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
MPLAB C32
C COMPILER
USER’S GUIDE
© 2007 Microchip Technology Inc.
DS51686A

Related parts for SW006015

SW006015 Summary of contents

Page 1

... Microchip Technology Inc. MPLAB C32 C COMPILER USER’S GUIDE DS51686A ...

Page 2

... PowerInfo, PowerMate, PowerTool, REAL ICE, rfLAB, Select Mode, Smart Serial, SmartTel, Total Endurance, UNI/O, WiperLock and ZENA are trademarks of Microchip Technology Incorporated in the U.S.A. and other countries. SQTP is a service mark of Microchip Technology Incorporated in the U.S.A. All other trademarks mentioned herein are property of their respective companies. ...

Page 3

... Generic Processor Header File .................................................................... 51 4.4 Processor Support Header Files .................................................................. 51 4.5 Peripheral Library Functions ........................................................................ 52 4.6 Special Function Register Access ................................................................ 53 4.7 CP0 Register Access ................................................................................... 53 4.8 Configuration Bit Access .............................................................................. 54 © 2007 Microchip Technology Inc. MPLAB ® Table of Contents C32 C COMPILER USER’S GUIDE ...

Page 4

... A.16 Pre-Processing Directives .......................................................................... 94 A.17 Library Functions ....................................................................................... 96 A.18 Architecture .............................................................................................. 101 Appendix B. Open Source Licensing B.1 Introduction ................................................................................................ 103 B.2 General Public License .............................................................................. 103 B.3 BSD License .............................................................................................. 103 B.4 Sun Microsystems ...................................................................................... 104 Index ...........................................................................................................................105 Worldwide Sales and Service ...................................................................................116 DS51686A-page iv © 2007 Microchip Technology Inc. ...

Page 5

... Appendix A. Implementation Defined Behavior – discusses the choices for implementation defined behavior in MPLAB C32 C compiler • Appendix B. Open Source Licensing – gives a summary of the open source licenses used for portions of the MPLAB C32 C compiler package © 2007 Microchip Technology Inc. MPLAB Preface NOTICE TO CUSTOMERS C32 C COMPILER ® ...

Page 6

... Optional arguments mcc18 [options] file [options] Choice of mutually exclusive errorlevel {0|1} arguments selection Replaces repeated text var_name [, var_name...] Represents code supplied by void main (void) user { ... } © 2007 Microchip Technology Inc. Examples ® IDE User’s Guide ...

Page 7

... Kochan, Steven G., Programming In ANSI C, Revised Edition. Hayden Books, Indianapolis, Indiana 46268. Plauger, P.J., The Standard C Library, Prentice-Hall, Englewood Cliffs, N.J. 07632. Van Sickle, Ted., Programming Microcontrollers in C, First Edition. LLH Technology Publishing, Eagle Rock, Virginia 24085. GCC Documents http://gcc.gnu.org/onlinedocs/ http://sourceware.org/binutils/ © 2007 Microchip Technology Inc. DS51686A-page 3 ...

Page 8

... Microchip consultant program member listing • Business of Microchip – Product selector and ordering guides, latest Microchip press releases, listing of seminars and events, listings of Microchip sales offices, distributors and factory representatives DS51686A-page 4 © 2007 Microchip Technology Inc. ...

Page 9

... Technical support is available through the web site at: DOCUMENT REVISION HISTORY Revision A (October 2007) • Initial Release of this document. © 2007 Microchip Technology Inc. ® ® Plus, PICkit™ 1 and http://support.microchip.com DS51686A-page 5 ...

Page 10

... NOTES: DS51686A-page 6 © 2007 Microchip Technology Inc. ...

Page 11

... The compilation driver recognizes the following file extensions, which are case sensitive. TABLE 1-1: Extensions file.c file.h file.i file.o file.s © 2007 Microchip Technology Inc. MPLAB ® FILE NAMES Definition A C source file that must be preprocessed. A header file (not to be compiled or linked source file that has already been pre-processed. An object file. ...

Page 12

... An assembly language source file that must be preprocessed. A file to be passed to the linker. 0x100 0x101 0x78 0x56 Type Type 0x102 0x103 0x34 0x12 Bits Min Max 8 -128 127 8 0 255 16 -32768 32767 16 0 65535 define a plain Bits © 2007 Microchip Technology Inc. ...

Page 13

... USHRT_MAX INT_MIN INT_MAX UINT_MAX LONG_MIN LONG_MAX ULONG_MAX LLONG_MIN LLONG_MAX ULLONG_MAX © 2007 Microchip Technology Inc. Value 8 The size, in bits, of the smallest non-bitfield object. -128 The minimum value possible for an object of type signed char. 127 The maximum value possible for an object of type signed char. ...

Page 14

... Defined if -mno-float specified. © 2007 Microchip Technology Inc. ...

Page 15

... See Chapter 3. “Interrupts” and Section 3.5 “Exception Handlers”. vector Generate a branch instruction at the indicated exception vector which targets the function. See Chapter 3. “Interrupts” and Section 3.5 “Exception Handlers”. © 2007 Microchip Technology Inc. Always defined. Defined if -ansi is not specified. Defined as 32. ...

Page 16

... The type parameter is one of printf, scanf, strftime or strfmon (optionally with surrounding double underscores, e.g., __printf__) and determines how the format string will be interpreted. The format_index parameter specifies which function parameter is the format string. Function parameters are numbered from the left-most parameter, starting from 1. DS51686A-page 12 © 2007 Microchip Technology Inc. ...

Page 17

... The aligned attribute can also be used on a structure member. Such a member will be aligned to the indicated boundary within the structure. If the alignment value n is omitted, the alignment of the variable is set 8 (the largest alignment value for a basic data type). © 2007 Microchip Technology Inc. DS51686A-page 13 ...

Page 18

... Pragmas #pragma interrupt Mark a function as an interrupt handler. The prologue and epilogue code for the function will perform more extensive context preservation. See Chapter 3. “Interrupts” and Section 3.5 “Exception Handlers”. #pragma vector DS51686A-page 14 © 2007 Microchip Technology Inc. ...

Page 19

... Microchip Technology Inc. PIC32MX DEVICE-SPECIFIC OPTIONS Option Selects the device for which to compile (e.g., -mprocessor=32MX360F512L) Generate (do not generate) MIPS16 code. Don’t use floating-point libraries. Assume that the floating-point coprocessor only supports single-precision operations ...

Page 20

... Disable (do not disable) use of the jal instruction. Calling functions using jal is more efficient but requires the caller and callee the same 256 megabyte segment. This option has no effect on abicalls code. The default is -mno-long-calls. Do not use the standard peripheral libraries when linking. Definition © 2007 Microchip Technology Inc. ...

Page 21

... Microchip Technology Inc. KIND-OF-OUTPUT CONTROL OPTIONS Definition Compile or assemble the source files, but do not link. The default file extension is .o. Stop after the preprocessing stage, i.e., before running the compiler proper. The default output file is stdout. ...

Page 22

... By default, such a bit field is signed, unless -traditional is used, in which case bit fields are always unsigned. Let the type char be unsigned, like unsigned char. Store strings in the writable data segment and don’t make them unique. Definition , and asm inline © 2007 Microchip Technology Inc. ...

Page 23

... Microchip Technology Inc. WARNING AND ERROR OPTIONS IMPLIED BY -WALL Check the code for syntax, but don’t do anything beyond that. Issue all the warnings demanded by strict ANSI C. Reject all programs that use forbidden extensions. ...

Page 24

... Examples of code with undefined behavior are a = a++;, a[n] = b[n++] and a[i++] = i;. Some more complicated cases are not diagnosed by this option, and it may give an occasional false positive result, but in general it has been found fairly effective at detecting this sort of problem in programs. Definition © 2007 Microchip Technology Inc. ...

Page 25

... Microchip Technology Inc. WARNING AND ERROR OPTIONS IMPLIED BY -WALL (CONTINUED) Warn whenever a switch statement has an index of enumeral type and lacks a case for one or more of the named codes of that enumeration. (The presence of a default label prevents this warning ...

Page 26

... Warn whenever a local variable or non-constant static variable is unused aside from its declaration. To suppress this warning, use the unused attribute. Warn whenever a statement computes a result that is explicitly not used. To suppress this warning, cast the expression to void. Definition © 2007 Microchip Technology Inc. ...

Page 27

... TABLE 1-6: Option -W -Waggregate-return -Wbad-function-cast © 2007 Microchip Technology Inc. WARNING AND ERROR OPTIONS NOT IMPLIED BY -WALL Print extra warning messages for these events: • A nonvolatile automatic variable might be changed by a call to longjmp. These warnings are possible only in optimizing compilation. The compiler sees only the calls to setjmp ...

Page 28

... Warn about anything that depends on the size of a function type or of void. MPLAB C32 C compiler assigns these types a size of 1, for convenience in calculations with void * pointers and pointers to functions. Definition © 2007 Microchip Technology Inc. ...

Page 29

... Microchip Technology Inc. WARNING AND ERROR OPTIONS NOT IMPLIED BY -WALL (CONTINUED) Warn if anything is declared more than once in the same scope, even in cases where multiple declaration is valid and changes nothing. Warn whenever a local variable shadows another local variable ...

Page 30

... Don’t delete intermediate files. Place them in the current directory and name them based on the source file. Thus, compiling foo.c with -c -save-temps would produce the following files: (preprocessed file) foo.i (assembly language file) foo.s (object file) foo.o Definition © 2007 Microchip Technology Inc. ...

Page 31

... The following options control specific optimizations. The -O2 option turns on all of these optimizations except -funroll-loops, -funroll-all-loops and -fstrict-aliasing. © 2007 Microchip Technology Inc. GENERAL OPTIMIZATION OPTIONS Do not optimize. (This is the default.) Without -O, the compiler’s goal is to reduce the cost of compilation and to make debugging produce the expected results ...

Page 32

... When you specify these options, the assembler and linker may create larger object and executable files and is also slower. Perform a global common subexpression elimination pass. This pass also performs global constant and copy propagation. Definition © 2007 Microchip Technology Inc. ...

Page 33

... Microchip Technology Inc. SPECIFIC OPTIMIZATION OPTIONS (CONTINUED) When -fgcse-lm is enabled, global common subexpression elimination attempts to move loads which are only killed by stores into themselves. This allows a loop containing a load/store sequence to change to a load outside the loop, and a copy/store within the loop ...

Page 34

... Perform the optimization of loop unrolling. This is done for all loops and usually makes programs run more slowly. -funroll-all-loops implies -fstrength-reduce, as well as -frerun-cse-after-loop. Definition © 2007 Microchip Technology Inc. ...

Page 35

... Microchip Technology Inc. MACHINE-INDEPENDENT OPTIMIZATION OPTIONS Force memory operands to be copied into registers before doing arithmetic on them. This produces better code by making all memory references potential common subexpressions. When they are not common subexpressions, instruction combination should eliminate the separate register-load ...

Page 36

... Do not print column numbers in diagnostics. This may be necessary if diagnostics are being scanned by a program that does not understand the column numbers, such as dejagnu. Print the name of each header file used, in addition to other normal activities. Definition Definition © 2007 Microchip Technology Inc. ...

Page 37

... Microchip Technology Inc. PREPROCESSOR OPTIONS (CONTINUED) Any directories you specify with -I options before the -I- options are searched only for the case of #include "file". They are not searched for #include <file>. If additional directories are specified with -I options after the -I-, these directories are searched for all #include directives ...

Page 38

... The result is the target. An -MT option sets the target to be exactly the string you specify. If you want multiple targets, you can specify them as a single argument to -MT, or use multiple -MT options. For example: -MT '$(objpfx)foo.o' might give $(objpfx)foo.o: foo.c Definition © 2007 Microchip Technology Inc. ...

Page 39

... The following options control assembler operations. TABLE 1-12: Option -Wa,option © 2007 Microchip Technology Inc. PREPROCESSOR OPTIONS (CONTINUED) Do not search the standard system directories for header files. Only the directories you have specified with -I options (and the current directory, if appropriate) are searched. (See Section 1.8.10 “ ...

Page 40

... It is legitimate to use -u multiple times with different symbols to force loading of additional library modules. Pass option as an option to the linker. If option contains commas split into multiple options at the commas. system-specific linker options that MPLAB C32 C compiler does not know how to recognize. © 2007 Microchip Technology Inc. ...

Page 41

... TABLE 1-14: Option -Bprefix -specs=file © 2007 Microchip Technology Inc. DIRECTORY SEARCH OPTIONS This option specifies where to find the executables, libraries, include files and data files of the compiler itself. The compiler driver program runs one or more of the sub-programs pic32-cpp, pic32-cc1, pic32-as and pic32-ld ...

Page 42

... This flag should be used consistently through all modules. Treat the register named reg as a fixed register. Generated code should never refer to it (except perhaps as a Stack Pointer, Frame Pointer or in some other fixed role). reg must be the name of a register, e.g., -ffixed-$0. © 2007 Microchip Technology Inc. ...

Page 43

... Microchip Technology Inc. CODE GENERATION CONVENTION OPTIONS (CONTINUED) Definition Generate instrumentation calls for entry and exit to functions. Just after function entry and just before function exit, the following profiling functions are called with the address of the current function and its call site ...

Page 44

... The executable file may be loaded into the MPLAB IDE hex file is required, for example to load into a device programmer, then use the following command: C:\> pic32-bin2hex ex1.out This creates an Intel hex file named ex1.hex. DS51686A-page 40 © 2007 Microchip Technology Inc. ...

Page 45

... Compile both files by typing the following at a DOS prompt: C:\> pic32-gcc -o ex1.out ex1.c add.c This command compiles the modules ex1.c and add.c. The compiled modules are linked with the compiler libraries and the executable file ex1.out is created. © 2007 Microchip Technology Inc. DS51686A-page 41 ...

Page 46

... NOTES: DS51686A-page 42 © 2007 Microchip Technology Inc. ...

Page 47

... The standard startup code (See Section 5.7 “Startup and Initialization”) invokes a number of weak functions directly and provides weak handlers for bootstrap exceptions and general exceptions: _on_reset, _nmi_handler, _bootstrap_exception_handler, _general_exception_handler, and _on_bootstrap. © 2007 Microchip Technology Inc. MPLAB C32 C COMPILER ® USER’S GUIDE ...

Page 48

... Evaluates the address is a kernel segment virtual address, zero otherwise. Evaluate the address is a KSEG0 virtual address, zero otherwise. Evaluate the address is a KSEG1 virtual address, zero otherwise. Evaluate the address is either a KSEG0 or a KSEG1 virtual address, zero otherwise. © 2007 Microchip Technology Inc. ...

Page 49

... Both of these directory structures contain subdirectories for each of the multilib combinations specified above. These subdirectories, respectively, are as follows ./size 3. ./speed 4. ./mips16 5. ./no-float 6. ./mips16/no-float 7. ./size/mips16 8. ./size/no-float 9. ./size/mips16/no-float 10. ./speed/mips16 11. ./speed/no-float 12. ./speed/mips16/no-float © 2007 Microchip Technology Inc. DS51686A-page 45 ...

Page 50

... In this case, the . subdirectories are used. 4. pic32-gcc -Os -mips16 foo.c For this example, the command line options for optimizing for size and for MIPS16 code have been specified (i.e., -Os and -mips16 are being used). In this case, the ./size/mips16 subdirectories are used. DS51686A-page 46 © 2007 Microchip Technology Inc. ...

Page 51

... A function is marked as a handler function via either the interrupt attribute or the interrupt pragma specified as handling interrupts of a specific priority level or for operating in single vector mode. 1. Note that pre-processor macros are not expanded in pragma directives. © 2007 Microchip Technology Inc. MPLAB Chapter 3. Interrupts 1 . Each method is functionally equivalent to the other. The interrupt is C32 C COMPILER ® ...

Page 52

... The following pragma specifies that function bar will be created as an interrupt handler function of priority five. bar will be located in general purpose program memory (.text section). A dispatch function targeting bar will be created at exception vector address 23. #pragma interrupt bar ipl5 vector 23 DS51686A-page 48 single [vector [@] 0 © 2007 Microchip Technology Inc. ...

Page 53

... The context saved is the hi and lo registers and all general purpose registers except s0-s8, which are defined to be preserved by all called functions and so are not necessary to actively save again here. © 2007 Microchip Technology Inc. =0). General exceptions are vectored BEV ...

Page 54

... A weak default implementation of _general_exception_handler() is provided in the standard library which merely goes into an infinite loop. If the user application provides an implementation of _general_exception_handler(), that implementation will be used instead. DS51686A-page 50 © 2007 Microchip Technology Inc. ...

Page 55

... The individual bits (or bit fields) are named in the structure using the names in the data sheet. For example in the PIC32MX360F512L processor-specific header file, the WDTCON register for use with C is declared as: © 2007 Microchip Technology Inc. MPLAB C32 C COMPILER ® ...

Page 56

... PERIPHERAL LIBRARY FUNCTIONS Many of he peripherals of the PIC32MX devices are supported by the peripheral library functions provided with the compiler tools. See the “MPLAB C32 C Compiler Libraries” (DS51685) for details on the functions provided. DS51686A-page 52 © 2007 Microchip Technology Inc. ...

Page 57

... CP0 Register Field Definitions When the CP0 register definitions header file is included from either an Assembly file, three #defines exist for each of the CP0 register fields. _CP0_ REGISTER © 2007 Microchip Technology Inc. _ $register_number, select_number REGISTER NAME _ register_number REGISTER ...

Page 58

... Only defined for registers that contain writable bit fields REGISTER NAME , to val, and _ REGISTER NAME , to val, and _ REGISTER NAME , to _ REGISTER NAME , to _ REGISTER NAME , to _ REGISTER NAME © 2007 Microchip Technology Inc. ...

Page 59

... The example does the following: • Enables the Watchdog Timer, • Sets the Watchdog Postscaler to 1:128, and • Selects the HS Oscillator for the Primary Oscillator #pragma config FWDTEN = ON, WDTPS = PS128 #pragma config POSCMOD = HS ... void main (void) { ... } © 2007 Microchip Technology Inc. DS51686A-page 55 ...

Page 60

... NOTES: DS51686A-page 56 © 2007 Microchip Technology Inc. ...

Page 61

... Register Name $0 $1 $2-$3 $4-$7 $8-$15 $16-$23 $24-$25 $26-$27 $28 $29 $30 $31 © 2007 Microchip Technology Inc. MPLAB ® REGISTER CONVENTIONS Software Name Always 0 when read. zero Assembler temporary variable. at Return value from functions. v0-v1 Used for passing arguments to functions. a0-a3 Temporary registers used by compiler for expression t0-t7 evaluation ...

Page 62

... Caller Space for argument 4 Space for argument 3 Space for argument 2 Space for argument 1 FP Local variables and temporary values Callee Register save area Space for arguments used in function calls SP Stack grows toward lower addresses © 2007 Microchip Technology Inc. ...

Page 63

... Pointer reserved register otherwise. - Register ra contains the return address of a function call. TABLE 5-2: char short int long long long float double long double Structure © 2007 Microchip Technology Inc. REGISTERS REQUIRED Data Type Number of Registers Required depending on the size of the struct. ...

Page 64

... Example Example DS51686A-page 60 PASSING ARGUMENTS int add (int, int) a= add (5, 10); undefined undefined SP void foo (double, double) call= foo (10.5, 20.1); undefined undefined SP void calculate (double, double, int) calculate (50.3, 100.0, .10); .10 undefined undefined 100.0 a3 © 2007 Microchip Technology Inc. ...

Page 65

... DRM must be configured for kernel program to contain the RAM functions, and the Stack Pointer is located one word prior to the beginning of the DRM kernel program boundary address. If RAM functions do not exist, then the Stack Pointer is located at the true end of DRM. © 2007 Microchip Technology Inc This variable is named _stack. The user ...

Page 66

... The compiler toolchain supports global pointer (gp) relative addressing. Loads and stores to data lying within 32KB of either side of the address stored in the gp register can be performed in a single instruction using the gp register as the base register. DS51686A-page 62 STACK AND HEAP LAYOUT STACK AND HEAP LAYOUT WITH RAM FUNCTIONS © 2007 Microchip Technology Inc. ...

Page 67

... There are two uninitialized data sections—.sbss and .bss. The .sbss section is a data segment containing uninitialized variables less than or equal to n bytes where n is determined by the -Gn command line option. The .bss section is a data segment containing uninitialized variables not included in .sbss. © 2007 Microchip Technology Inc. • lit8 • sbss • sbss.* • ...

Page 68

... The startup code copies all data memory locations from program flash image to data memory using these variables. These variables are named _data_image_begin, _data_begin, and _data_end, respectively. DS51686A-page 64 UNINITIALIZED DATA © 2007 Microchip Technology Inc. ...

Page 69

... To determine whether any RAM functions exist in the application, the linker script provides a variable that contains the length of the .ramfunc section 1. All functions attributed with __ramfunc__ or __longramfunc__ are placed in the .ramfunc section. © 2007 Microchip Technology Inc. INITIALIZED DATA RAM FUNCTIONS 1 ...

Page 70

... For example not desirable to provide direct access to the Count register, access to the register may be individually disabled and the return value can be virtualized by the operating system. No initialization is performed on this register in the PIC32MX startup code. DS51686A-page 66 ORIGIN(${DATA_MEMORY_LOCATION}) ; BUS MATRIX INITIALIZATION © 2007 Microchip Technology Inc. ...

Page 71

... IM1..IM0 = 0) • Interrupt priority level is 0 (IPL = 0) • Base mode is Kernel mode ( • Error level is normal (ERL = 0) • Exception level is normal (EXL = 0) • Interrupts are disabled ( © 2007 Microchip Technology Inc. == 1), CorExtend is enabled (CEE = 1), otherwise, CorExtend is bit in the Debug register DS51686A-page 67 ...

Page 72

... Status register is set, however, the register can still be written via the MTC0 instruction. No initialization is performed on this register in the PIC32MX startup code. DS51686A-page 68 = 0). In such cases, the shadow set number comes from VS is zero, the results of a software read or write of this register HSS . The HSS © 2007 Microchip Technology Inc. ...

Page 73

... These fields are reset to 0 because L2/L3 caches are not supported on the core. All fields in the Config2 register are read-only. No initialization is performed on this register in the PIC32MX startup code. © 2007 Microchip Technology Inc. equals 0, and a read-only CPU number value that may BEV is 0 ...

Page 74

... This register is a read/write register that contains the address at which processing resumes after a debug exception or debug mode exception has been serviced. For synchronous (precise) debug and debug mode exceptions, the DEPC contains either: DS51686A-page 70 field are valid when read from ver © 2007 Microchip Technology Inc. ...

Page 75

... CALL MAIN The last thing that the startup code performs is a call to the main routine. If the user returns from main, the startup code goes into an infinite loop. © 2007 Microchip Technology Inc. is set) and before entering into BEV is cleared to BEV ...

Page 76

... The startup code arranges for a jump to the reset exception handler to be located at 0xBFC00380 and a jump to the general exception handler to be located at EBASE + 0x180. Both handlers must be attributed with the nomips16 [e.g., __attribute__ ((nomips16))] since the startup code jumps to these functions. FIGURE 5-10: DS51686A-page 72 EXCEPTIONS is 1 BEV © 2007 Microchip Technology Inc. ...

Page 77

... The default linker script contains the following categories of information: • Output Format and Entry Points • Default Values for Minimum Stack and Heap Sizes • Processor Definitions Include File © 2007 Microchip Technology Inc. Description The address to place into the BMXDKPBA register if _ramfunc_length is greater than 0. ...

Page 78

... Microchip Technology Inc. Can Can ...

Page 79

... This section of the processor definitions linker script provides information about certain memory addresses required by the default linker script. /************************************************************** * Memory Address Equates **************************************************************/ _RESET_ADDR= 0xBFC00000; _BEV_EXCPT_ADDR= 0xBFC00380; _DBG_EXCPT_ADDR= 0xBFC00480; _DBG_CODE_ADDR= 0xBFC02000; _GEN_EXCPT_ADDR= _ebase_address + 0x180; © 2007 Microchip Technology Inc. Contains SFR definitions. DS51686A-page 75 ...

Page 80

... ORIGIN = 0x9FC01000, LENGTH = 0x1000 : ORIGIN = 0xBFC00000, LENGTH = 0x490 : ORIGIN = 0xBFC02000, LENGTH = 0xFF0 : ORIGIN = 0xBFC02FF0, LENGTH = 0x4 : ORIGIN = 0xBFC02FF4, LENGTH = 0x4 : ORIGIN = 0xBFC02FF8, LENGTH = 0x4 : ORIGIN = 0xBFC02FFC, LENGTH = 0x4 : ORIGIN = 0xA0000000, LENGTH = 0x2000 : ORIGIN = 0xBF800000, LENGTH = 0x10000 © 2007 Microchip Technology Inc. ...

Page 81

... The following output sections may be created by the linker: • .reset Section • .bev_excpt Section • .dbg_excpt Section • .dbg_code Section • .app_excpt Section • .vector_0 .. .vector_63 Sections • .startup Section • .text Section • .rodata Sectionn © 2007 Microchip Technology Inc. DS51686A-page 77 ...

Page 82

... The section is marked as NOLOAD only intended to ensure that application code cannot be placed at locations reserved for the debug executive. .dbg_excpt _DBG_EXCPT_ADDR (NOLOAD (DEFINED (_DEBUGGER) ? 0x8 : 0x0); } > kseg1_boot_mem DS51686A-page This BEV © 2007 Microchip Technology Inc. ...

Page 83

... This section collects executable code from all of the application's input files. This section is assigned to the program memory region (kseg0_program_mem) and has a fill value of NOP (0). Symbols are defined to represent the begin (_text_begin) and end (_text_end) addresses of this section. .text ORIGIN(kseg0_program_mem _text_begin = . ; © 2007 Microchip Technology Inc This BEV DS51686A-page 79 ...

Page 84

... This section is assigned to the data memory region (kseg1_data_mem). The section is marked as NOLOAD only intended to ensure that application data cannot be placed at locations reserved for the debug executive. DS51686A-page 80 This is different from Again, this is © 2007 Microchip Technology Inc. ...

Page 85

... We want the small data sections together single-instruction offsets can access them all, and * initialized data all before uninitialized can shorten the on-disk segment size. */ .sdata : { _sdata_begin = . ; *(.sdata .sdata.* .gnu.linkonce.s.*) _sdata_end = . ; } > kseg1_data_mem AT> kseg0_program_mem © 2007 Microchip Technology Inc. DS51686A-page 81 ...

Page 86

... Align here to ensure that the .bss section occupies * space up to _end. * alignment even if the .bss section disappears because * there are no input sections. DS51686A-page Align after .bss to ensure correct © 2007 Microchip Technology Inc. ...

Page 87

... RAM functions go at the end of our stack and heap allocation. * Alignment of 2K required by the boundary register (BMXDKPBA). */ .ramfunc ALIGN(2K _ramfunc_begin = . ; *(.ramfunc . = ALIGN(4) ; _ramfunc_end = . ; } > kseg1_data_mem AT> kseg0_program_mem _ramfunc_image_begin = LOADADDR(.ramfunc) ; _ramfunc_length = SIZEOF(.ramfunc) ; _bmxdkpba_address = _ramfunc_begin - ORIGIN(kseg1_data_mem) ; _bmxdudba_address = LENGTH(kseg1_data_mem); _bmxdupba_address = LENGTH(kseg1_data_mem); © 2007 Microchip Technology Inc. .ramfunc.*) DS51686A-page 83 ...

Page 88

... SGI/MIPS DWARF 2 extensions */ .debug_weaknames *(.debug_weaknames) } .debug_funcnames *(.debug_funcnames) } DS51686A-page 84 If RAM functions do not exist, then the top */ *(.stab *(.stabstr *(.stab.excl *(.stab.exclstr *(.stab.index *(.comment *(.debug *(.line *(.debug_srcinfo *(.debug_sfnames *(.debug_aranges *(.debug_info .gnu.linkonce.wi.*) } *(.debug_abbrev *(.debug_line *(.debug_frame *(.debug_str *(.debug_loc *(.debug_macinfo) } Reduce heap */ © 2007 Microchip Technology Inc. ...

Page 89

... RAM */ void __ramfunc__ foo (void function ‘bar’ will be placed in RAM and will be invoked using the full 32 bit address */ void __longramfunc__ bar (void Specifying __longramfunc__ is functionally equivalent to specifying both __ramfunc__ and __longcall__. © 2007 Microchip Technology Inc *(.debug_varnames DS51686A-page 85 ...

Page 90

... NOTES: DS51686A-page 86 © 2007 Microchip Technology Inc. ...

Page 91

... ISO/IEC 9899:1999 standard. A.4 TRANSLATION ISO Standard: Implementation: ISO Standard: Implementation: © 2007 Microchip Technology Inc. MPLAB C32 C COMPILER ® “How a diagnostic is identified (3.10, 5.1.1.3).” All output to stderr is a diagnostic. “Whether each nonempty sequence of white-space characters other than new-line is retained or replaced by one space character in translation phase 3 (5.1.1.2).” ...

Page 92

... EXIT_SUCCESS, or EXIT_FAILURE (7.20.4.3).” The host environment is application defined. “The set of environment names and the method for altering the environment list used by the getenv function (7.20.4.4).” The host environment is application defined. © 2007 Microchip Technology Inc. ...

Page 93

... Implementation: ISO Standard: Implementation: ISO Standard: Implementation: © 2007 Microchip Technology Inc. “The manner of execution of the string by the system function (7.20.4.5).” The host environment is application defined. “Which additional multibyte characters may appear in identifiers and their correspondence to universal character names (6.4.2).” ...

Page 94

... All integer types are represented as two’s complement, and all bit patterns are ordinary values. “The rank of any extended integer type relative to another extended integer type with the same precision (C99 6.3.1.1).” © 2007 Microchip Technology Inc. ...

Page 95

... Implementation: ISO Standard: Implementation: ISO Standard: © 2007 Microchip Technology Inc. No extended integer types are supported. “The result of, or the signal raised by, converting an integer to a signed integer type when the value cannot be represented in an object of that type (C90 6.2.1.2, C99 6.3.1.3).” ...

Page 96

... When casting from an integer to a pointer, if the source type is smaller than the destination type, the result is extended base don the signedness of the source type. © 2007 Microchip Technology Inc. ...

Page 97

... ISO Standard: Implementation: ISO Standard: Implementation: ISO Standard: © 2007 Microchip Technology Inc. “The size of the result of subtracting two pointers to elements of the same array (C90 6.3.6, C99 6.5.6).” 32 bit signed integer. “The extent to which suggestions made by using the register storage-class specifier are effective (C90 6.5.1, C99 6.7.1).” ...

Page 98

... No limit. “The maximum number of case values in a switch statement (C90 6.6.4.2).” No limit. “How sequences in both forms of header names are mapped to headers or external source file names (C90 6.1.7, C99 6.4.7).” © 2007 Microchip Technology Inc. ...

Page 99

... ISO Standard: Implementation: ISO Standard: Implementation: © 2007 Microchip Technology Inc. The character sequence between the delimiters is considered string which is a file name for the host environment. “Whether the value of a character constant in a constant expression that controls conditional inclusion matches the value of the same character constant in the execution character set (C90 6.8.1, C99 6.10.1).” ...

Page 100

... None. “The types defined for float_t and double_t when the value of the FLT_EVAL_METHOD macro is less than 0 or greater than 2 (7.12).” Unimplemented. “The infinity to which the INFINITY macro expands, if any (7.12).” Unimplemented. © 2007 Microchip Technology Inc. ...

Page 101

... Implementation: ISO Standard: Implementation: ISO Standard: Implementation: © 2007 Microchip Technology Inc. “The quiet NaN to which the NAN macro expands, when it is defined (7.12).” Unimplemented. “Domain errors for the mathematics functions, other than those required by this International Standard (7.12.1).” ...

Page 102

... Encodings are the same for each file. “The effect of the remove function on an open file (7.19.4.1).” Application defined. The system function unlink is called. © 2007 Microchip Technology Inc. ...

Page 103

... ISO Standard: Implementation: ISO Standard: Implementation: © 2007 Microchip Technology Inc. “The effect if a file with the new name exists prior to a call to the rename function (7.19.4.2).” Application defined. The system function link is called to create the new filename, then unlink is called to remove the old filename ...

Page 104

... Application defined. “The local time zone and Daylight Saving Time (7.23.1).” Application defined. “The era for the clock function (7.23.2.1).” © 2007 Microchip Technology Inc. ...

Page 105

... ISO Standard: Implementation: ISO Standard: Implementation: ISO Standard: Implementation: © 2007 Microchip Technology Inc. Application defined. “The positive value for tm_isdst in a normalized tmx structure (7.23.2.6).” 1. “The replacement string for the %Z specifier to the strftime, strfxtime, wcsftime, and wcsfxtime functions in the “C” ...

Page 106

... NOTES: DS51686A-page 102 © 2007 Microchip Technology Inc. ...

Page 107

... OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT © 2007 Microchip Technology Inc. MPLAB C32 C COMPILER ® USER’S GUIDE ...

Page 108

... Portions of the standard library are copyright Sun Microsystems and are distributed under the permissions granted by the following terms: Developed at SunPro, a Sun Microsystems, Inc. business. Permission to use, copy, modify, and distribute this software is freely granted, provided that this notice is preserved. DS51686A-page 104 © 2007 Microchip Technology Inc. ...

Page 109

... Section ........................................................ 80 .stack Section........................................................... 83 .startup Section ........................................................ 79 .text Section ............................................................. 79 .vector_n Sections ................................................... 79 __LANGUAGE_ASSEMBLY.................................... 10 __LANGUAGE_ASSEMBLY__................................ 10 __LANGUAGE_C .................................................... 10 __LANGUAGE_C__ ................................................ 10 __longramfunc__ ................................................61 __mips ..................................................................... 11 __mips__ ................................................................. 11 __mips_isa_rev ........................................................ 11 __mips_single_float ................................................. 11 __mips_soft_float ..................................................... 11 __mips16 ................................................................. 11 __mips16e ............................................................... 11 © 2007 Microchip Technology Inc. MPLAB C32 C COMPILER ® Index __MIPSEL ................................................................ 11 __MIPSEL__ ............................................................ 11 __NO_FLOAT .......................................................... 10 __PIC__ ................................................................... 10 __pic__..................................................................... __PIC32MX.............................................................. 10 __PIC32MX__.......................................................... 10 __processor__ ......................................................... 10 __R3000................................................................... 11 __R3000__............................................................... 11 __ramfunc__ ...

Page 110

... Branch Delay............................................................ 68 , Bus Matrix Register .................................................. 65 BMXDKPBA ...................................................... 65 BMXDUDBA...................................................... 65 49 BMXDUPBA ...................................................... -C.............................................................................. 32 -c ........................................................................ 17 C Dialect Control Options......................................... 18 -ansi .................................................................. 18 -aux-info ............................................................ 18 -ffreestanding .................................................... 18 -fno-asm ............................................................ 18 -fno-builtin ......................................................... 18 -fno-signed-bitfields........................................... 18 -fno-unsigned-bitfields....................................... 18 -fsigned-bitfields ................................................ 18 -fsigned-char ..................................................... 18 -funsigned-bitfields ............................................ 18 -funsigned-char ................................................. 18 -fwritable-strings................................................ 18 C Stack Usage ......................................................... 58 Call Main .................................................................. 71 calloc ........................................................................ Cast .............................................................. 21 Cause Register................................................... 67 char ........................................................... © 2007 Microchip Technology Inc. ...

Page 111

... Command Line Option, Linker --defsym ............................................................ 74 --defsym_min_stack_size ................................. 58 -L....................................................................... 75 Command Line Options ........................................... 15 Comments...........................................................19 Common Subexpression Elimination ............28 Common Subexpressions ........................................ 31 Compare Register .................................................... 67 Compiler © 2007 Microchip Technology Inc. Driver .......................................................7 Compiling Multiple Files ........................................... 41 con fign..................................................................... 77 Config Register ........................................................ 69 Config1 Register ...................................................... 69 Config2 Register ...................................................... 69 Config3 Register ...................................................... 70 Configuration Bit Access .......................................... 54 Configuration Memory Region config3, config2, config1, config0 ...

Page 112

... Frame Pointer (W14).......................................... -freduce-all-givs ........................................................ 29 -fregmove ................................................................. 29 -frename-registers .................................................... 29 -frerun-cse-after-loop.......................................... -frerun-loop-opt......................................................... 29 -fschedule-insns ....................................................... -fschedule-insns2 ..................................................... 29 -fshort-enums ..................................................... 39 -fsigned-bitfields ....................................................... 18 -fsigned-char ............................................................ 18 -fstrength-reduce ................................................ 29 -fstrict-aliasing .................................................... 27 -fsyntax-only ............................................................. 19 -fthread-jumps .................................................... 27 Full Mode close.................................................................. 43 lseek.................................................................. 43 open .................................................................. © 2007 Microchip Technology Inc. ...

Page 113

... INT_MAX ................................................................... 9 INT_MIN..................................................................... 9 IntCtl......................................................................... 68 Integer Values char ..................................................................... 8 int ........................................................................ 8 long ..................................................................... 8 long long ............................................................. 8 short .................................................................... 8 signed char ......................................................... 8 signed int ............................................................ 8 signed long ......................................................... 8 © 2007 Microchip Technology Inc. signed long long.................................................. 8 signed short ........................................................ 8 unsigned char ..................................................... 8 unsigned int......................................................... 8 unsigned long...................................................... 8 30 unsigned long long.............................................. unsigned short .................................................... Internet Address ...

Page 114

... Attribute.............................. 39 , -nodefaultlibs ............................................................ 36 noinline ..................................................................... 12 NOLOAD ............................................................ nomips16...................................................... nonnull (index, ...)..................................................... 13 NOP.......................................................................... 79 noreturn .................................................................... 12 noreturn Attribute...................................................... 24 -nostdinc ............................................................. -nostdlib.................................................................... ....................................................................... 26 -o ........................................................................ 17 -o ex1.out ................................................................. 40 -O0 ..................................................................... -O1 ........................................................................... 27 -O2 ..................................................................... 27 -O3 ..................................................................... 27 -O3 -mips16.............................................................. 45 -O3 -mips16 -mno-float ............................................ 45 -O3 -mno-float .......................................................... Object File .................................................... 28 open ......................................................................... 43 Optimization Control Options ................................... -falign-functions................................................. 28 -falign-labels...................................................... 28 -falign-loops....................................................... © 2007 Microchip Technology Inc. ...

Page 115

... Directory Search ............................................... 37 Linking .............................................................. 36 Optimization Control ......................................... 27 Output Control .................................................. 17 Preprocessor Control ........................................ 32 Warnings and Errors Control ............................ 19 -Os ......................................................................27 -Os -mips16 ............................................................. 45 -Os -mips16 -mno-float ............................................ 45 -Os -mno-float .......................................................... 45 Output Control Options ............................................ 17 -c ....................................................................... 17 © 2007 Microchip Technology Inc. -E ...................................................................... 17 --help................................................................. 17 -o....................................................................... 17 -S ...................................................................... 17 -v ....................................................................... 17 -x ....................................................................... 17 OUTPUT_ARCH ...................................................... 74 OUTPUT_FORMAT ................................................. 74 P -P.............................................................................. 35 packed...................................................................... 14 PATH ...

Page 116

... Simple Mode _mon_getc ........................................................ 43 _mon_put .......................................................... 43 _mon_putc ........................................................ 43 _mon_write........................................................ 43 Software Stack ......................................................... 58 sp........................................................................ 47 Special Function Register Access............................ Special Function Registers....................................... 40 -specs=..................................................................... 37 SR ............................................................................ 47 SRSCtl...................................................................... 68 SRSMap ................................................................... 68 Stack C Usage ............................................................ 58 Pointer (W15) .................................................... 38 Software ............................................................ 58 © 2007 Microchip Technology Inc ...

Page 117

... Attribute............................................13 Unused Function Parameter .................................... 21 Unused Variable ...................................................... 21 used Attribute ........................................................... 13 User Trace Data Register ........................................ 70 USHRT_MAX ............................................................. .............................................................................. 17 v0 ............................................................................. 47 v1 ............................................................................. 47 Variable Attributes. See Attributes, Variable vector ....................................................................... 11 Vector Attribute ........................................................ 49 © 2007 Microchip Technology Inc. vector Attribute ......................................................... 49 Vector Pragma ......................................................... 49 volatile ...................................................................... 39 W -W............................................................ 19 -w ............................................................................. w!x............................................................................ 76 -Wa........................................................................... 35 -Waggregate-return.................................................. 23 -Wall ........................................................19 warn_unused_result................................................. 13 Warnings and Errors Control Options ...

Page 118

... DS51686A-page 114 -Wundef.................................................................... 25 -Wuninitialized .......................................................... 21 -Wunknown-pragmas ............................................... 21 -Wunreachable-code ................................................ 25 -Wunused ........................................................... 21 -Wunused-function ................................................... 21 -Wunused-label ........................................................ 21 -Wunused-parameter ............................................... 22 -Wunused-value ....................................................... 22 -Wunused-variable ................................................... 22 -Wwrite-strings ......................................................... 25 WWW Address ........................................................... .............................................................................. 17 -Xlinker ..................................................................... © 2007 Microchip Technology Inc ...

Page 119

... NOTES: © 2007 Microchip Technology Inc. DS51686A-page 115 ...

Page 120

... Fax: 886-3-572-6459 Taiwan - Kaohsiung Tel: 886-7-536-4818 Fax: 886-7-536-4803 Taiwan - Taipei Tel: 886-2-2500-6610 Fax: 886-2-2508-0102 Thailand - Bangkok Tel: 66-2-694-1351 Fax: 66-2-694-1350 © 2007 Microchip Technology Inc. EUROPE Austria - Wels Tel: 43-7242-2244-39 Fax: 43-7242-2244-393 Denmark - Copenhagen Tel: 45-4450-2828 Fax: 45-4485-2829 France - Paris Tel: 33-1-69-53-63-20 ...

Related keywords