MPLAB XC16 C Compiler User's Guide
User Manual:
Open the PDF directly: View PDF
Page Count: 396 [warning: Documents this large are best viewed by clicking the View PDF Link!]
- MPLAB XC16 C Compiler User's Guide
- Table of Contents
- Preface
- Chapter 1. Compiler Overview
- Chapter 2. Common C Interface
- 2.1 Introduction
- 2.2 Background – The Desire for Portable Code
- 2.3 Using the CCI
- 2.4 ANSI Standard Refinement
- 2.4.1 Source File Encoding
- 2.4.2 The Prototype for main
- 2.4.3 Header File Specification
- 2.4.4 Include Search Paths
- 2.4.5 The Number of Significant Initial Characters in an Identifier
- 2.4.6 Sizes of Types
- 2.4.7 Plain char Types
- 2.4.8 Signed Integer Representation
- 2.4.9 Integer Conversion
- 2.4.10 Bitwise Operations on Signed Values
- 2.4.11 Right-shifting Signed Values
- 2.4.12 Conversion of Union Member Accessed Using Member With Different Type
- 2.4.13 Default Bit-field int Type
- 2.4.14 Bit-fields Straddling a Storage Unit Boundary
- 2.4.15 The Allocation Order of Bit-fields
- 2.4.16 The NULL Macro
- 2.4.17 Floating-point Sizes
- 2.5 ANSI Standard Extensions
- 2.5.1 Generic Header File
- 2.5.2 Absolute Addressing
- 2.5.3 Far Objects and Functions
- 2.5.4 Near Objects
- 2.5.5 Persistent Objects
- 2.5.6 X and Y Data Objects
- 2.5.7 Banked Data Objects
- 2.5.8 Alignment of Objects
- 2.5.9 EEPROM Objects
- 2.5.10 Interrupt Functions
- 2.5.11 Packing Objects
- 2.5.12 Indicating Antiquated Objects
- 2.5.13 Assigning Objects to Sections
- 2.5.14 Specifying Configuration Bits
- 2.5.15 Manifest Macros
- Table 2-1: Manifest macros defined by the CCI
- 2.5.16 In-line Assembly
- 2.6 Compiler Features
- Chapter 3. How To’s
- 3.1 Introduction
- 3.2 Installing and Activating the Compiler
- 3.3 Invoking the Compiler
- 3.3.1 How Do I Compile from Within MPLAB X IDE?
- 3.3.2 How Do I Compile on the Command Line?
- 3.3.3 How Can I Select Which Compiler Version to Build With?
- 3.3.4 How Can I Change the Compiler Optimizations?
- 3.3.5 How Do I Know Which Optimization Features I Get?
- 3.3.6 How Do I Know Which Compiler Options Are Available and What They Do?
- 3.3.7 How Do I Build Libraries?
- 3.3.8 How Do I Know What the Build Options in MPLAB X IDE Do?
- 3.3.9 What is Different About an MPLAB X IDE Debug Build?
- 3.4 Writing Source Code
- 3.5 Getting My Application to Do What I Want
- 3.5.1 How Do I Generate Debug Information?
- 3.5.2 Why No Disassembly in the MPLAB X IDE Disassembly Window?
- 3.5.3 How Do I Share Data Between Interrupt and Main-line Code?
- 3.5.4 How to Protect My Code After It Is Programmed Into a Device?
- 3.5.5 How Do I Redirect Standard I/O When Using Printf?
- 3.5.6 How Do I Place Variables in Off-Chip Memory?
- 3.5.7 How Can I Implement a Delay in My Code?
- 3.5.8 How Can I Rotate a Variable?
- 3.6 Understanding the Compilation Process
- 3.6.1 How Does Licensing Affect Features and Optimization Levels?
- 3.6.2 How Can I Make My Code Smaller?
- 3.6.3 How Can I Reduce RAM Usage?
- 3.6.4 How Can I Make My Code Faster?
- 3.6.5 How Can I Control Where the Language Tool Places Objects in Memory?
- 3.6.6 How Can I Make My Interrupt Routine Faster?
- 3.6.7 How Big Can C Variables Be?
- 3.6.8 Which Optimizations Will Be Applied to My Code?
- 3.6.9 Which Devices are Supported by the Compiler?
- 3.6.10 How Do I Know What Code the Compiler Is Producing?
- 3.6.11 How Can I Tell How Big a Function Is?
- 3.6.12 How Do I Learn Where Variables and Functions Have Been Positioned?
- 3.6.13 How Do I Properly Reserve Memory?
- 3.6.14 How Do I Know How Much Memory Is Still Available?
- 3.6.15 Which Libraries Get Included by Default?
- 3.6.16 How Do I Create My Own Libraries?
- 3.6.17 Why Do I Get Out-of-memory Errors When I Select a Debugger?
- 3.7 Fixing Code That Does Not Work
- 3.7.1 How Do I Find Out What a Warning or Error Message Means?
- 3.7.2 How Do I Find the Code that Caused Compiler Errors Or Warnings in My Program?
- 3.7.3 How Can I Stop Warnings from Being Produced?
- 3.7.4 How Do I Know If the Stack Has Overflowed?
- 3.7.5 What Can Cause Corrupted Variables and Code Failure When Using Interrupts?
- Chapter 4. XC16 Toolchain and MPLAB X IDE
- 4.1 Introduction
- 4.2 MPLAB X IDE and Tools Installation
- 4.3 MPLAB X IDE Setup
- 4.4 MPLAB X IDE Projects
- 4.5 Project Setup
- Figure 4-3: Project Properties Window
- 4.5.1 XC16 (Global Options)
- Table 4-1: All Options Category
- 4.5.2 xc16-as (16-Bit Assembler)
- Table 4-2: General Options Category
- Table 4-3: Listing File Options Category (Continued)
- 4.5.3 xc16-gcc (16-Bit C Compiler)
- Table 4-4: General Category
- Table 4-5: Memory Model Category
- Table 4-6: Optimizations Category
- Table 4-7: Preprocessing and Messages Category
- 4.5.4 xc16-ld (16-Bit Linker)
- Table 4-8: General Category
- Table 4-9: Symbols and Macros Category
- Table 4-10: Fill Flash Memory Category
- Table 4-11: Libraries Category
- Table 4-12: Diagnostics Category
- Table 4-13: Code Guard Category
- 4.5.5 xc16-ar (16-Bit Archiver/Librarian)
- Table 4-14: General Category
- 4.5.6 Options Page Features
- Table 4-15: Page Features Options
- 4.5.7 Additional Search Paths and Directories
- 4.6 Project Example
- Chapter 5. Compiler Command-Line Driver
- 5.1 Introduction
- 5.2 Invoking the Compiler
- 5.3 The Compilation Sequence
- 5.4 Runtime Files
- 5.5 Compiler Output
- 5.6 Compiler Messages
- 5.7 Driver Option Descriptions
- 5.7.1 Options Specific to 16-Bit Devices
- Table 5-5: 16-Bit Device-Specific Options
- 5.7.2 Options for Controlling the Kind of Output
- Table 5-6: Kind-of-Output Control Options
- 5.7.3 Options for Controlling the C Dialect
- Table 5-7: C Dialect Control Options
- 5.7.4 Options for Controlling Warnings and Errors
- Table 5-8: Warning/Error Options Implied by -Wall
- Table 5-9: Warning/Error Options not Implied by -Wall
- 5.7.5 Options for Debugging
- Table 5-10: Debugging Options
- 5.7.6 Options for Controlling Optimization
- Table 5-11: General Optimization Options
- Table 5-12: Specific Optimization Options
- Table 5-13: Machine-Independent Optimization Options
- 5.7.7 Options for Controlling the Preprocessor
- Table 5-14: Preprocessor Options
- 5.7.8 Options for Assembling
- Table 5-15: Assembly Options
- 5.7.9 Options for Linking
- Table 5-16: Linking Options
- 5.7.10 Options for Directory Search
- Table 5-17: Directory Search Options
- 5.7.11 Options for Code Generation Conventions
- Table 5-18: Code Generation Convention Options
- 5.8 MPLAB X IDE Toolchain Equivalents
- Chapter 6. Device-Related Features
- Chapter 7. Differences Between MPLAB XC16 and ANSI C
- Chapter 8. Supported Data Types and Variables
- Chapter 9. Fixed-Point Arithmetic Support
- Chapter 10. Memory Allocation and Access
- 10.1 Introduction
- 10.2 Address Spaces
- 10.3 Variables In Data Space Memory
- 10.3.1 Auto and Non-Auto Variables vs. Local and Global Variables
- 10.3.2 Non-Auto Variable Allocation and Access
- 10.3.3 Auto Variable Allocation and Access
- Figure 10-1: Stack and Frame Pointers
- Figure 10-2: CALL or RCALL
- Figure 10-3: Callee Space Allocation
- Figure 10-4: Push Callee-Saved Registers
- 10.3.4 Changing Auto Variable Allocation
- 10.4 Variables in Program Space
- 10.5 Parallel Master Port Access
- 10.6 External Memory Access
- 10.7 Extended Data Space Access
- 10.8 Dataflash Memory Access
- 10.9 Dual Partition Memory Access
- 10.10 Packing Data Stored in Flash
- 10.11 Allocation of Variables to Registers
- 10.12 Variables in EEPROM Data Space
- 10.13 Dynamic Memory Allocation
- 10.14 Co-resident Applications
- 10.15 Memory Models
- Chapter 11. Operators and Statements
- Chapter 12. Register Usage
- Chapter 13. Functions
- Chapter 14. Interrupts
- Chapter 15. Main, Runtime Startup and Reset
- Chapter 16. Mixing C and Assembly Code
- Chapter 17. Library Routines
- Chapter 18. Optimizations
- Chapter 19. Preprocessing
- 19.1 Introduction
- 19.2 C Language Comments
- 19.3 Preprocessing Directives
- 19.4 Predefined Macro Names
- 19.5 Pragmas vs. Attributes
- Table 19-6: C18 Pragmas vs. Attributes
- Table 19-7: PICC18 Pragmas and Qualifiers vs. Attributes
- Table 19-8: Locate the Variable Mabonga at Address 0x100 in Data Memory
- Table 19-9: Specify a Variable to be Placed in Program Memory
- Table 19-10: Locate the function PrintString at Address 0x8000 in Program Memory
- Table 19-11: Compiler automatically SaveS and Restores the Variables var1 and var2
- Chapter 20. Linking Programs
- Appendix A. Implementation-Defined Behavior
- A.1 Introduction
- A.2 Translation
- A.3 Environment
- A.4 Identifiers
- A.5 Characters
- A.6 Integers
- A.7 Floating Point
- A.8 Arrays and Pointers
- A.9 Registers
- A.10 Structures, Unions, Enumerations and Bit-Fields
- A.11 Qualifiers
- A.12 Declarators
- A.13 Statements
- A.14 Preprocessing Directives
- A.15 Library Functions
- A.16 Signals
- A.17 Streams and Files
- A.18 tmpfile
- A.19 errno
- A.20 Memory
- A.21 abort
- A.22 exit
- A.23 getenv
- A.24 system
- A.25 strerror
- Appendix B. Embedded Compiler Compatibility Mode
- Appendix C. Diagnostics
- Appendix D. GNU Free Documentation License
- Appendix F. Deprecated Features
- Appendix G. Built-in Functions
- Appendix H. Document Revision History
- Support
- Glossary
- Index
- Worldwide Sales and Service