SW006012 Microchip Technology, SW006012 Datasheet

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
C30
C COMPILER
USER’S GUIDE
© 2007 Microchip Technology Inc.
DS51284F

Related parts for SW006012

SW006012 Summary of contents

Page 1

... Microchip Technology Inc. ® MPLAB C COMPILER USER’S GUIDE C30 DS51284F ...

Page 2

... 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

... File Naming Conventions ............................................................................. 34 3.5 Options ......................................................................................................... 34 3.6 Environment Variables ................................................................................. 59 3.7 Predefined Constants ................................................................................... 60 3.8 Compiling a Single File on the Command Line ............................................ 60 3.9 Compiling Multiple Files on the Command Line ........................................... 61 © 2007 Microchip Technology Inc. Table of Contents ® MPLAB C30 USER’S GUIDE DS51284F-page iii ...

Page 4

... Interrupt Service Routine Context Saving .................................................. 104 7.6 Latency ....................................................................................................... 104 7.7 Nesting Interrupts ....................................................................................... 104 7.8 Enabling/Disabling Interrupts ..................................................................... 105 7.9 Sharing Memory Between Interrupt Service Routines and Mainline Code 106 7.10 PSV Usage with Interrupt Service Routines ............................................. 109 DS51284F-page iv © 2007 Microchip Technology Inc. ...

Page 5

... A.25 system ...................................................................................................... 131 A.26 strerror ..................................................................................................... 131 Appendix B. MPLAB C30 Built-in Functions B.1 Introduction ................................................................................................ 133 B.2 Built-In Function List .................................................................................. 134 Appendix C. MPLAB C30 C Compiler Diagnostics C.1 Introduction ................................................................................................ 155 C.2 Errors ......................................................................................................... 155 C.3 Warnings .................................................................................................... 174 © 2007 Microchip Technology Inc. Table of Contents DS51284F-page v ...

Page 6

... G.6 Combining Documents .............................................................................. 211 G.7 Collections of Documents .......................................................................... 211 G.8 Aggregation with Independent Works ........................................................ 211 G.9 Translation ................................................................................................. 212 G.10 Termination .............................................................................................. 212 G.11 Future Revisions of this License .............................................................. 212 Glossary .....................................................................................................................213 Index ...........................................................................................................................233 Worldwide Sales and Service ...................................................................................242 DS51284F-page vi © 2007 Microchip Technology Inc. ...

Page 7

... MPLAB C30. Items discussed include: • Document Layout • Conventions Used in this Guide • Recommended Reading • The Microchip Web Site • Development Systems Customer Change Notification Service • Customer Support © 2007 Microchip Technology Inc. Preface NOTICE TO CUSTOMERS ® MPLAB C30 USER’S GUIDE ® ...

Page 8

... Appendix E: Deprecated Features – details features that are considered obsolete. • Appendix F: ASCII Character Set – contains the ASCII character set. • Appendix G: GNU Free Documentation License – usage license for the Free Software Foundation. DS51284F-page 2 © 2007 Microchip Technology Inc. ...

Page 9

... Text in angle brackets < > Courier font: Plain Courier Italic Courier Square brackets [ ] Curly brackets and pipe character Ellipses... Icon © 2007 Microchip Technology Inc. Represents Referenced books MPLAB Emphasized text ...is the only compiler... A window the Output window A dialog the Settings dialog ...

Page 10

... American National Standards Institute (ANSI), 11 West 42nd. Street, New York, New York, 10036. This standard specifies the form and establishes the interpretation of programs expressed in the programming language C. Its purpose is to promote portability, reliability, maintainability and efficient execution of C language programs on a variety of computing systems. DS51284F-page 4 © 2007 Microchip Technology Inc. ...

Page 11

... 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 © 2007 Microchip Technology Inc. Preface DS51284F-page 5 ...

Page 12

... Local sales offices are also available to help customers. A listing of sales offices and locations is included in the back of this document. Technical support is available through the web site at: http://support.microchip.com DS51284F-page 6 ® II device programmers and the PICSTART © 2007 Microchip Technology Inc. ® ® ...

Page 13

... COFF or ELF file to ® Intel hex format, suitable for loading into the command-line simulator or a device programmer. See Figure 1-1 for an overview of the software development data flow. © 2007 Microchip Technology Inc. ® MPLAB C30 USER’S GUIDE ...

Page 14

... Files (*.s) Archiver (Librarian) Object File Libraries (*.a) DS51284F-page 8 SOFTWARE DEVELOPMENT TOOLS DATA FLOW C Source Files (*.c) C Compiler Source Files (*.s) Assembler COFF/ELF Object Files (*.o) Linker Executable File (*.exe) Compiler Driver Program ® MPLAB IDE Debug Tool Command-Line Simulator © 2007 Microchip Technology Inc. ...

Page 15

... Program Space Visibility (PSV) window. 1.5.5 Compiler Driver MPLAB C30 includes a powerful command-line driver program. Using the driver program, application programs can be compiled, assembled and linked in a single step (see Figure 1-1). © 2007 Microchip Technology Inc. Compiler Overview DS51284F-page 9 ...

Page 16

... MPLAB C30 User’s Guide NOTES: DS51284F-page 10 © 2007 Microchip Technology Inc. ...

Page 17

... MPLAB C30 port of GCC. • Specifying Attributes of Variables • Specifying Attributes of Functions • Inline Functions • Variables in Specified Registers • Complex Numbers • Double-Word Integers • Referring to a Type with typeof © 2007 Microchip Technology Inc. ® MPLAB C30 USER’S GUIDE DS51284F-page 11 ...

Page 18

... PSV space. If the variable placed into a PSV section, the address should be a program memory address. __ int var attribute DS51284F-page 12 __ ((aligned (16), packed)). __ ((address(0x800))); © 2007 Microchip Technology Inc. ...

Page 19

... When a deprecated function or variable is used, the compiler will emit a warning. A deprecated definition is still defined and, therefore, present in any object file. For example, compiling the following file: __ int attribute int main() { return i; } will produce the warning: © 2007 Microchip Technology Inc ((aligned (16))) = attribute ((aligned)); ...

Page 20

