 2000 Microchip Technology Inc. DS51217B Information contained in this publica

 2000 Microchip Technology Inc. DS51217B Information contained in this publication regarding device applications and the like is intended by way of suggestion only. No representation or warranty is given and no liability is assumed by Microchip Technology Incorporated with respect to the accuracy or use of such information. Use of Microchip’s products as critical components in life support systems is not authorized except with express written approval by Microchip.  2000 Microchip Technology Incorporated. All rights reserved. The Microchip logo, name, MPLAB, PIC, PICSTART, PRO MATE, and PICmicro are registered trademarks of Microchip Technology Incorporated in the U.S.A. and other countries. Microsoft, the Microsoft Internet Explorer, Windows, and MS-DOS are registered trademarks of Microsoft Corporation in the United States and/or other countries. Netscape is a registered trademark of Netscape Corporation in the United States and/or other countries. Microwire is a registered trademark of National Semiconductor Corporation. I2C is a trademark of Philips Corporation. SPI is a registered trademark of Motorola Corporation All product/company trademarks mentioned herein are the property of their respective companies. MPLAB®-CXX COMPILER USER’S GUIDE MPLAB®-CXX Compiler User’s Guide DS51217B  2000 Microchip Technology Inc.  2000 Microchip Technology Inc. DS51217B-page i MPLAB®-CXX COMPILER USER’S GUIDE Table of Contents General Information Introduction .......................................................................................... 1 Highlights ............................................................................................. 1 About This Guide ................................................................................. 1 Warranty Registration .......................................................................... 4 Recommended Reading ...................................................................... 4 Troubleshooting ................................................................................... 5 The Microchip Internet Web Site ......................................................... 6 Development Systems Customer Notification Service ........................ 7 Customer Support ............................................................................... 9 MPLAB®-CXX Compiler User’s Guide DS51217B-page ii  2000 Microchip Technology Inc. Part 1 – Getting Started with MPLAB-CXX Chapter 1. MPLAB-CXX Preview 1.1 Introduction .................................................................................13 1.2 Highlights ....................................................................................13 1.3 What MPLAB-CXX Is ..................................................................13 1.4 What MPLAB-CXX Does ............................................................14 1.5 ANSI Compatibility ......................................................................14 1.6 Tool Compatibility .......................................................................14 Chapter 2. MPLAB-CXX Installation 2.1 Introduction .................................................................................15 2.2 Highlights ....................................................................................15 2.3 Host Computer System Requirements .......................................15 2.4 Compiler Versions ......................................................................15 2.5 Installation ..................................................................................16 Chapter 3. MPLAB-CXX Overview 3.1 Introduction .................................................................................19 3.2 Highlights ....................................................................................19 3.3 Overview of Compilers ...............................................................19 3.4 Compiler Input/Output Files ........................................................21 3.5 Compiler Resource Requirements .............................................22 Chapter 4. Using MPLAB-CXX without MPLAB IDE 4.1 Introduction .................................................................................23 4.2 Highlights ....................................................................................23 4.3 MPLAB-CXX – Command Line Overview ..................................23 4.4 Using MPLAB-C17 on the Command Line .................................26 4.5 Using MPLAB-C18 on the Command Line .................................31 4.6 Going Forward ............................................................................36  2000 Microchip Technology Inc. DS51217B-page iii Table Of Contents Chapter 5. Using MPLAB-CXX with MPLAB IDE 5.1 Introduction ................................................................................ 37 5.2 Highlights ................................................................................... 37 5.3 MPLAB-CXX – MPLAB Projects Overview ................................ 37 5.4 Using MPLAB-C17 with MPLAB IDE – A Tutorial ...................... 40 5.5 Using MPLAB-C18 with MPLAB IDE – A Tutorial ...................... 54 5.6 Going Forward ........................................................................... 68 MPLAB®-CXX Compiler User’s Guide DS51217B-page iv  2000 Microchip Technology Inc. Part 2 – Using MPLAB-CXX Chapter 6. MPLAB-CXX and C 6.1 Introduction .................................................................................71 6.2 Highlights ....................................................................................71 6.3 C vs. MPLAB-CXX ......................................................................71 6.4 Components of a Basic MPLAB-CXX Program ..........................72 6.5 C Keywords ................................................................................73 Chapter 7. MPLAB-CXX Fundamentals 7.1 Introduction .................................................................................75 7.2 Highlights ....................................................................................75 7.3 Preprocessor Directives .............................................................76 7.4 Comments ..................................................................................85 7.5 Constants ...................................................................................86 7.6 Variables .....................................................................................88 7.7 Functions ....................................................................................96 7.8 Operators ....................................................................................99 7.9 Program Control Statements ....................................................106 7.10 Arrays and Strings ....................................................................112 7.11 Pointers ....................................................................................115 7.12 Structures and Unions ..............................................................118 Chapter 8. MPLAB-CXX and PICmicro MCU Programming 8.1 Introduction ...............................................................................123 8.2 Highlights ..................................................................................123 8.3 PICmicro MCU Programming Specifics ....................................123 8.4 MPLAB-C17 and PICmicro MCU Programming .......................126 8.5 MPLAB-C18 and PICmicro MCU Programming .......................135  2000 Microchip Technology Inc. DS51217B-page v Table Of Contents Chapter 9. Mixing Assembly Language and C Modules 9.1 Introduction .............................................................................. 139 9.2 Highlights ................................................................................. 139 9.3 Calling Conventions ................................................................. 139 9.4 Mixing Assembly Language and C Variables and Functions ... 140 9.5 Calling an Assembly Function in C – MPLAB-C17 .................. 141 9.6 Using the File Selection Registers (FSR’s) .............................. 142 Chapter 10. ANSI Implementation Issues 10.1 Introduction .............................................................................. 145 10.2 Highlights ................................................................................. 145 10.3 Identifiers .................................................................................. 145 10.4 Characters ................................................................................ 146 10.5 Integers .................................................................................... 146 10.6 Floating Point ........................................................................... 147 10.7 Arrays and Pointers .................................................................. 148 10.8 Registers .................................................................................. 148 10.9 Structures and Unions .............................................................. 148 10.10Bit-Fields ................................................................................. 149 10.11Enumerations .......................................................................... 149 10.12Switch Statement .................................................................... 149 10.13Preprocessing Directives ........................................................ 149 Chapter 11. Examples 11.1 Introduction .............................................................................. 151 11.2 Highlights ................................................................................. 151 11.3 Overview of Example Files ....................................................... 151 11.4 Example Details ....................................................................... 152 MPLAB®-CXX Compiler User’s Guide DS51217B-page vi  2000 Microchip Technology Inc. Appendices Appendix A. ASCII Character Set A.1 Introduction ...............................................................................155 A.2 ASCII Character Set .................................................................155 Appendix B. PIC17CXXX Instruction Set B.1 Introduction ...............................................................................157 B.2 Highlights ..................................................................................157 B.3 Key to PICmicro MCU Family Instruction Sets .........................157 B.4 PIC17CXXX Instruction Set ......................................................158 Appendix C. PIC18CXXX Instruction Set C.1 Introduction ...............................................................................163 C.2 Highlights ..................................................................................163 C.3 Key to Enhanced 16-Bit Core Instruction Set ...........................163 C.4 PIC18CXXX Instruction Set ......................................................164 Appendix D. MPLAB-C17 Errors D.1 Introduction ...............................................................................169 D.2 Highlights ..................................................................................169 D.3 Errors ........................................................................................169 D.4 Warnings ..................................................................................173 Appendix E. MPLAB-C18 Errors E.1 Introduction ...............................................................................175 E.2 Highlights ..................................................................................175 E.3 Errors ........................................................................................175 E.4 Warnings ..................................................................................182 Appendix F. References F.1 Introduction ...............................................................................185 F.2 Highlights ..................................................................................185 F.3 C Standards Information ...........................................................185 F.4 General C Information ..............................................................185  2000 Microchip Technology Inc. DS51217B-page vii Table Of Contents Glossary ..................................................................................................187 Introduction ...................................................................................... 187 Highlights ......................................................................................... 187 Terms .............................................................................................. 187 Index ........................................................................................................203 Worldwide Sales and Service................................................................210 MPLAB®-CXX Compiler User’s Guide DS51217B-page viii  2000 Microchip Technology Inc.  2000 Microchip Technology Inc. DS51217B-page 1 MPLAB®-CXX COMPILER USER’S GUIDE General Information General Information Introduction This first chapter contains general information that will be useful to know before using MPLAB-C17 or MPLAB-C18. Highlights The information you will garner from this chapter: • About this Guide • Recommended Reading • Warranty Registration • Troubleshooting • The Microchip Internet Web Site • Development Systems Customer Notification Service • Customer Support About This Guide Document Layout This document describes how to use MPLAB-CXX to write C code for PICmicro microcontroller applications. For a detailed discussion about basic MPLAB IDE functions, refer to the MPLAB IDE User’s Guide (DS51025). The User’s Guide layout is as follows: Part 1 - Getting Started with MPLAB-CXX • Chapter 1: MPLAB-CXX Preview – describes what MPLAB-C17 and MPLAB-C18 are and what they can do. • Chapter 2: MPLAB-CXX Installation – discusses compiler versions, PC requirements, and installation procedures. • Chapter 3: MPLAB-CXX Overview – gives an overview of compiler operation, input/output files, and resource requirements. • Chapter 4: Using MPLAB-CXX without MPLAB IDE – describes how to use MPLAB-C17 or MPLAB-C18 as stand-alone compilers. • Chapter 5: Using MPLAB-CXX with MPLAB IDE – describes how to use MPLAB-C17 or MPLAB-C18 with MPLAB IDE. MPLAB®-CXX Compiler User’s Guide DS51217B-page 2  2000 Microchip Technology Inc. Part 2 - Using MPLAB-CXX • Chapter 6: MPLAB-CXX and C – compares MPLAB-CXX and C. • Chapter 7: MPLAB-CXX Fundamentals – describes the MPLAB-CXX programming language including functions, statements, operators, vari- ables, and other elements. • Chapter 8: MPLAB-CXX and PICmicro® MCU Programming – describes how to use MPLAB-CXX in conjunction with device program- ming. • Chapter 9: Mixing C with Assembly Language Modules – provides guidelines to using C with MPASM assembly language modules. • Chapter 10: ANSI Implementation Issues – details MPLAB-CXX spe- cific parameters described as implementation defined in the ANSI stan- dard. • Chapter 11: Examples – discusses the MPLAB-C17 examples included in the examples directory. Appendices • Appendix A: ASCII Character Set – contains the ASCII character set. • Appendix B: PIC17CXXX Instruction Set – gives the instruction set for the PIC17CXXX device family. • Appendix C: PIC18CXXX Instruction Set – gives the instruction set for the PIC18CXXX device family. • Appendix D: MPLAB-C17 Errors – lists errors generated by MPLAB-C17. • Appendix E: MPLAB-C18 Errors – lists errors generated by MPLAB-C18. • Appendix F: References – gives references that may be helpful in pro- gramming with MPLAB-CXX. • Glossary – A glossary of terms used in this guide. • Index – Cross-reference listing of terms, features and sections of this document. • Worldwide Sales and Service – gives the address, telephone and fax number for Microchip Technology Inc. sales and service locations throughout the world.  2000 Microchip Technology Inc. DS51217B-page 3 General Information General Information Conventions Used in this Guide This manual uses the following documentation conventions: Updates All documentation becomes dated, and this user’s guide is no exception. Since MPLAB IDE, MPLAB-C17, MPLAB-C18 and other Microchip tools are constantly evolving to meet customer needs, some MPLAB IDE dialogs and/ or tool descriptions may differ from those in this document. Please refer to our web site to obtain the latest documentation available. Table: Documentation Conventions Description Represents Examples Code (Courier font): Plain characters Sample code Filenames and paths #define START c:\autoexec.bat Angle brackets: < > Variables <label>, <exp> Square brackets [ ] Optional arguments MPASMWIN [main.asm] Curly brackets and pipe character: { | } Choice of mutually exclusive arguments An OR selection errorlevel {0|1} Lower case charac- ters in quotes Type of data “filename” Ellipses... Used to imply (but not show) additional text that is not rele- vant to the example list [“list_option... , “list_option”] 0xnnn A hexadecimal number where n is a hexadecimal uploads/s3/ mplab-cxx-compiler-user-x27-s-guide-2000-microchip-technology-inc-ds51217b.pdf

  • 18
  • 0
  • 0
Afficher les détails des licences
Licence et utilisation
Gratuit pour un usage personnel Attribution requise
Partager