© 2005 Microchip Technology Inc. DS51284E MPLAB® C30 C COMPILER USER’S GUIDE DS

© 2005 Microchip Technology Inc. DS51284E MPLAB® C30 C COMPILER USER’S GUIDE DS51284E-page ii © 2005 Microchip Technology Inc. Information contained in this publication regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WAR- RANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip’s products as critical components in life support systems is not authorized except with express written approval by Microchip. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights. Trademarks The Microchip name and logo, the Microchip logo, Accuron, dsPIC, KEELOQ, microID, MPLAB, PIC, PICmicro, PICSTART, PRO MATE, PowerSmart, rfPIC, and SmartShunt are registered trademarks of Microchip Technology Incorporated in the U.S.A. and other countries. AmpLab, FilterLab, Migratable Memory, MXDEV, MXLAB, PICMASTER, SEEVAL, SmartSensor and The Embedded Control Solutions Company are registered trademarks of Microchip Technology Incorporated in the U.S.A. Analog-for-the-Digital Age, Application Maestro, dsPICDEM, dsPICDEM.net, dsPICworks, ECAN, ECONOMONITOR, FanSense, FlexROM, fuzzyLAB, In-Circuit Serial Programming, ICSP, ICEPIC, Linear Active Thermistor, MPASM, MPLIB, MPLINK, MPSIM, PICkit, PICDEM, PICDEM.net, PICLAB, PICtail, PowerCal, PowerInfo, PowerMate, PowerTool, Real ICE, rfLAB, rfPICDEM, 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. © 2005, Microchip Technology Incorporated, Printed in the U.S.A., All Rights Reserved. Printed on recycled paper. Note the following details of the code protection feature on Microchip devices: • Microchip products meet the specification contained in their particular Microchip Data Sheet. • Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the intended manner and under normal conditions. • There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchip’s Data Sheets. Most likely, the person doing so is engaged in theft of intellectual property. • Microchip is willing to work with the customer who is concerned about the integrity of their code. • Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not mean that we are guaranteeing the product as “unbreakable.” Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our products. Attempts to break Microchip’s code protection feature may be a violation of the Digital Millennium Copyright Act. If such acts allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act. Microchip received ISO/TS-16949:2002 quality system certification for its worldwide headquarters, design and wafer fabrication facilities in Chandler and Tempe, Arizona and Mountain View, California in October 2003. The Company’s quality system processes and procedures are for its PICmicro® 8-bit MCUs, KEELOQ® code hopping devices, Serial EEPROMs, microperipherals, nonvolatile memory and analog products. In addition, Microchip’s quality system for the design and manufacture of development systems is ISO 9001:2000 certified. MPLAB® C30 USER’S GUIDE © 2005 Microchip Technology Inc. DS51284D5-page iii Table of Contents Preface ........................................................................................................................... 1 Chapter 1. Compiler Overview 1.1 Introduction ..................................................................................................... 7 1.2 Highlights ........................................................................................................ 7 1.3 MPLAB C30 Description ................................................................................. 7 1.4 MPLAB C30 and Other Development Tools ................................................... 7 1.5 MPLAB C30 Feature Set ................................................................................ 9 Chapter 2. Differences Between MPLAB C30 and ANSI C 2.1 Introduction ................................................................................................... 11 2.2 Highlights ...................................................................................................... 11 2.3 Keyword Differences .................................................................................... 11 2.4 Statement Differences .................................................................................. 27 2.5 Expression Differences ................................................................................ 28 Chapter 3. Using MPLAB C30 C Compiler 3.1 Introduction ................................................................................................... 29 3.2 Highlights ...................................................................................................... 29 3.3 Overview ...................................................................................................... 29 3.4 File Naming Conventions ............................................................................. 30 3.5 Options ......................................................................................................... 30 3.6 Environment Variables ................................................................................. 55 3.7 Predefined Constants ................................................................................... 56 3.8 Compiling a Single File on the Command Line ............................................ 57 3.9 Compiling Multiple Files on the Command Line ........................................... 58 Chapter 4. MPLAB C30 C Compiler Runtime Environment 4.1 Introduction ................................................................................................... 59 4.2 Highlights ...................................................................................................... 59 4.3 Address Spaces ........................................................................................... 59 4.4 Code and Data Sections .............................................................................. 61 4.5 Startup and Initialization ............................................................................... 63 4.6 Memory Spaces ........................................................................................... 64 4.7 Memory Models ............................................................................................ 65 4.8 Locating Code and Data ............................................................................... 67 4.9 Software Stack ............................................................................................. 68 4.10 The C Stack Usage .................................................................................... 69 4.11 The C Heap Usage ..................................................................................... 71 MPLAB® C30 User’s Guide DS51284D5-page iv © 2005 Microchip Technology Inc. 4.12 Function Call Conventions ......................................................................... 72 4.13 Register Conventions ................................................................................. 74 4.14 Bit Reversed and Modulo Addressing ........................................................ 75 4.15 Program Space Visibility (PSV) Usage ...................................................... 75 Chapter 5. Data Types 5.1 Introduction ................................................................................................... 77 5.2 Highlights ...................................................................................................... 77 5.3 Data Representation .................................................................................... 77 5.4 Integer .......................................................................................................... 77 5.5 Floating Point ............................................................................................... 78 5.6 Pointers ........................................................................................................ 78 Chapter 6. Device Support Files 6.1 Introduction ................................................................................................... 79 6.2 Highlights ...................................................................................................... 79 6.3 Processor Header Files ................................................................................ 79 6.4 Register Definition Files ............................................................................... 80 6.5 Using SFRs .................................................................................................. 81 6.6 Using Macros ............................................................................................... 83 6.7 Accessing EEDATA from C Code - dsPIC30F DSCs only ........................... 84 Chapter 7. Interrupts 7.1 Introduction ................................................................................................... 87 7.2 Highlights ...................................................................................................... 87 7.3 Writing an Interrupt Service Routine ............................................................ 88 7.4 Writing the Interrupt Vector .......................................................................... 90 7.5 Interrupt Service Routine Context Saving .................................................. 100 7.6 Latency ....................................................................................................... 100 7.7 Nesting Interrupts ....................................................................................... 100 7.8 Enabling/Disabling Interrupts ..................................................................... 101 7.9 Sharing Memory Between Interrupt Service Routines and Mainline Code ....................................................................................... 102 Chapter 8. Mixing Assembly Language and C Modules 8.1 Introduction ................................................................................................. 107 8.2 Highlights .................................................................................................... 107 8.3 Mixing Assembly Language and C Variables and Functions ..................... 107 8.4 Using Inline Assembly Language ............................................................... 109 Appendix A. Implementation-Defined Behavior A.1 Introduction ................................................................................................ 115 A.2 Translation ................................................................................................. 116 A.3 Environment ............................................................................................... 116 A.4 Identifiers ................................................................................................... 117 A.5 Characters ................................................................................................. 117 A.6 Integers ...................................................................................................... 118 A.7 Floating Point ............................................................................................. 118 Table of Contents © 2005 Microchip Technology Inc. DS51284D5-page v A.8 Arrays and Pointers ................................................................................... 119 A.9 Registers .................................................................................................... 119 A.10 Structures, Unions, Enumerations and Bit fields ...................................... 120 A.11 Qualifiers .................................................................................................. 120 A.12 Declarators ............................................................................................... 120 A.13 Statements ............................................................................................... 120 A.14 Preprocessing Directives ......................................................................... 121 A.15 Library Functions ..................................................................................... 122 A.16 Signals ..................................................................................................... 123 A.17 Streams and Files .................................................................................... 123 A.18 tmpfile ...................................................................................................... 124 A.19 errno ......................................................................................................... 124 A.20 Memory .................................................................................................... 124 A.21 abort ......................................................................................................... 124 A.22 exit ........................................................................................................... 124 A.23 getenv ...................................................................................................... 125 A.24 system ...................................................................................................... 125 A.25 strerror ..................................................................................................... 125 Appendix B. MPLAB C30 C Compiler Diagnostics B.1 Introduction ................................................................................................ 127 B.2 Errors ......................................................................................................... 127 B.3 Warnings .................................................................................................... 146 Appendix C. MPLAB C18 vs. MPLAB C30 C Compiler C.1 Introduction ................................................................................................ 167 C.2 Data Formats ............................................................................................. 168 C.3 Pointers ...................................................................................................... 168 C.4 Storage Classes ........................................................................................ 168 C.5 Stack Usage .............................................................................................. 168 C.6 Storage Qualifiers ...................................................................................... 169 C.7 Predefined Macro Names .......................................................................... 169 C.8 Integer Promotions .................................................................................... 169 C.9 String Constants ........................................................................................ 169 C.10 Anonymous Structures ............................................................................ 170 C.11 Access Memory ....................................................................................... 170 C.12 Inline Assembly ........................................................................................ 170 C.13 Pragmas .................................................................................................. 170 C.14 Memory Models ....................................................................................... 171 C.15 Calling Conventions ................................................................................. 172 C.16 Startup Code ............................................................................................ 172 C.17 Compiler-Managed Resources ................................................................ 172 C.18 Optimizations ........................................................................................... 172 C.19 Object Module Format ............................................................................. 172 C.20 Implementation-Defined Behavior ........................................................... 172 C.21 Bit fields ................................................................................................... 173 MPLAB® C30 User’s Guide DS51284D5-page vi © 2005 Microchip Technology Inc. Appendix D. Deprecated Features D.1 Introduction ................................................................................................ 175 D.2 Highlights ................................................................................................... 175 D.3 Predefined Constants ................................................................................ 175 Appendix E. ASCII Character Set .............................................................................177 Appendix F. GNU Free Documentation License .....................................................179 Glossary .....................................................................................................................185 Index ...........................................................................................................................193 Worldwide Sales and Service ...................................................................................202 MPLAB® C30 USER’S GUIDE © 2005 Microchip Technology Inc. DS51284E-page 1 Preface INTRODUCTION The purpose of this document is to help you use Microchip’s MPLAB C30 C compiler for dsPIC® Digital Signal Controllers (DSC) devices to develop your application. MPLAB C30 is a GCC-based (GNU Compiler Collection) language tool, based on source code from the Free Software Foundation (FSF). For more information about the FSF, see www.fsf.org. Other GNU language tools available from Microchip are: • MPLAB ASM30 Assembler • MPLAB LINK30 Linker • MPLAB LIB30 Librarian/Archiver Items discussed in this chapter include: • About This Guide • Recommended Reading • Troubleshooting • The Microchip Web Site • Development Systems Customer Change Notification Service • Customer Support NOTICE TO CUSTOMERS All documentation becomes dated, and this manual is no exception. Microchip tools and documentation are constantly evolving to meet customer needs, so some actual dialogs and/or tool descriptions may differ from those in this document. Please refer to our web site (www.microchip.com) to obtain the latest documentation available. Documents are identified with a “DS” number. This number is located on the bottom of each page, in front uploads/S4/ c30-users-guide.pdf

  • 24
  • 0
  • 0
Afficher les détails des licences
Licence et utilisation
Gratuit pour un usage personnel Attribution requise
Partager
  • Détails
  • Publié le Fev 19, 2021
  • Catégorie Law / Droit
  • Langue French
  • Taille du fichier 2.1302MB