... EEPROM. int table1[50] DS51284F-page 14 ) Width 8 bits 16 bits 32 bits 64 bits 32 bits 64 bits attribute (( mode (SI))) int32; __ ((near)); __ __ attribute ((noload ® MPLAB C30 Type char int long long long float long double © 2007 Microchip Technology Inc. ...

Page 21

... A variable with the reverse attribute cannot be placed into the auto_psv space (see the space() attribute or the -mconst-in-code option); attempts will cause a warning and the compiler will place the variable into the PSV space. © 2007 Microchip Technology Inc. __ attribute ((packed)); ...

Page 22

... In this case, storage must be allocated for the string literal in a memory space which is accessible to the enclosing secure function. The compiler will allocate the string in a psv constant section designated for the secure segment. DS51284F-page attribute ((section("userdata"))) = {0}; © 2007 Microchip Technology Inc. ...

Page 23

... A variable in the auto_psv space cannot be placed at a specific address or given a reverse alignment. Note: © 2007 Microchip Technology Inc attribute ((sfr(0x200)))u1mod; Variables placed in the auto_psv section are not loaded into data memory at startup ...

Page 24

... Otherwise '0' is returned. There are many uses for this feature, mostly to provide generic code that can link with an optional library. DS51284F-page 18 (see “16-Bit Language Tools Libraries”, DS51456) __ attribute ((unordered attribute (( weak )) s; © 2007 Microchip Technology Inc. ...

Page 25

... In the cases where only weak definitions exist, the linker will choose the storage of the first such definition. The remaining definitions become in-accessible. The behavior is identical, regardless of the type of the symbol; functions and variables behave in the same manner. © 2007 Microchip Technology Inc ...

Page 26

... The alias attribute causes the declaration to be emitted as an alias for another symbol, which must be specified. Use of this attribute results in an external reference to target, which must be resolved during the link phase. DS51284F-page 20 __ attribute ((address(0x100))) { © 2007 Microchip Technology Inc. ...

Page 27

... The actual function definition will be located beyond the access area; therefore the access area will contain a jump table through which control can be transferred from another security segment to functions with defined entry points. © 2007 Microchip Technology Inc. DS51284F-page 21 ...

Page 28

... The parameter string-index specifies which argument is the format string argument (arguments are numbered from the left, starting from 1), while first-to-check is the number of the first argument to check DS51284F-page attribute ((const int)); __ ((format (printf, 2, 3))); © 2007 Microchip Technology Inc. ...

Page 29

... The near attribute tells the compiler that the function can be called using a more efficient form of the call instruction. no_instrument_function If the command line option -finstrument-function is given, profiling function calls will be generated at entry and exit of most user-compiled functions. Functions with this attribute will not be so instrumented. © 2007 Microchip Technology Inc. __ ((format_arg (2))); DS51284F-page 23 ...

Page 30

... The value 16 is excluded because access entry 16 is reserved for the secure segment interrupt vector. The value unused is used to specify a function for all of the unused slots in the access area. DS51284F-page 24 __ attribute ((noload attribute ((noreturn)); __ __ attribute ((section (".libtext"))); © 2007 Microchip Technology Inc. ...

Page 31

... This attribute is usually used in conjunction with the interrupt attribute. __ void attribute unused This attribute, attached to a function, means that the function is meant to be possibly unused. MPLAB C30 will not produce an unused function warning for this function. © 2007 Microchip Technology Inc. __ ((interrupt, shadow)) _T1Interrupt (void); DS51284F-page 25 ...

Page 32

... The function must also be compiled as usual if the program refers to its address, because that can’t be inlined. The compiler will only eliminate inline functions if they are declared to be static and if the function definition precedes all uses of the function. DS51284F-page 26 © 2007 Microchip Technology Inc. ...

Page 33

... It is not safe to access the global register variables from signal handlers, or from more than one thread of control, because the system library routines may temporarily use the register for other things (unless you recompile them especially for the task at hand). © 2007 Microchip Technology Inc. DS51284F-page 27 ...

Page 34

... To write a constant with a complex data type, use the suffix 'i' or 'j' (either one; they are equivalent). For example, 2.5fi has type __complex__ float and 3i has type __complex__ int. Such a constant is a purely imaginary value, but you can form any complex value you like by adding one to a real constant. DS51284F-page 28 © 2007 Microchip Technology Inc. ...

Page 35

... Here is an example with a typename as the argument: typeof (int *) Here the type described is a pointer to int. If you are writing a header file that must work when included in ANSI C programs, write __typeof__ instead of typeof. © 2007 Microchip Technology Inc. __ float real z ...

Page 36

... Then you can select a label with indexing, like this: goto *array[i]; Note: This does not check whether the subscript is in bounds. (Array indexing in C never does.) DS51284F-page 30 © 2007 Microchip Technology Inc. ...

Page 37

... Like other integer constants, a binary constant may be suffixed by the letter 'u' or 'U', to specify that it is unsigned. A binary constant may also be suffixed by the letter 'l' or 'L', to specify that it is long. Similarly, the suffix 'll' or 'LL' denotes a long long binary constant. © 2007 Microchip Technology Inc. DS51284F-page 31 ...

Page 38

... MPLAB C30 User’s Guide NOTES: DS51284F-page 32 © 2007 Microchip Technology Inc. ...

Page 39

... Command line options and file name extensions are case-sensitive. The available options are described in Section 3.5 “Options”. For example, to compile, assemble and link the C source file hello.c, creating the absolute executable hello.exe. pic30-gcc -o hello.exe hello.c © 2007 Microchip Technology Inc. ® MPLAB C30 USER’S GUIDE ® ...

Page 40

... A C source file that must be preprocessed. A header file (not to be compiled or linked source file that should not be preprocessed. An object file. A pre procedural-abstraction assembly language file. Assembler code. Assembler code that must be preprocessed. A file to be passed to the linker. © 2007 Microchip Technology Inc. ...

Page 41

... Invalid machine instructions or instruction sequences, or assembler directives (sectioning directives, macros, include files, etc.) must not be used, or the procedure abstraction phase will fail, inhibiting the creation of an output file. © 2007 Microchip Technology Inc. Using MPLAB C30 C Compiler ® dsPIC ...

Page 42

... Uses of © 2007 Microchip Technology Inc. ...

Page 43

... Microchip Technology Inc. Using MPLAB C30 C Compiler 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 44

... 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 45

... Microchip Technology Inc. Using MPLAB C30 C Compiler WARNING/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 46

... 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 47

... Microchip Technology Inc. Using MPLAB C30 C Compiler WARNING/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 48

... To suppress this warning, use the unused attribute (see Section 2.3.1 “Specifying Attributes of Variables”). 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 49

... Option -W -Waggregate-return -Wbad-function-cast -Wcast-align -Wcast-qual © 2007 Microchip Technology Inc. Using MPLAB C30 C Compiler WARNING/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. It cannot know where longjmp will be called ...

Page 50

... 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. Definition © 2007 Microchip Technology Inc. ...

Page 51

... Microchip Technology Inc. Using MPLAB C30 C Compiler WARNING/ERROR OPTIONS NOT IMPLIED BY -WALL Warn when a comparison between signed and unsigned values could produce an incorrect result when the signed value is converted to unsigned. This warning is also enabled by -W ...

Page 52

... Optimize. Optimizing compilation takes somewhat longer, and a lot more host memory for a large function. With -O, the compiler tries to reduce code size and execution time. When -O is specified, the compiler turns on -fthread-jumps and -fdefer-pop. The compiler turns on -fomit-frame-pointer. Definition Definition © 2007 Microchip Technology Inc. ...

Page 53

... Microchip Technology Inc. Using MPLAB C30 C Compiler GENERAL OPTIMIZATION OPTIONS (CONTINUED) Optimize even more. MPLAB® C30 performs nearly all supported optimizations that do not involve a space-speed trade-off. -O2 turns on all optional optimizations except for ...

Page 54

... To disable peephole entirely, use both options. Attempt to reassign register numbers in move instructions and as operands of other simple instructions in order to maximize the amount of register tying. -fregmove and -foptimize-register-moves are the same optimization. Definition © 2007 Microchip Technology Inc. ...

Page 55

... Microchip Technology Inc. Using MPLAB C30 C Compiler SPECIFIC OPTIMIZATION OPTIONS (CONTINUED) Forces all general-induction variables in loops to be strength-reduced. These options may generate better or worse code; results are highly dependent on the structure of loops within the source code ...

Page 56

... Note: Pseudo instruction represents, in this particular context, an abstract measurement of function's size way does it represent a count of assembly instructions and as such, its exact meaning might change from one release of the compiler to an another. Definition Definition © 2007 Microchip Technology Inc. ...

Page 57

... Option -Aquestion (answer) -A -predicate =answer Cancel an assertion with the predicate predicate and -A predicate =answer © 2007 Microchip Technology Inc. Using MPLAB C30 C Compiler MACHINE-INDEPENDENT OPTIMIZATION OPTIONS Even if all calls to a given function are integrated, and the function is declared static, output a separate runtime callable version of the function ...

Page 58

... Any -D and -U options on the command line are always processed before -imacros file, regardless of the order in which they are written. All the -include and -imacros options are processed in the order in which they are written. Definition © 2007 Microchip Technology Inc. ...

Page 59

... Microchip Technology Inc. Using MPLAB C30 C Compiler PREPROCESSOR OPTIONS (CONTINUED) Process file as input before processing the regular input file. In effect, the contents of file are compiled first. Any -D and -U options on the command line are always processed before -include file, regardless of the order in which they are written ...

Page 60

... Undefine macro macro. -U options are evaluated after all -D options, but before any -include and -imacros options. Do not predefine any nonstandard macros (including architecture flags). ASSEMBLY OPTIONS Pass option as an option to the assembler. If option contains commas split into multiple options at the commas. Definition Definition © 2007 Microchip Technology Inc. ...

Page 61

... Pass option as an option to the linker. You can use this to supply © 2007 Microchip Technology Inc. Using MPLAB C30 C Compiler , or are used, the linker is not run and object file names - LINKING OPTIONS ...

Page 62

... Each language will automatically use whatever option is required by the language standard. You should not need to use these options yourself. Definition © 2007 Microchip Technology Inc. ...

Page 63

... Microchip Technology Inc. Using MPLAB C30 C Compiler CODE GENERATION CONVENTION OPTIONS (CONTINUED) Definition Treat the register named reg as an allocatable register saved by functions. It may be allocated even for temporaries or variables that live across a call. Functions compiled this way will save and restore the register reg if they use it ...

Page 64

... Consider all memory references through pointers to be volatile. Consider all memory references to external and global data items to be volatile. The use of this switch has no effect on static data. Consider all memory references to static data to be volatile. © 2007 Microchip Technology Inc. ...

Page 65

... PIC30_EXEC_ PREFIX PIC30_LIBRARY_ PATH PIC30_OMF TMPDIR © 2007 Microchip Technology Inc. Using MPLAB C30 C Compiler COMPILER-RELATED ENVIRONMENTAL VARIABLES Definition This variable's value is a semicolon-separated list of directories, much like PATH. When MPLAB® C30 searches for header files, it tries the directories listed in the variable, after the directories specified with -I but before the standard header file directories ...

Page 66

... DOS command prompt, type set to check this.) DS51284F-page 60 Symbol Defined with -ansi command-line option? C30 __ C30 __ __ C30 C30ELF __ C30ELF __ __ C30ELF C30COFF __ C30COFF __ __ C30COFF Defined with -ansi command-line option? No Yes Yes No Yes Yes No Yes Yes Yes Yes Yes Yes © 2007 Microchip Technology Inc. ...

Page 67

... COMPILING MULTIPLE FILES ON THE COMMAND LINE Move the Add() function into a file called add.c to demonstrate the use of multiple files in an application. That is: File 1 /* ex1.c */ #include <p30f2010.h> int main(void); unsigned int Add(unsigned int a, unsigned int b); © 2007 Microchip Technology Inc. Using MPLAB C30 C Compiler DS51284F-page 61 ...

Page 68

... Compile both files by typing the following at a DOS prompt: C:\> pic30-gcc -o ex1.o 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.o is created. DS51284F-page 62 © 2007 Microchip Technology Inc. ...

Page 69

... KB of the data memory space, and far data, which is in the upper data memory space. Although the program and data memory regions are distinctly separate, the compiler can access constant data in program memory through the program space visibility window. © 2007 Microchip Technology Inc. ® MPLAB C30 USER’S GUIDE ® ...

Page 70

... Constants in Program Memory Initializers for Data Memory General Program Storage Far Code Handles Reset and Exception Vectors Program Space Visibility Data Window (PSV) Stack (Grows Up) Heap (Optional) Y Data Memory General Data Memory X Data Memory Memory Mapped SFRs © 2007 Microchip Technology Inc. ...

Page 71

... This section is intended to be located in program memory and accessed using the PSV window. Variables may also be placed into the .const section by using the section attribute: __ int i attribute regardless of whether the -mconst-in-code option is present on the command line. © 2007 Microchip Technology Inc. COMPILER-GENERATED DATA SECTIONS Initialized Constants in ROM .ndata .const .data ...

Page 72

... Various bits in the RCON reset con- trol register can be tested to determine the reset source. See Section 8 in the “dsPIC30F Family Reference Manual” (DS70046) for more information. DS51284F-page 66 __ ((persistent)); © 2007 Microchip Technology Inc. ...

Page 73

... Source code (in dsPIC DSC assembly language) for both modules is provided in the c:\Program Files\Microchip\MPLAB C30\src directory. The startup modules may be modified if necessary. For example application requires main to be called with parameters, a conditional assembly directive may be changed to provide this support. © 2007 Microchip Technology Inc. DS51284F-page 67 ...

Page 74

... C statements. They must be explicitly accessed by the programmer, usually using table-access inline assembly instructions, or using the program space visibility window. dma - PIC24H MCUs, dsPIC33F DSCs only DMA memory. Variables in DMA memory can be accessed using ordinary C statements and by the DMA peripheral. DS51284F-page 68 © 2007 Microchip Technology Inc. ...

Page 75

... This requests that the compiler arrange to have just the scalars for an application allocated in the near data section. If neither of these global options is suitable, then the following alternatives are available. © 2007 Microchip Technology Inc. MEMORY MODEL COMMAND LINE OPTIONS Memory Definition data memory. ...

Page 76

... The linker will produce an error message if the function declared to be near cannot be reached by one of its callers using a more efficient form of the function call. DS51284F-page 70 © 2007 Microchip Technology Inc. ...

Page 77

... Similarly, to locate the variable Mabonga at address 0x1000 in data memory, first declare the variable as follows in the C source: int __attribute__((__section__(".myDataSection"))) Mabonga = 1; © 2007 Microchip Technology Inc. __ ((address(0x8000))) PrintString (const char *s); __ ((address(0x1000))) Mabonga = 1; ...

Page 78

... This value should be decreased further to account for stack usage by the interrupt handler itself stack error interrupt handler is installed. The default interrupt handler does not require additional stack usage. DS51284F-page 72 ® ® ASM30, MPLAB LINK30 © 2007 Microchip Technology Inc. ...

Page 79

... The user may initialize the Stack Pointer Limit register to further restrict stack growth. The following diagrams illustrate the steps involved in calling a function. Executing a CALL or RCALL instruction pushes the return address onto the software stack. See Figure 4-4. © 2007 Microchip Technology Inc. STACK AND FRAME POINTERS Stack grows toward ...

Page 80

... Return addr [23:16] Return addr [15:0] Parameter 1 : Parameter n-1 Parameter n Caller’s Frame CALLEE SPACE ALLOCATION Local Variables and Temporaries Previous FP Return addr [23:16] Return addr [15:0] Parameter 1 : Parameter n-1 Parameter n Caller’s Frame SP (W15) FP (W14) SP (W15) FP (W14) © 2007 Microchip Technology Inc. ...

Page 81

... If there is insufficient heap memory, then the open function will return an error indicator. For each file that should be buffered, 514 bytes of heap space is required. If there is insufficient heap memory for the buffer, then the file will be opened in unbuffered mode. © 2007 Microchip Technology Inc. PUSH CALLEE-SAVED REGISTERS Callee-Saved Registers ...

Page 82

... REGISTERS REQUIRED Number of Registers Required (contiguous – aligned to even numbered register) 2 (contiguous – aligned to even numbered register) 2 (contiguous – aligned to even numbered register) 4 (contiguous – aligned to quad numbered register) 1 register per 2 bytes in structure FUNCTION CALL MODEL © 2007 Microchip Technology Inc. ...

Page 83

... Function return values are returned in W0 for 8- or 16-bit scalars, W1:W0 for 32-bit scalars, and W3:W2:W1:W0 for 64-bit scalars. Aggregates are returned indirectly through W0, which is set up by the function caller to contain the address of the aggregate value. © 2007 Microchip Technology Inc. FUNCTION CALL MODEL, PASSING STRUCTURES i b.i b ...

Page 84

... W10, W12}. The lower-numbered register contains the least significant 16-bits of the significant. A quadruplet of contiguous registers, the first of which is a register from the set {W0, W4, W8}. The lower-numbered register contains the least significant 16-bits of the significant. Working Register © 2007 Microchip Technology Inc. ...

Page 85

... This value will be restored after any external function call. 4.15.2 String Literals as Arguments In addition to being used as initializers, string literals may also be used as function arguments. For example: myputs("Enter the Dragon code:\n"); © 2007 Microchip Technology Inc. ® ® ASM30, MPLAB LINK30 and Utilities DS51284F-page 79 ...

Page 86

... Even though PSVPAG is now considered compiler-managed resource, there is no change to the function calling conventions. Objects and libraries created with earlier versions are compatible with 3.0 objects, with the exception of some Interrupt Service Routines as noted in Section 7.10 “PSV Usage with Interrupt Service Routines”. DS51284F-page 80 © 2007 Microchip Technology Inc. ...

Page 87

... ANSI-89 extension © 2007 Microchip Technology Inc. 0x101 0x102 0X103 0x56 0x34 0x12 w5 0x1234 INTEGER DATA TYPES Type ® ...

Page 88

... GOTO instruction which is located in the first 32 Kwords of program space. DS51284F-page 82 FLOATING POINT DATA TYPES Bits E Min 32 -126 32 -126 64 -1022 E Max N Min N Max -126 128 127 2 2 -126 128 127 2 2 -1022 1024 1023 2 2 © 2007 Microchip Technology Inc. ...

Page 89

... For example, the following module, compiled for the dsPIC30F2010 part, includes two functions: one for enabling the PSV window, and another for disabling the PSV window. #include <p30f2010.h> void EnablePSV(void) { CORCONbits.PSV = 1; } void DisablePSV(void) { CORCONbits.PSV = 0; } © 2007 Microchip Technology Inc. ® MPLAB C30 USER’S GUIDE DS51284F-page 83 ...

Page 90

... Section 3.6 “Environment Variables”. DS51284F-page 84 __ attribute :1; /* Integer/Fractional mode :1; /* Rounding mode :1; /* Program Space Visibility enable :1; :1; /* Acc saturation mode :1; /* Data space write saturation enable :1; /* Acc B saturation enable :1; /* Acc A saturation enable : loop nesting level status : near )); */ */ */ */ */ */ */ */ © 2007 Microchip Technology Inc. ...

Page 91

... The following example is a sample real time clock. It uses several SFR’s. Descriptions for these SFR’s are found in the p30f6014.h file. This file would be linked with the device specific linker script which is p30f6014.gld. © 2007 Microchip Technology Inc. Device Support Files ® ...

Page 92

... CPU priority levels 4-7*/ /* start the timer interrupt )) _T1Interrupt(void countdown timer is active */ /* decrement it /* increment ticks counter /* if time to rollover /* clear seconds ticks /* and increment seconds /* clear interrupt flag */ */ */ */ */ */ */ */ */ */ */ */ */ */ © 2007 Microchip Technology Inc. ...

Page 93

... To declare an initialized array in data EEPROM without special alignment: int _EEDATA(2) table1 13, 21}; The following macros do not require an argument. They can be used to locate a variable in persistent data memory or in near data memory. #define _PERSISTENT #define _NEAR © 2007 Microchip Technology Inc. Device Support Files asm volatile (" ...

Page 94

... For EE data this will be 0xFF, but it is best to use the __builtin_psvpage() function. • The PSV window should also be enabled by setting the PSV bit in the CORCON register. If this bit is not set, uses of the PSV window will always read 0x0000. DS51284F-page attribute ((interrupt attribute ((interrupt, shadow © 2007 Microchip Technology Inc. ...

Page 95

... TBLPAG = eedata_read(user_data[2], value); if (value something */ } © 2007 Microchip Technology Inc. Device Support Files EEDATA ACCESS VIA PSV builtin_psvpage(&user_data); EEDATA ACCESS VIA TABLE READ \ \ \ \ __ builtin_tbloffset(&src builtin_tblpage(&user_data); ...

Page 96

... Section 5 of the 'dsPIC30F Family Reference Manual' (DS70046) has an excellent discussion on using the Flash program memory and EE data memory provided on the dsPIC DSC devices. This section also has information on run-time programming of both program memory and EE data memory. DS51284F-page 90 © 2007 Microchip Technology Inc. ...

Page 97

... Sharing Memory Between Interrupt Service Routines and Mainline Code – How to mitigate potential hazards when this technique is used. • PSV Usage with Interrupt Service Routines – Using ISRs with managed psv pointers and CodeGuard Security psv constant sections. © 2007 Microchip Technology Inc. Chapter 7. Interrupts ® MPLAB C30 USER’ ...

Page 98

... Section 7.4 “Writing the Interrupt Vector” for a list of interrupt ID’s.) The optional preprologue parameter allows you to insert assembly-language statements into the generated code immediately before the compiler-generated function prologue. DS51284F-page 92 __ ((interrupt [( [ save(symbol-list)] [, irq(irqid)] [, altirq(altirqid)] [, preprologue(asm © 2007 Microchip Technology Inc. ...

Page 99

... For example, to declare an interrupt handler for the timer0 interrupt: #include <p30fxxxx.h> void _ISR _INT0Interrupt(void); To declare an interrupt handler for the SPI1 interrupt with fast context save: #include <p30fxxxx.h> void _ISRFAST _SPI1Interrupt(void); © 2007 Microchip Technology Inc interrupt )) isr0(void); __ ...

Page 100

... UART1RX Uart 1 Receiver UART1TX Uart 1 Transmitter ADC convert completed NMM NVM write completed 2 Slave I C™ interrupt 2 Master I C™ interrupt CN Input change interrupt INT1 External interrupt 0 IC7 Input capture 7 IC8 Input capture 8 OC3 Output compare 3 © 2007 Microchip Technology Inc. ...

Page 101

... N/A _OscillatorFail N/A _AddressError N/A _StackError N/A _MathError N/A _ReservedTrap5 N/A _ReservedTrap6 N/A _ReservedTrap7 © 2007 Microchip Technology Inc. INTERRUPT VECTORS – dsPIC30F DSCs (NON-SMPS) Alternate Name _AltOC4Interrupt _AltT4Interrupt _AltT5Interrupt _AltINT2Interrupt _AltU2RXInterrupt _AltU2TXInterrupt _AltSPI2Interrupt _AltC1Interrupt _AltIC3Interrupt _AltIC4Interrupt _AltIC5Interrupt _AltIC6Interrupt _AltOC5Interrupt ...

Page 102

... Analog comparator interrupt 2 Analog comparator interrupt 3 Analog comparator interrupt 4 Reserved Reserved Reserved Reserved ADC Pair 0 conversion complete ADC Pair 1 conversion complete ADC Pair 2 conversion complete ADC Pair 3 conversion complete ADC Pair 4 conversion complete ADC Pair 5 conversion complete Reserved © 2007 Microchip Technology Inc. ...

Page 103

... Microchip Technology Inc. INTERRUPT VECTORS - dsPIC30F DSCs (SMPS) (CONTINUED) Alternate Name _AltInterrupt44 _AltInterrupt45 _AltInterrupt46 _AltInterrupt47 _AltInterrupt48 _AltInterrupt49 _AltInterrupt50 _AltInterrupt51 _AltInterrupt52 _AltInterrupt53 INTERRUPT VECTORS - PIC24F MCUs Alternate Name _AltReservedTrap0 _AltOscillatorFail _AltAddressError ...

Page 104

... C™ interrupt 2 2 Slave I C™ interrupt 2 Reserved Reserved INT3 External interrupt 3 INT4 External interrupt 4 Reserved Reserved Reserved Reserved Reserved Reserved Reserved Real-time clock and calender Reserved Reserved UART1 error interrupt UART2 error interrupt Cyclic Redundancy Check Reserved © 2007 Microchip Technology Inc. ...

Page 105

... Microchip Technology Inc. INTERRUPT VECTORS - PIC24F MCUs (CONTINUED) Alternate Name _AltInterrupt69 _AltInterrupt70 _AltInterrupt71 _AltInterrupt72 _AltInterrupt73 _AltInterrupt74 _AltInterrupt75 _AltInterrupt76 _AltInterrupt77 _AltInterrupt78 _AltInterrupt79 _AltInterrupt80 _AltInterrupt81 ...

Page 106

... Master I C™ interrupt 1 Reserved CN Input change interrupt INT1 External interrupt 1 ADC 2 convert completed IC7 Input capture 7 IC8 Input capture 8 DMA 2 interrupt OC3 Output compare 3 OC4 Output compare 4 TMR4 Timer 4 expired TMR5 Timer 5 expired INT2 External interrupt 2 © 2007 Microchip Technology Inc. ...

Page 107

... Microchip Technology Inc. INTERRUPT VECTORS - dsPIC33F DSCs/PIC24H MCUs Alternate Name _AltU2RXInterrupt _AltU2TXInterrupt _AltSPI2ErrInterrupt _AltSPI2Interrupt _AltC1RxRdyInterrupt _AltC1Interrupt _AltDMA3Interrupt _AltIC3Interrupt _AltIC4Interrupt _AltIC5Interrupt _AltIC6Interrupt _AltOC5Interrupt _AltOC6Interrupt _AltOC7Interrupt _AltOC8Interrupt _AltInterrupt45 _AltDMA4Interrupt _AltT6Interrupt ...

Page 108

... Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved Reserved © 2007 Microchip Technology Inc. ...

Page 109

... In the same way, if the altirq parameter of the interrupt attribute is used, the compiler creates the external symbol name __AltInterruptn, where n is the vector number. Therefore, the C identifiers _AltInterrupt45 through _AltInterrupt53 are reserved by the compiler. © 2007 Microchip Technology Inc interrupt )) _StackError(void) ...

Page 110

... Interrupt Priority Control registers (IPCn). If there is a pending Interrupt Request (IRQ) with a priority level equal to or greater than the current proces- sor priority level in the Processor Status register (CPUPRI field in the ST register), an interrupt will be presented to the processor. DS51284F-page 104 interrupt ( preprologue __ ("inc _semaphore")))) © 2007 Microchip Technology Inc. ...

Page 111

... For example, you may wish to protect a section of code from interrupt. The following code will adjust the current IPL setting and restore the IPL to its previous value. void foo(void) { int current_cpu_ipl; SET_AND_SAVE_CPU_IPL(current_cpu_ipl, 7); /* protected code here */ RESTORE_CPU_IPL(current_cpu_ipl); } © 2007 Microchip Technology Inc. Interrupts /* disable interrupts */ DS51284F-page 105 ...

Page 112

... Here are some sample flow sequences: 1. Safe: read bar read baz perform operation write back result to foo DS51284F-page 106 BAR MUST MATCH BAZ © 2007 Microchip Technology Inc. ...

Page 113

... The dsPIC DSC instruction set can operate on 1 bit atomically. The compiler may select these instructions depending upon optimization level, memory settings and resource availability. © 2007 Microchip Technology Inc. TYPE OF FOO, BAR AND BAZ BIT FIELDS Interrupts ...

Page 114

... First reads LATG into a W reg, implements XOR operation, then writes result to LATG */ /* No problem, this is a write only assignment operation */ /* No problem likely, this is an assignment of a single bit and will use a single instruction bit set operation */ \ \ \ \ \ © 2007 Microchip Technology Inc. ...

Page 115

... A warning diagnostic message will also be issued. The warning will help alert cus- tomers to the migration issue, and to the possibility of reducing interrupt latency by specifying the no_auto_psv attribute. © 2007 Microchip Technology Inc. Interrupts /* No problem likely, single instruction bit clear ...

Page 116

... MPLAB C30 User’s Guide NOTES: DS51284F-page 110 © 2007 Microchip Technology Inc. ...

Page 117

... C regardless of where they were originally defined. The file ex1.c defines foo and cVariable to be used in the assembly language file. The C file also shows how to call an assembly function, asmFunction, and how to access the assembly defined variable, asmVariable. © 2007 Microchip Technology Inc. ® MPLAB C30 USER’ ...

Page 118

... The following MPLAB C30 example shows how to call an assembly function with two parameters. The C function main in call1.c calls the asmFunction in call2.s with two parameters. DS51284F-page 112 MIXING C AND ASSEMBLY © 2007 Microchip Technology Inc. ...

Page 119

... Constraint letters and modifiers supported by MPLAB C30 are listed in Table 8-1 and Table 8-2 respectively. © 2007 Microchip Technology Inc. CALLING AN ASSEMBLY FUNCTION "constraint"(input-operand ... ] ] [ "clobber" ... ] ] ] ]) ...

Page 120

... Commas separate output operands and separate inputs. DS51284F-page 114 CONSTRAINT LETTERS SUPPORTED BY MPLAB Constraint CONSTRAINT MODIFIERS SUPPORTED BY MPLAB Constraint PASSING C VARIABLES ® C30 ® C30 © 2007 Microchip Technology Inc. ...

Page 121

... W0 and W1: asm ("mov %0,w0\nmov %1,W1\ncall _foo" outputs */ : "g" (a), "g" (b) : "W0", "W1"); In this example, the constraint strings “g” indicate a general operand. © 2007 Microchip Technology Inc. CLOBBERING REGISTERS USING MULTIPLE ASSEMBLER INSTRUCTIONS DS51284F-page 115 ...

Page 122

... DS51284F-page 116 USING '&' TO PREVENT INPUT REGISTER CLOBBERING __ ("add %1,%2,%0\n sl %0,%1,%0" : "=r"(c) : "r"(a), "r"(b)); __ ("add %1,%2,%0\n sl %0,%1,%0" : "=&r"(c) : "r"(a), "r"(b)); MATCHING OPERANDS © 2007 Microchip Technology Inc. ...

Page 123

... In this case, the asm("error: ") and following state- ments will be deleted because they are unreachable. See further information regarding labels in asm statements. © 2007 Microchip Technology Inc. NAMING OPERANDS VOLATILE ASM STATEMENTS MAKING CONTROL FLOW CHANGES : /* inputs */ : " ...

Page 124

... The above form is slightly better; at least it will fix the multiply-defined label issue. However the procedural aggregator tool (-mpa) does not accept the 0: form of label. DS51284F-page 118 : /* inputs */ : "cc"); ) will loopend: " " ® ASM30, © 2007 Microchip Technology Inc. ...

Page 125

... By default, %0 represents the first register for the operand (0). To access the second, third, or fourth register, use a modifier letter specified in Table 8-2. © 2007 Microchip Technology Inc. USING REQUIRED REGISTERS /* outputs */ "=r"(out1), "=r"(out2 inputs */ " ...

Page 126

... MPLAB C30 User’s Guide NOTES: DS51284F-page 120 © 2007 Microchip Technology Inc. ...

Page 127

... Preprocessing Directives • Library Functions • Signals • Streams and Files • tmpfile • errno • Memory • abort • exit • getenv • system • strerror © 2007 Microchip Technology Inc. ® MPLAB C30 USER’S GUIDE DS51284F-page 121 ...

Page 128

... Describe the arguments (parameters) passed to the function main? (ISO 5.1.2.2.1) No parameters are passed to main. Which of the following is a valid interactive device: (ISO 5.1.2.3) Asynchronous terminalNo Paired display and keyboardNo Inter program connectionNo Other, please describe?None DS51284F-page 122 © 2007 Microchip Technology Inc. ...

Page 129

... The identity function. What is the equivalent type of a plain char? (ISO 6.2.1.1) Either (user defined). The default is signed char. A compiler command-line option may be used to make the default unsigned char. © 2007 Microchip Technology Inc. Implementation-Defined Behavior ESCAPE SEQUENCE CHARACTERS AND VALUES Sequence ...

Page 130

... Range © 2007 Microchip Technology Inc. ...

Page 131

... C Standard. To what extent does the storage class specifier register actually effect the storage of objects in registers? (ISO 6.5.1) If optimization is disabled, an attempt will be made to honor the register storage class; otherwise ignored. © 2007 Microchip Technology Inc. Implementation-Defined Behavior FLOATING-POINT TYPES Size (bits) 32 1.175494e-38 … 3.40282346e+38 32 1.175494e-38 … ...

Page 132

... What is the maximum number of declarators that may modify an arithmetic, structure, or union type? (ISO 6.5.4) No limit. A.14 STATEMENTS Implementation-Defined Behavior for Statements is covered in section G.3.12 of the ANSI C Standard. What is the maximum number of case values in a switch statement? (ISO 6.6.4.2) No limit. DS51284F-page 126 © 2007 Microchip Technology Inc. ...

Page 133

... What are the definitions for __ DATE __ and __ TIME __ respectively, when the date and time of translation are not available? (ISO 6.8.8) Not applicable. The compiler is not supported in environments where these functions are not available. © 2007 Microchip Technology Inc. Implementation-Defined Behavior #PRAGMA BEHAVIOR Pragma Names the code section ...

Page 134

... One of the letters: islower or isupper. One of the five standard motion control characters, backspace and alert: \f, \n, \r, \t, \v, \b, \ One of the letters a through graphic character or the space character: isalnum or ispunct or space One of the letters A through Z . One of the characters: ! " & < = > © 2007 Microchip Technology Inc. ...

Page 135

... Application defined. Describe the characteristics of file buffering. (ISO 7.9.3) Fully buffered. Can zero-length file actually exist? (ISO 7.9.3) Yes. © 2007 Microchip Technology Inc. Implementation-Defined Behavior SIGNAL FUNCTION Abnormal termination. Receipt of an interactive attention signal. Detection of an invalid function image. ...

Page 136

... What happens to open and temporary files when the abort function is called? (ISO 7.10.4.1) Nothing. A.23 EXIT What is the status returned by the exit function if the value of the argument is other than zero, EXIT_SUCCESS, or EXIT_FAILURE? (ISO 7.10.4.3) The value of the argument. DS51284F-page 130 © 2007 Microchip Technology Inc. ...

Page 137

... List the contents of the error message strings returned by a call to the strerror function. (ISO 7.11.6.2) TABLE A-7: Errno 0 EDOM ERANGE EFPOS EFOPEN nnn © 2007 Microchip Technology Inc. Implementation-Defined Behavior ERROR MESSAGE STRINGS no error domain error range error file positioning error file open error error #nnn Message ...

Page 138

... MPLAB C30 User’s Guide NOTES: DS51284F-page 132 © 2007 Microchip Technology Inc. ...

Page 139

... Microchip Technology Inc. ® MPLAB __builtin_mpy __builtin_tblrdh __builtin_mpyn __builtin_tblrdl __builtin_msc __builtin_tblwth __builtin_mulss __builtin_tblwtl __builtin_mulsu __builtin_write_NVM __builtin_mulus __builtin_write_OSCCONL __builtin_muluu __builtin_write_OSCCONH __builtin_nop __builtin_psvpage ...

Page 140

... Integer number to add to accumulator value. value Amount to shift resultant accumulator value. shift Returns the shifted addition result to an accumulator. add An error message will be displayed if: • the result is not an accumulator register • the shift value is not a literal within range ), so they __builtin_ © 2007 Microchip Technology Inc. ...

Page 141

... Machine Instruction: Error Messages builtin_clr __ Description: Prototype: Argument: Return Value: © 2007 Microchip Technology Inc. MPLAB C30 Built-in Functions This function will generate a btg machine instruction. Some examples include: int i; /* near by default */ int l __attribute__((far)); struct foo { int bit1:1; } barbits; ...

Page 142

... Microchip Technology Inc. ...

Page 143

... Description: Prototype: Argument: Return Value: Assembler Opera- tor / Machine Instruction: © 2007 Microchip Technology Inc. MPLAB C30 Built-in Functions Integer pointer to x prefetch. xptr Integer value of x prefetch. xval Integer increment value of x prefetch. xincr Integer pointer to y prefetch. yptr Integer value of y prefetch ...

Page 144

... Might generate: mov #dmaoffset(buffer), w0 unsigned int __builtin_dmaoffset(const void *p); pointer to DMA address value *p Returns the offset to an accumulator. dmaoffset An error message will be displayed if the result is not an accumulator register. © 2007 Microchip Technology Inc. ...

Page 145

... Instruction: Error Messages builtin_edac __ Description: © 2007 Microchip Technology Inc. MPLAB C30 Built-in Functions Squares sqr, returning it as the result. Also prefetchs data for future square operation by computing **xptr - **yptr and storing the result in *distance. xincr and yincr may be the literal values: -6, -4, - integer value ...

Page 146

... For example: register int result asm("A"); int value; result = __builtin_lac(value,3); Might generate: lac w4, #3, A int __builtin_lac(int value, int shift); Integer number to be shifted. value Literal amount to shift. shift Returns the shifted addition result to an accumulator. © 2007 Microchip Technology Inc. ...

Page 147

... Argument: Return Value: Assembler Opera- tor / Machine Instruction: Error Messages © 2007 Microchip Technology Inc. MPLAB C30 Built-in Functions lac An error message will be displayed if: • the result is not an accumulator register • the shift value is not a literal within range Computes and sums with accumulator; also prefetchs data ready for a future MAC operation ...

Page 148

... This form of the builtin function will capture only the remainder. unsigned int __builtin_modud(unsigned long dividend, unsigned int divisor); number to be divided dividend number to divide by divisor Remainder. modud None. © 2007 Microchip Technology Inc. ...

Page 149

... Return Value: Assembler Opera- tor / Machine Instruction: Error Messages © 2007 Microchip Technology Inc. MPLAB C30 Built-in Functions Computes nothing, but prefetchs data ready for a future MAC operation. xptr may be null to signify no X prefetch to be performed, in which case the values of xincr and xval are ignored, but required. ...

Page 150

... Returns the cleared value result to an accumulator. mpy An error message will be displayed if: • the result is not an accumulator register • xval is a null value but xptr is not null • yval is a null value but yptr is not null © 2007 Microchip Technology Inc. ...

Page 151

... Return Value: Assembler Opera- tor / Machine Instruction: Error Messages © 2007 Microchip Technology Inc. MPLAB C30 Built-in Functions Computes - also prefetchs data ready for a future MAC operation. xptr may be null to signify no X prefetch to be performed, in which case the values of xincr and xval are ignored, but required. ...

Page 152

... Computes the product p0 x p1. Function arguments are signed inte- gers, and the function result is a signed long integer. The command-line option -Wconversions can be used to detect unexpected sign conversions. signed long __builtin_mulss(const signed int p0, const signed int p1); © 2007 Microchip Technology Inc. ...

Page 153

... Assembler Opera- tor / Machine Instruction: builtin_muluu __ Description: Prototype: Argument: Return Value: © 2007 Microchip Technology Inc. MPLAB C30 Built-in Functions multiplicand p0 multiplier p1 Returns the signed long integer value of the product p0 x p1. mul.ss Computes the product p0 x p1. Function arguments are integers with mixed signs, and the function result is a signed long integer ...

Page 154

... See the space attribute in the ® “MPLAB C30 C Compiler User’s Guide” (DS51284) unsigned int __builtin_psvoffset(const void *p); object address p Returns the psv page number offset of the object whose address is given as a parameter. psvoffset © 2007 Microchip Technology Inc. ...

Page 155

... Description: Prototype: Argument: Return Value: © 2007 Microchip Technology Inc. MPLAB C30 Built-in Functions The following error message is produced when this function is used incorrectly: “Argument to __builtin_psvoffset() is not the address of an object in code, psv, or eedata section”. The argument must be an explicit object address. ...

Page 156

... Might generate: sftac A, w0 int __builtin_sftac(int shift); Literal amount to shift. shift Returns the shifted result to an accumulator. sftac An error message will be displayed if: • the result is not an accumulator register • the shift value is not a literal within range © 2007 Microchip Technology Inc. ...

Page 157

... Instruction: Error Messages builtin_tbloffset __ Description: Prototype: Argument: Return Value: © 2007 Microchip Technology Inc. MPLAB C30 Built-in Functions Subtracts acumulators A and B with the result written back to the specified accumulator. For example: register int result asm("A"); result = __builtin_subab(); will generate: sub A int __builtin_subab(void) ...

Page 158

... To do this, you may make use of __builtin_tbloffset() and__builtin_tblpage(). Please refer to the data sheet or “dsPIC30F Family Reference Manual” (DS70046) for complete details regarding reading and writing program Flash. unsigned int __builtin_tblrdl(unsigned int offset); desired memory offset offset None. tblrdl None. © 2007 Microchip Technology Inc. ...

Page 159

... Assembler Opera- tor / Machine Instruction: Error Messages © 2007 Microchip Technology Inc. MPLAB C30 Built-in Functions Issues the tblwth.w instruction to write a word to Flash or EEDATA memory. You must set up the TBLPAG to point to the appropriate page this, you may make use of __builtin_tbloffset() and __builtin_tblpage(). Please refer to the data sheet or “ ...

Page 160

... None. Unlocks and writes its argument to OSCCONH. void __builtin_write_OSCCONH(unsigned char value); character to be written value None. mov #0x78, w0 mov #0x9A, w1 mov #_OSCCON+1, w2 mov.b w0, [w2] mov.b w1, [w2] mov.b value, [w2] None. © 2007 Microchip Technology Inc. ...

Page 161

... In a preprocessor conditional, the #if must be used before using the #elif. #else after #else In a preprocessor conditional, the #else clause must appear only once. #else without # preprocessor conditional, the #if must be used before using the #else. © 2007 Microchip Technology Inc. ® MPLAB C30 USER’S GUIDE ...

Page 162

... The '__alignof' operator may not be applied to a bit-field. alternate interrupt vector is not a constant The interrupt vector number must be an integer constant. alternate interrupt vector number n is not valid A valid interrupt vector number is required. DS51284F-page 156 © 2007 Microchip Technology Inc. ...

Page 163

... Asm templates must be string constants. assertion without predicate #assert or #unassert must be followed by a predicate, which must be a single identifier. 'attribute' attribute applies only to functions The attribute 'attribute' may only be applied to functions. © 2007 Microchip Technology Inc. MPLAB C30 C Compiler Diagnostics DS51284F-page 157 ...

Page 164

... Case labels must be compile-time integer constants. case label not within a switch statement Case labels must be within a switch statement. cast specifies array type It is not permissible for a cast to specify an array type. DS51284F-page 158 © 2007 Microchip Technology Inc. ...

Page 165

... The macro name cannot be called 'defined'. dereferencing pointer to incomplete type A dereferenced pointer must be a pointer to an incomplete type. division by zero in #if Division by zero is not computable. © 2007 Microchip Technology Inc. MPLAB C30 C Compiler Diagnostics DS51284F-page 159 ...

Page 166

... The type of the expression is incomplete. extra brace group at end of initializer Do not place extra brace groups at the end of initializers. extraneous argument to 'option' option There are too many arguments to the specified command-line option. DS51284F-page 160 © 2007 Microchip Technology Inc. ...

Page 167

... The format_arg attribute may only be used with a function which return value is a string type. function 'identifier' is initialized like a variable It is not legal to initialize a function like a variable. function return type cannot be function The return type of a function cannot be a function. © 2007 Microchip Technology Inc. MPLAB C30 C Compiler Diagnostics DS51284F-page 161 ...

Page 168

... Do not increment a pointer to an unknown structure. initializer element is not computable at load time Initializer elements must be computable at load time. initializer element is not constant Initializer elements must be constant. initializer fails to determine size of 'identifier' An array initializer fails to determine its size. DS51284F-page 162 © 2007 Microchip Technology Inc. ...

Page 169

... This message appears when an unprintable character, such as a control character, appears after #if. invalid initial value for member 'name' Bit-field 'name' can only be initialized by an integer. invalid initializer Do not use invalid initializers. © 2007 Microchip Technology Inc. MPLAB C30 C Compiler Diagnostics DS51284F-page 163 ...

Page 170

... Only const or volatile may be used as type modifiers within a pointer declarator. invalid use of array with unspecified bounds Arrays with unspecified bounds must be used in valid ways. invalid use of incomplete typedef 'typedef' The specified typedef is being used in an invalid way; this is not allowed. DS51284F-page 164 © 2007 Microchip Technology Inc. ...

Page 171

... Macro names must start with a letter or underscore followed by more letters, numbers or underscores. macro parameters must be comma-separated Commas are required between parameters in a list of parameters. macro 'name' passed n arguments, but takes just n Too many arguments were passed to macro 'name'. © 2007 Microchip Technology Inc. MPLAB C30 C Compiler Diagnostics DS51284F-page 165 ...

Page 172

... Only a single default label may be specified for each switch. multiple parameters named 'identifier' Parameter names must be unique. multiple storage classes in declaration of 'identifier' Each declaration should have a single storage class. DS51284F-page 166 © 2007 Microchip Technology Inc. ...

Page 173

... The asm statement is invalid. output operand constraint lacks '=' The asm statement is invalid. output operand is constant in 'asm' The asm statement is invalid. overflow in enumeration values Enumeration values must be in the range of 'int'. © 2007 Microchip Technology Inc. MPLAB C30 C Compiler Diagnostics DS51284F-page 167 ...

Page 174

... This message identifies the location of a previous definition of identifier that conflicts with the current definition. prototype declaration Identifies the line number where a function prototype is declared. Used in conjunction with other error messages. DS51284F-page 168 © 2007 Microchip Technology Inc. ...

Page 175

... The object being saved must be word aligned save variable 'name' size is not even The object being saved must be evenly sized. save variable 'name' size is not known The object being saved must have a known size. © 2007 Microchip Technology Inc. MPLAB C30 C Compiler Diagnostics DS51284F-page 169 ...

Page 176

... A structure member named 'identifier' is referenced; but the referenced structure contains no such member. This is not allowed. subscripted value is neither array nor pointer Only arrays or pointers may be subscripted. switch quantity not an integer Switch quantities must be integers DS51284F-page 170 © 2007 Microchip Technology Inc. ...

Page 177

... Specify a complete type for the indicated parameter. type mismatch in conditional expression Types in conditional expressions must not be mismatched. typedef 'identifier' is initialized It is not legal to initialize typedef's. Use __typeof__ instead. © 2007 Microchip Technology Inc. MPLAB C30 C Compiler Diagnostics DS51284F-page 171 ...

Page 178

... It is not legal to initialize variables with incomplete types. variable or field 'identifier' declared void Neither variables nor fields may be declared void. variable-sized object may not be initialized It is not legal to initialize a variable-sized object. virtual memory exhausted Not enough memory left to write error message. DS51284F-page 172 © 2007 Microchip Technology Inc. ...

Page 179

... Do not use the wrong type of argument to this operator. wrong type argument to unary plus Do not use the wrong type of argument to this operator. Z zero width for bit-field 'identifier' Bit-fields may not have zero width. © 2007 Microchip Technology Inc. MPLAB C30 C Compiler Diagnostics DS51284F-page 173 ...

Page 180

... An anonymous struct is declared inside a function parameter list usually better programming practice to declare structs outside parameter lists, since they can never become complete types when defined inside parameter lists. DS51284F-page 174 © 2007 Microchip Technology Inc. ...

Page 181

... While processing for escape sequences, a backslash and newline were found at the end of the file. bit-field 'identifier' type invalid in ISO C The type used on the specified identifier is not valid in ISO C. braces around scalar initializer A redundant set of braces around an initializer is supplied. © 2007 Microchip Technology Inc. MPLAB C30 C Compiler Diagnostics DS51284F-page 175 ...

Page 182

... Floating-point values can be approximations to infinitely precise real numbers. Instead of testing for equality, use relational operators to see whether the two values have ranges that overlap. comparison between pointer and integer A pointer type is being compared to an integer type. DS51284F-page 176 © 2007 Microchip Technology Inc. ...

Page 183

... Therefore, the return value might be unpredictable. conversion lacks type at end of format When checking the argument list of a call to printf, scanf, etc., the compiler found that a format field in the format string lacked a type specifier. © 2007 Microchip Technology Inc. MPLAB C30 C Compiler Diagnostics DS51284F-page 177 ...

Page 184

... A label should not be at the end of a statement. It should be followed by a statement. dereferencing 'void *' pointer It is not correct to dereference a 'void *' pointer. Cast pointer of the appropriate type before dereferencing the pointer. division by zero Compile-time division by zero has been detected. DS51284F-page 178 © 2007 Microchip Technology Inc. ...

Page 185

... There are more elements in the initializer list than the structure was declared with. excess elements in union initializer There are more elements in the initializer list than the union was declared with. © 2007 Microchip Technology Inc. MPLAB C30 C Compiler Diagnostics DS51284F-page 179 ...

Page 186

... In this case, a function definition was encountered without a preceding function prototype. function declared 'noreturn' has a 'return' statement A function was declared with the noreturn attribute-indicating that the function does not return-yet the function contains a return statement. This is inconsistent. DS51284F-page 180 © 2007 Microchip Technology Inc. ...

Page 187

... ISO C does not allow imaginary numeric constants. implicit declaration of function 'identifier' The specified function has no previous explicit declaration (definition or function prototype), so the compiler makes assumptions about its return type and parameters. © 2007 Microchip Technology Inc. MPLAB C30 C Compiler Diagnostics DS51284F-page 181 ...

Page 188

... Third argument must 'identifier unrecognized format function type The specified identifier, used with the format attribute, is not one of the recognized format function types printf, scanf, or strftime. DS51284F-page 182 © 2007 Microchip Technology Inc. ...

Page 189

... Subscripting a 'register' array is not allowed in ISO C. ISO C forbids taking the address of a label Taking the address of a label is not allowed in ISO C. ISO C forbids zero-size array 'name' The array size of 'name' must be larger than zero. © 2007 Microchip Technology Inc. MPLAB C30 C Compiler Diagnostics DS51284F-page 183 ...

Page 190

... Shift counts should be less than the number of bits in the type being shifted. Otherwise, the shift is meaningless, and the result is undefined. left shift count is negative Shift counts should be positive. A negative left shift count does not mean shift right meaningless. DS51284F-page 184 © 2007 Microchip Technology Inc. ...

Page 191

... A required set of braces around an initializer is missing. missing initializer An initializer is missing. modification by 'asm' of read-only variable 'identifier' A const variable is the left-hand-side of an assignment in an 'asm' statement. multi-character character constant A character constant contains more than one character. © 2007 Microchip Technology Inc. MPLAB C30 C Compiler Diagnostics DS51284F-page 185 ...

Page 192

... The constant expression has exceeded the range of representable values for its type. overflow in implicit constant conversion An implicit constant conversion resulted in a number that cannot be represented as a signed int; therefore, the compiler automatically treats unsigned int. DS51284F-page 186 © 2007 Microchip Technology Inc. ...

Page 193

... This warning message appears in conjunction with the warning message “type mismatch with previous implicit declaration”. It locates the implicit declaration of the identifier that conflicts with the explicit declaration. © 2007 Microchip Technology Inc. MPLAB C30 C Compiler Diagnostics DS51284F-page 187 ...

Page 194

... The specified function has the same name as a built-in function, and consequently shadows the built-in function. shadowing library function 'identifier' The specified function has the same name as a library function, and consequently shadows the library function. DS51284F-page 188 © 2007 Microchip Technology Inc. ...

Page 195

... Use the format '#line linenum' for traditional C. subscript has type 'char' An array subscript has type 'char'. suggest explicit braces to avoid ambiguous 'else' A nested if statement has an ambiguous else clause recommended that braces be used to remove the ambiguity. © 2007 Microchip Technology Inc. MPLAB C30 C Compiler Diagnostics DS51284F-page 189 ...

Page 196

... The -fdelayed-branch option is not supported. too few arguments for format When checking the argument list of a call to printf, scanf, etc., the compiler found that the number of actual arguments was fewer than that required by the format string. DS51284F-page 190 © 2007 Microchip Technology Inc. ...

Page 197

... The specified union is declared inside a function parameter list usually better programming practice to declare unions outside parameter lists, since they can never become complete types when defined inside parameter lists. © 2007 Microchip Technology Inc. MPLAB C30 C Compiler Diagnostics ??< ??> ??= = # ??/ = \ ...

Page 198

... The specified function was used but never defined. 'name' used with 'spec' 'function' format 'name' is not valid with the conversion specification 'spec' in the format of the specified function. useless keyword or type name in empty declaration An empty declaration contains a useless keyword or type name. DS51284F-page 192 © 2007 Microchip Technology Inc. ...

Page 199

... The specified identifier was previously declared implicitly 'extern' and is now being declared as static. 'identifier' was previously implicitly declared to return 'int' There is a mismatch against the previous implicit declaration. © 2007 Microchip Technology Inc. MPLAB C30 C Compiler Diagnostics DS51284F-page 193 ...

Page 200

... Z zero-length identifier format string When checking the argument list of a call to printf, scanf, etc., the compiler found that the format string was empty (“”). DS51284F-page 194 © 2007 Microchip Technology Inc. ...

Related keywords