
Manual HI-TECH PICC-18 STD Compiler HI-TECH Software. Copyright (C) 2010 HI-TECH Software. All Rights Reserved. Printed in Australia. PICC-18 is licensed exclusively to HI-TECH Software by Microchip Technology Inc. Produced on: December 7, 2010 HI-TECH Software Pty. Ltd. ACN 002 724 549 45 Colebard Street West Acacia Ridge QLD 4110 Australia email: [email protected] web: http://www.htsoft.com ftp: ftp://www.htsoft.com Contents Table of Contents iii List of Tables xiii 1 Introduction 1 1.1 Typographic conventions ................................ 1 2 PICC-18 Command-line Driver 3 2.1 Long Command Lines ................................. 4 2.2 Default Libraries .................................... 4 2.3 Standard Runtime Code ................................. 4 2.4 PICC18 Compiler Options ............................... 5 2.4.1 -Bmodel: Select Memory Model ....................... 7 2.4.2 -C: Compile to Object File ........................... 7 2.4.3 -Dmacro: Define Macro ............................ 8 2.4.4 -Efile: Redirect Compiler Errors to a File .................. 8 2.4.5 -Gfile: Generate Source-level Symbol File ................. 9 2.4.6 -Ipath: Include Search Path ......................... 10 2.4.7 -Llibrary: Scan Library .......................... 10 2.4.8 -L-option: Adjust Linker Options Directly ................. 11 2.4.9 -Mfile: Generate Map File .......................... 11 2.4.10 -Nsize: Identifier Length ........................... 11 2.4.11 -Ofile: Specify Output File ......................... 11 2.4.12 -P: Preprocess Assembly Files ......................... 12 2.4.13 -Q: Quiet Mode ................................. 12 2.4.14 -S: Compile to Assembler Code ........................ 12 2.4.15 -Umacro: Undefine a Macro ......................... 12 2.4.16 -V: Verbose Compile .............................. 12 iii CONTENTS CONTENTS 2.4.17 -X: Strip Local Symbols ............................ 13 2.4.18 --ASMLIST: Generate Assembler .LST Files .................. 13 2.4.19 --CALLGRAPH=type: Control level of information displayed in call graph .. 13 2.4.20 --CHAR=type: Make Char Type Signed or Unsigned ............. 13 2.4.21 --CHECKSUM=start-end@address<,specs>: Calculate, store and ver- ify a checksum ................................. 13 2.4.22 --CHIP=processor: Define Processor ................... 14 2.4.23 --CHIPINFO: Display List of Supported Processors .............. 14 2.4.24 --CODEOFFSET: Offset Program Code to Address ............... 14 2.4.25 --CP=size: Set the Size of Pointers to Code Space ............. 14 2.4.26 --CR=file: Generate Cross Reference Listing ................ 15 2.4.27 --DEBUGGER=type: Select Debugger Type .................. 15 2.4.28 --DOUBLE=type: Select kind of Double Types ................ 15 2.4.29 --EMI=type: Select operating mode of the external memory interface (EMI) 16 2.4.30 --ERRATA=type: Specify to add or remove specific errata workarounds ... 16 2.4.31 --ERRFORMAT=format: Define Format for Compiler Messages ....... 18 2.4.31.1 Using the Format Options ...................... 18 2.4.31.2 Modifying the Standard Format ................... 19 2.4.32 --ERRORS=number: Maximum Number of Errors .............. 19 2.4.33 --FILL=opcode: Fill Unused Program Memory ............... 20 2.4.34 --GETOPTION=app,file: Get Command-line Options ........... 20 2.4.35 --HELP<=option>: Display Help ...................... 20 2.4.36 --IDE=type: Specify the IDE being used .................. 20 2.4.37 --LANG=language: Specify the Language for Messages .......... 21 2.4.38 --MEMMAP=file: Display Memory Map ................... 21 2.4.39 --MSGFORMAT=format: Set Advisory Message Format ........... 21 2.4.40 --NOEXEC: Don’t Execute Compiler ...................... 21 2.4.41 --OPT<=type>: Invoke Compiler Optimizations ............... 22 2.4.42 --OUTPUT=type: Specify Output File Type .................. 22 2.4.43 --PRE: Produce Preprocessed Source Code .................. 23 2.4.44 --PROTO: Generate Prototypes ......................... 23 2.4.45 --RAM=lo-hi,<lo-hi,...>: Specify Additional RAM Ranges ..... 24 2.4.46 --ROM=lo-hi,<lo-hi,...>|tag: Specify Additional ROM Ranges .. 25 2.4.47 --RUNTIME=type: Specify Runtime Environment .............. 25 2.4.48 --SCANDEP: Scan for Dependencies ...................... 25 2.4.49 --SERIAL=hexcode@address: Store a Value at this Program Memory Address ..................................... 27 2.4.50 --SETOPTION=app,file: Set The Command-line Options for Application 27 2.4.51 --STRICT: Strict ANSI Conformance ..................... 27 iv CONTENTS CONTENTS 2.4.52 --SUMMARY=type: Select Memory Summary Output Type .......... 27 2.4.53 --VER: Display The Compiler’s Version Information ............. 27 2.4.54 --WARN=level: Set Warning Level ...................... 28 2.4.55 --WARNFORMAT=format: Set Warning Message Format ........... 28 3 C Language Features 29 3.1 ANSI Standard Issues .................................. 29 3.1.1 Divergence from the ANSI C Standard .................... 29 3.1.2 Implementation-defined behaviour ....................... 29 3.2 Processor-related Features ............................... 29 3.2.1 Processor Support ............................... 30 3.2.2 Configuration Fuses .............................. 30 3.2.3 ID Locations .................................. 31 3.2.4 EEPROM and Flash Runtime Access ..................... 31 3.2.4.1 EEPROM Access .......................... 31 3.2.4.2 Flash Access ............................. 32 3.2.5 Peripheral Memory Ranges ........................... 32 3.2.6 Bit Instructions ................................. 33 3.2.7 Multi-byte SFRs ................................ 33 3.3 Files ........................................... 34 3.3.1 Source Files ................................... 34 3.3.2 Symbol Files .................................. 34 3.3.3 Output File Formats .............................. 35 3.3.4 Library files ................................... 35 3.3.4.1 Standard Libraries .......................... 35 3.3.4.2 Printf Libraries ............................ 36 3.3.4.3 Peripheral Libraries ......................... 36 3.3.4.4 Program Memory Libraries ..................... 37 3.3.5 Runtime startup Modules ............................ 38 3.3.5.1 Initialization of Data psects ..................... 39 3.3.5.2 Clearing the Bss Psects ....................... 39 3.3.5.3 Linking in the C Libraries ...................... 40 3.3.5.4 The powerup Routine ........................ 41 3.4 Supported Data Types and Variables .......................... 41 3.4.1 Radix Specifiers and Constants ......................... 42 3.4.2 Bit Data Types and Variables .......................... 43 3.4.3 Using Bit-Addressable Registers ........................ 44 3.4.4 8-Bit Integer Data Types and Variables .................... 44 3.4.5 16-Bit Integer Data Types ........................... 45 v CONTENTS CONTENTS 3.4.6 32-Bit Integer Data Types and Variables .................... 45 3.4.7 Floating Point Types and Variables ....................... 46 3.4.8 Structures and Unions ............................. 47 3.4.8.1 Bit-fields in Structures ........................ 47 3.4.8.2 Structure and Union Qualifiers ................... 48 3.4.9 Standard Type Qualifiers ............................ 49 3.4.9.1 Const and Volatile Type Qualifiers ................. 49 3.4.10 Special Type Qualifiers ............................. 49 3.4.10.1 Persistent Type Qualifier ...................... 50 3.4.10.2 Near Type Qualifier ......................... 50 3.4.10.3 Far Type Qualifier .......................... 51 3.4.11 Bdata Type Qualifier .............................. 51 3.4.12 Pointer Types .................................. 51 3.4.12.1 RAM Pointers ............................ 52 3.4.12.2 Const and Far Pointers ........................ 52 3.4.12.3 Function Pointers .......................... 53 3.4.12.4 Combining Type Qualifiers and Pointers .............. 53 3.5 Storage Class and Object Placement .......................... 54 3.5.1 Local Variables ................................. 54 3.5.1.1 Auto Variables ............................ 55 3.5.1.2 Static Variables ........................... 55 3.5.2 Absolute Variables ............................... 56 3.5.3 Objects in Program Space ........................... 56 3.6 Functions ........................................ 57 3.6.1 Function Argument Passing .......................... 57 3.6.2 Function Return Values ............................. 58 3.6.2.1 8-Bit Return Values ......................... 58 3.6.2.2 16-Bit and 32-bit Return Values ................... 58 3.6.2.3 Structure Return Values ....................... 58 3.6.3 Memory Models and Usage .......................... 59 3.7 Register Usage ..................................... 60 3.8 Operators ........................................ 60 3.8.1 Integral Promotion ............................... 60 3.8.2 Shifts applied to integral types ......................... 62 3.8.3 Division and modulus with integral types ................... 62 3.9 Psects .......................................... 62 3.9.1 Compiler-generated Psects ........................... 63 3.10 Interrupt Handling in C ................................. 65 3.10.1 Interrupt Functions ............................... 65 vi CONTENTS CONTENTS 3.10.2 Context Saving on Interrupts .......................... 66 3.10.3 Context Retrieval ................................ 67 3.10.4 Interrupt Levels ................................. 67 3.10.5 Interrupt Registers ............................... 68 3.11 Mixing C and Assembler Code ............................
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages450 Page
-
File Size-