Click here to load reader
Mar 17, 2018
C Compiler
Reference Manual
July 2011
This manual documents software version 4. Review the readme.txt file in the product directory for changes made since this version. Copyright 1994, 2011 Custom Computer Services, Inc. All rights reserved worldwide. No part of this work may be reproduced or copied in any form or by any means- electronic, graphic, or mechanical, including photocopying, recording, taping, or information retrieval systems without prior permission.
v
Table of Contents Overview .......................................................................................................................................... 1
PCB, PCM and PCH Overview .................................................................................................... 1 Installation ................................................................................................................................... 1 Technical Support ....................................................................................................................... 2 Directories ................................................................................................................................... 2 File Formats ................................................................................................................................. 3 Invoking the Command Line Compiler ...................................................................................... 5 PCW Overview ............................................................................................................................. 7
Program Syntax ............................................................................................................................ 17 Overall Structure ....................................................................................................................... 17 Comment .................................................................................................................................... 17 Trigraph Sequences .................................................................................................................. 19 Multiple Project Files ................................................................................................................ 19 Multiple Compilation Units ....................................................................................................... 20 Example ..................................................................................................................................... 30
Statements .................................................................................................................................... 31 Statements ................................................................................................................................. 31 if .................................................................................................................................................. 32 while ........................................................................................................................................... 32 do ................................................................................................................................................ 33 do-while ...................................................................................................................................... 33 for ............................................................................................................................................... 33 switch ......................................................................................................................................... 34 return .......................................................................................................................................... 34 goto ............................................................................................................................................ 35 label ............................................................................................................................................ 35 break ........................................................................................................................................... 35 continue ..................................................................................................................................... 36 expr ............................................................................................................................................. 36 ; ................................................................................................................................................... 36 stmt ............................................................................................................................................. 36
Expressions .................................................................................................................................. 37 Expressions ............................................................................................................................... 37 Operators ................................................................................................................................... 38 operator precedence ................................................................................................................. 39 Reference Parameters .............................................................................................................. 40 Variable Argument Lists ........................................................................................................... 40 Default Parameters.................................................................................................................... 41 Overloaded Functions .............................................................................................................. 42
Data Definitions ............................................................................................................................ 43 Basic and Special types ........................................................................................................... 43 Declarations ............................................................................................................................... 46 Non-RAM Data Definitions ........................................................................................................ 47 Using Program Memory for Data ............................................................................................. 48 Function Definition .................................................................................................................... 50
CCS C Compiler Reference Manual June 2011
vi
Functional Overviews ................................................................................................................... 51 I2C............................................................................................................................................... 51 ADC ............................................................................................................................................ 52 Analog Comparator ................................................................................................................... 53 CAN Bus ..................................................................................................................................... 54 CCP1 ........................................................................................................................................... 56 CCP2, CCP3, CCP4, CCP5, CCP6............................................................................................. 57 Configuration Memory .............................................................................................................. 57 DAC ............................................................................................................................................ 58 Data Eeprom .............................................................................................................................. 59 External Memory ....................................................................................................................... 60 General Purpose I/O .................................................................................................................. 61 Internal LCD ............................................................................................................................... 62 Internal Oscillator ...................................................................................................................... 63 Interrupts ................................................................................................................................... 64 Linker ......................................................................................................................................... 65 Low Voltage Detect ................................................................................................................... 69 PMP ............................................................................................................................................ 70 Power PWM ................................................................................................................................ 71 Program Eeprom ....................................................................................................................... 72 PSP ......................................................