ccs c manual

381
i CCS C Compiler Manual PCB / PCM / PCH May 2015 ALL RIGHTS RESERVED. Copyright Custom Computer Services, Inc. 2015

Upload: cinthia-anahatha

Post on 11-Sep-2015

8 views

Category:

Documents


0 download

DESCRIPTION

manual de Ccs

TRANSCRIPT

  • i

    CCS C Compiler Manual

    PCB / PCM / PCH

    May 2015

    ALL RIGHTS RESERVED.

    Copyright Custom Computer Services, Inc. 2015

  • CCSC Manual

    ii

    Table of Contents Overview ........................................................................................................................................................................ 1

    C Compiler.................................................................................................................................................................. 1 PCB, PCM and PCH Overview ................................................................................................................................... 1 Installation .................................................................................................................................................................. 1 Technical Support ....................................................................................................................................................... 2 Directories .................................................................................................................................................................. 2 File Formats................................................................................................................................................................ 3 Invoking the Command Line Compiler ........................................................................................................................ 3 PCW Overview ........................................................................................................................................................... 5 Menu .......................................................................................................................................................................... 6 Editor Tabs ................................................................................................................................................................. 7 Slide Out Windows ..................................................................................................................................................... 7 Editor .......................................................................................................................................................................... 8 Debugging Windows ................................................................................................................................................... 8 Status Bar ................................................................................................................................................................... 9 Output Messages ....................................................................................................................................................... 9

    Program Syntax ........................................................................................................................................................... 11 Overall Structure ....................................................................................................................................................... 11 Comment .................................................................................................................................................................. 11 Trigraph Sequences ................................................................................................................................................. 12 Multiple Project Files ................................................................................................................................................ 12 Multiple Compilation Units ........................................................................................................................................ 13 Full Example Program .............................................................................................................................................. 13

    Statements ................................................................................................................................................................... 15 Statements ............................................................................................................................................................... 15 if ................................................................................................................................................................................ 15 while ......................................................................................................................................................................... 16 do-while .................................................................................................................................................................... 16 for ............................................................................................................................................................................. 17 switch ....................................................................................................................................................................... 17 return ........................................................................................................................................................................ 18 goto .......................................................................................................................................................................... 18 label .......................................................................................................................................................................... 18 break ........................................................................................................................................................................ 18 continue .................................................................................................................................................................... 19 expr .......................................................................................................................................................................... 19 ; ................................................................................................................................................................................ 19 stmt ........................................................................................................................................................................... 20

    Expressions ................................................................................................................................................................. 21 Constants ................................................................................................................................................................. 21 Identifiers .................................................................................................................................................................. 22 Operators.................................................................................................................................................................. 22 Operator Precedence ............................................................................................................................................... 23

    Data Definitions ............................................................................................................................................................ 25 Data Definitions ........................................................................................................................................................ 25 Type Specifiers ......................................................................................................................................................... 25 Type Qualifiers ......................................................................................................................................................... 26 Enumerated Types ................................................................................................................................................... 27 Structures and Unions .............................................................................................................................................. 27 typedef ...................................................................................................................................................................... 28 Non-RAM Data Definitions ....................................................................................................................................... 29 Using Program Memory for Data .............................................................................................................................. 30 Named Registers ...................................................................................................................................................... 31

    Function Definition ....................................................................................................................................................... 33 Function Definition .................................................................................................................................................... 33 Overloaded Functions .............................................................................................................................................. 33 Reference Parameters ............................................................................................................................................. 34 Default Parameters ................................................................................................................................................... 34 Variable Argument Lists ........................................................................................................................................... 35

  • Table of Contents

    iii

    Functional Overview ..................................................................................................................................................... 37 I2C ............................................................................................................................................................................ 37 ADC .......................................................................................................................................................................... 37 Analog Comparator .................................................................................................................................................. 39 CAN Bus ................................................................................................................................................................... 39 CCP .......................................................................................................................................................................... 41 Code Profile .............................................................................................................................................................. 42 Configuration Memory .............................................................................................................................................. 43 DAC .......................................................................................................................................................................... 43 Data Eeprom ............................................................................................................................................................ 44 Data Signal Modulator .............................................................................................................................................. 45 External Memory ...................................................................................................................................................... 45 General Purpose I/O ................................................................................................................................................. 46 Internal LCD ............................................................................................................................................................. 47 Internal Oscillator ...................................................................................................................................................... 47 Interrupts .................................................................................................................................................................. 48 Low Voltage Detect .................................................................................................................................................. 49 PMP/EPMP............................................................................................................................................................... 49 Power PWM.............................................................................................................................................................. 50 Program Eeprom ...................................................................................................................................................... 51 PSP .......................................................................................................................................................................... 52 QEI ........................................................................................................................................................................... 53 RS232 I/O ................................................................................................................................................................. 54 RTOS ....................................................................................................................................................................... 56 SPI ............................................................................................................................................................................ 57 Timer0 ...................................................................................................................................................................... 58 Timer1 ...................................................................................................................................................................... 59 Timer2 ...................................................................................................................................................................... 59 Timer3 ...................................................................................................................................................................... 60 Timer4 ...................................................................................................................................................................... 60 Timer5 ...................................................................................................................................................................... 60 TimerA ...................................................................................................................................................................... 61 TimerB ...................................................................................................................................................................... 61 USB .......................................................................................................................................................................... 62 Voltage Reference .................................................................................................................................................... 64 WDT or Watch Dog Timer ........................................................................................................................................ 65 interrupt_enabled() ................................................................................................................................................... 66 Stream I/O ................................................................................................................................................................ 66

    PreProcessor ............................................................................................................................................................... 69 PRE-PROCESSOR DIRECTORY ............................................................................................................................ 69 __address__ ............................................................................................................................................................. 71 _attribute_x ............................................................................................................................................................... 71 #asm #endasm #asm asis ........................................................................................................................................ 72 #bit ............................................................................................................................................................................ 73 __buildcount__ ......................................................................................................................................................... 74 #build ........................................................................................................................................................................ 74 #byte ......................................................................................................................................................................... 75 #case ........................................................................................................................................................................ 75 _date_ ...................................................................................................................................................................... 76 #define ...................................................................................................................................................................... 76 definedinc ................................................................................................................................................................. 77 #device ..................................................................................................................................................................... 78 _device_ ................................................................................................................................................................... 79 #if expr #else #elif #endif .......................................................................................................................................... 80 #error ........................................................................................................................................................................ 81 #export (options) ....................................................................................................................................................... 81 __file__ ..................................................................................................................................................................... 83 __filename__ ............................................................................................................................................................ 83 #fill_rom .................................................................................................................................................................... 83 #fuses ....................................................................................................................................................................... 84 #hexcomment ........................................................................................................................................................... 84 #id ............................................................................................................................................................................. 85

  • CCSC Manual

    iv

    #if expr #else #elif #endif .......................................................................................................................................... 85 #ifdef #ifndef #else #elif #endif ................................................................................................................................. 86 #ignore_warnings ..................................................................................................................................................... 87 #import (options) ....................................................................................................................................................... 87 #include .................................................................................................................................................................... 88 #inline ....................................................................................................................................................................... 88 #int_xxxx .................................................................................................................................................................. 89 #INT_DEFAULT ....................................................................................................................................................... 92 #int_global ................................................................................................................................................................ 92 __line__ .................................................................................................................................................................... 92 #list ........................................................................................................................................................................... 93 #line .......................................................................................................................................................................... 93 #locate ...................................................................................................................................................................... 94 #module .................................................................................................................................................................... 94 #nolist ....................................................................................................................................................................... 95 #ocs .......................................................................................................................................................................... 95 #opt .......................................................................................................................................................................... 96 #org .......................................................................................................................................................................... 96 #pin_select ............................................................................................................................................................... 97 __pcb__ .................................................................................................................................................................... 99 __pcm__ ................................................................................................................................................................... 99 __pch__ .................................................................................................................................................................... 99 #pragma ................................................................................................................................................................. 100 #priority ................................................................................................................................................................... 100 #profile .................................................................................................................................................................... 100 #reserve ................................................................................................................................................................. 101 #rom ....................................................................................................................................................................... 102 #separate ............................................................................................................................................................... 102 #serialize ................................................................................................................................................................ 103 #task ....................................................................................................................................................................... 104 __time__ ................................................................................................................................................................. 105 #type ....................................................................................................................................................................... 105 #undef .................................................................................................................................................................... 106 _unicode ................................................................................................................................................................. 106 #use capture ........................................................................................................................................................... 107 #use delay .............................................................................................................................................................. 108 #use dynamic_memory .......................................................................................................................................... 109 #use fast_io ............................................................................................................................................................ 109 #use fixed_io .......................................................................................................................................................... 110 #use i2c .................................................................................................................................................................. 110 #use profile()........................................................................................................................................................... 111 #use pwm ............................................................................................................................................................... 112 #use rs232 .............................................................................................................................................................. 113 #use rtos ................................................................................................................................................................. 116 #use spi .................................................................................................................................................................. 117 #use standard_io .................................................................................................................................................... 118 #use timer ............................................................................................................................................................... 119 #use touchpad ........................................................................................................................................................ 120 #warning ................................................................................................................................................................. 121 #word ...................................................................................................................................................................... 121 #zero_ram .............................................................................................................................................................. 122

    Built-in Functions ........................................................................................................................................................ 123 BUILT-IN FUNCTIONS ........................................................................................................................................... 123 abs( ) ...................................................................................................................................................................... 129 sin( ) cos( ) tan( ) asin( ) acos() atan() sinh() cosh() tanh() atan2() ......................................................................... 129 adc_done( ) ............................................................................................................................................................ 130 assert( ) .................................................................................................................................................................. 131 atoe ........................................................................................................................................................................ 131 atof( ) ...................................................................................................................................................................... 132 pin_select() ............................................................................................................................................................. 132 atoi( ) atol( ) atoi32( ) .............................................................................................................................................. 133 at_clear_interrupts( ) .............................................................................................................................................. 134

  • Table of Contents

    v

    at_disable_interrupts( ) ........................................................................................................................................... 134 at_enable_interrupts( ) ........................................................................................................................................... 135 at_get_capture( ) .................................................................................................................................................... 136 at_get_missing_pulse_delay( ) ............................................................................................................................... 136 at_get_period( ) ...................................................................................................................................................... 137 at_get_phase_counter( ) ........................................................................................................................................ 137 at_get_resolution( ) ................................................................................................................................................. 138 at_get_set_point( ) .................................................................................................................................................. 138 at_get_set_point_error( ) ........................................................................................................................................ 139 at_get_status( ) ....................................................................................................................................................... 139 at_interrupt_active( ) ............................................................................................................................................... 140 at_set_compare_time( ) .......................................................................................................................................... 141 at_set_missing_pulse_delay( ) ............................................................................................................................... 141 at_set_resolution( ) ................................................................................................................................................. 142 at_set_set_point( ) .................................................................................................................................................. 142 at_setup_cc( ) ......................................................................................................................................................... 143 bit_clear( )............................................................................................................................................................... 143 bit_set( ) ................................................................................................................................................................. 144 bit_test( ) ................................................................................................................................................................ 144 brownout_enable( ) ................................................................................................................................................. 145 bsearch( ) ............................................................................................................................................................... 145 calloc( ) ................................................................................................................................................................... 146 ceil( ) ....................................................................................................................................................................... 146 clc1_setup_gate() clc2_setup_gate() clc3_setup_gate() clc4_setup_gate() ........................................................... 147 clc1_setup_input() clc2_setup_input() clc3_setup_input() clc4_setup_input() ........................................................ 148 clear_interrupt( ) ..................................................................................................................................................... 148 cog_status( ) ........................................................................................................................................................... 149 cog_restart( ) .......................................................................................................................................................... 149 crc_calc( ) ............................................................................................................................................................... 150 crc_calc8( ) ............................................................................................................................................................. 150 crc_calc16( ) ........................................................................................................................................................... 150 ) .............................................................................................................................................................................. 150 crc_init(mode) ......................................................................................................................................................... 151 cwg_status( ) .......................................................................................................................................................... 151 cwg_restart( ) .......................................................................................................................................................... 151 dac_write( ) ............................................................................................................................................................. 152 delay_cycles( ) ........................................................................................................................................................ 152 delay_ms( ) ............................................................................................................................................................. 153 delay_us( ) .............................................................................................................................................................. 153 disable_interrupts( ) ................................................................................................................................................ 154 div( ) ldiv( ) .............................................................................................................................................................. 155 enable_interrupts( ) ................................................................................................................................................ 155 erase_eeprom( ) ..................................................................................................................................................... 156 erase_program_eeprom( ) ...................................................................................................................................... 156 exp( ) ...................................................................................................................................................................... 157 ext_int_edge( ) ........................................................................................................................................................ 158 fabs( ) ..................................................................................................................................................................... 158 getc( ) getch( ) getchar( ) fgetc( ) ............................................................................................................................ 159 gets( ) fgets( ) ......................................................................................................................................................... 159 floor( ) ..................................................................................................................................................................... 160 fmod( ) .................................................................................................................................................................... 160 printf( ) fprintf( ) ....................................................................................................................................................... 161 putc( ) putchar( ) fputc( ) ......................................................................................................................................... 162 puts( ) fputs( ) ......................................................................................................................................................... 163 free( ) ...................................................................................................................................................................... 163 frexp( ) .................................................................................................................................................................... 164 scanf( ) ................................................................................................................................................................... 164 get_capture( ) ......................................................................................................................................................... 166 get_capture_event() ............................................................................................................................................... 167 get_capture_time() ................................................................................................................................................. 167 get_capture32() ...................................................................................................................................................... 168 get_hspwm_capture( ) ............................................................................................................................................ 168

  • CCSC Manual

    vi

    get_nco_accumulator( ) .......................................................................................................................................... 169 get_nco_inc_value( ) .............................................................................................................................................. 169 get_ticks( ) .............................................................................................................................................................. 170 get_timerA( ) ........................................................................................................................................................... 170 get_timerB( ) ........................................................................................................................................................... 170 get_timerx( ) ........................................................................................................................................................... 171 get_tris_x( )............................................................................................................................................................. 172 getenv( ) ................................................................................................................................................................. 172 gets( ) fgets( ) ......................................................................................................................................................... 176 goto_address( ) ...................................................................................................................................................... 176 high_speed_adc_done( ) ........................................................................................................................................ 177 i2c_init( ) ................................................................................................................................................................. 177 i2c_isr_state( ) ........................................................................................................................................................ 178 i2c_poll( ) ................................................................................................................................................................ 179 i2c_read( ) .............................................................................................................................................................. 179 i2c_slaveaddr( ) ...................................................................................................................................................... 180 i2c_speed( ) ............................................................................................................................................................ 180 i2c_start( )............................................................................................................................................................... 181 i2c_stop( ) ............................................................................................................................................................... 181 i2c_write( ) .............................................................................................................................................................. 182 input( ) .................................................................................................................................................................... 183 input_change_x( ) ................................................................................................................................................... 183 input_state( )........................................................................................................................................................... 184 input_x( ) ................................................................................................................................................................ 185 interrupt_active( ) .................................................................................................................................................... 185 isalnum(char) isalpha(char) .................................................................................................................................... 186 iscntrl(x) isdigit(char) .............................................................................................................................................. 186 isgraph(x) islower(char) isspace(char) isupper(char) isxdigit(char) isprint(x) ispunct(x) ......................................... 186 isamong( )............................................................................................................................................................... 187 itoa( ) ...................................................................................................................................................................... 187 jump_to_isr( ) .......................................................................................................................................................... 188 kbhit( ) .................................................................................................................................................................... 188 label_address( ) ...................................................................................................................................................... 189 labs( ) ..................................................................................................................................................................... 189 lcd_contrast( ) ......................................................................................................................................................... 190 lcd_load( ) ............................................................................................................................................................... 190 lcd_symbol( ) .......................................................................................................................................................... 191 ldexp( ) ................................................................................................................................................................... 191 log( ) ....................................................................................................................................................................... 192 log10( ) ................................................................................................................................................................... 192 longjmp( )................................................................................................................................................................ 193 make8( ) ................................................................................................................................................................. 193 make16( ) ............................................................................................................................................................... 194 make32( ) ............................................................................................................................................................... 194 malloc( ) .................................................................................................................................................................. 195 memcpy( ) memmove( ) ......................................................................................................................................... 195 memset( ) ............................................................................................................................................................... 196 modf( ) .................................................................................................................................................................... 196 _mul( ) .................................................................................................................................................................... 197 nargs( ) ................................................................................................................................................................... 197 offsetof( ) offsetofbit( ) ............................................................................................................................................ 198 output_x( ) .............................................................................................................................................................. 199 output_bit( ) ............................................................................................................................................................ 199 output_drive( ) ........................................................................................................................................................ 200 output_float( ) ......................................................................................................................................................... 201 output_high( ) ......................................................................................................................................................... 201 output_low( ) ........................................................................................................................................................... 202 output_toggle( ) ...................................................................................................................................................... 202 perror( ) .................................................................................................................................................................. 203 pid_busy( ) .............................................................................................................................................................. 203 pid_get_result( ) ...................................................................................................................................................... 204 pid_read( ) .............................................................................................................................................................. 204

  • Table of Contents

    vii

    pid_write( ) .............................................................................................................................................................. 205 port_x_pullups ( ) .................................................................................................................................................... 206 pow( ) pwr( ) ........................................................................................................................................................... 207 printf( ) fprintf( ) ....................................................................................................................................................... 207 profileout() .............................................................................................................................................................. 208 psp_output_full( ) psp_input_full( ) psp_overflow( ) ................................................................................................ 209 putc( ) putchar( ) fputc( ) ......................................................................................................................................... 210 putc_send( );........................................................................................................................................................... 211 fputc_send( );.......................................................................................................................................................... 211 puts( ) fputs( ) ......................................................................................................................................................... 211 pwm_off()................................................................................................................................................................ 212 pwm_on()................................................................................................................................................................ 212 pwm_set_duty() ...................................................................................................................................................... 213 pwm_set_duty_percent .......................................................................................................................................... 213 pwm_set_frequency ............................................................................................................................................... 214 qei_get_count( ) ...................................................................................................................................................... 215 qei_set_count( ) ...................................................................................................................................................... 215 qei_status( ) ............................................................................................................................................................ 215 qsort( ) .................................................................................................................................................................... 216 rand( ) ..................................................................................................................................................................... 217 rcv_buffer_bytes( ) .................................................................................................................................................. 217 rcv_buffer_full( ) ...................................................................................................................................................... 218 read_adc( ) ............................................................................................................................................................. 218 read_bank( ) ........................................................................................................................................................... 219 read_calibration( ) ................................................................................................................................................... 219 read_configuration_memory( )................................................................................................................................ 220 read_eeprom( ) ....................................................................................................................................................... 220 read_extended_ram( ) ............................................................................................................................................ 221 read_program_memory( ) ....................................................................................................................................... 221 read_external_memory( ) ....................................................................................................................................... 221 read_high_speed_adc( ) ......................................................................................................................................... 222 read_program_eeprom( ) ....................................................................................................................................... 223 read_rom_memory( ) .............................................................................................................................................. 224 read_sd_adc( ) ....................................................................................................................................................... 224 realloc( ) ................................................................................................................................................................. 224 release_io()............................................................................................................................................................. 225 reset_cpu( ) ............................................................................................................................................................ 225 restart_cause( ) ...................................................................................................................................................... 226 restart_wdt( ) .......................................................................................................................................................... 226 rotate_left( ) ............................................................................................................................................................ 227 rotate_right( ) .......................................................................................................................................................... 228 rtc_alarm_read( ) .................................................................................................................................................... 228 rtc_alarm_write( ) .................................................................................................................................................... 229 rtc_read( ) ............................................................................................................................................................... 229 rtc_write( )............................................................................................................................................................... 230 rtos_await( ) ............................................................................................................................................................ 230 rtos_disable( ) ......................................................................................................................................................... 231 rtos_enable( ) ......................................................................................................................................................... 231 rtos_msg_poll( ) ...................................................................................................................................................... 231 rtos_msg_read( ) .................................................................................................................................................... 232 rtos_msg_send( ) .................................................................................................................................................... 232 rtos_overrun( ) ........................................................................................................................................................ 233 rtos_run( ) ............................................................................................................................................................... 233 rtos_signal( ) ........................................................................................................................................................... 234 rtos_stats( )............................................................................................................................................................. 234 rtos_terminate( ) ..................................................................................................................................................... 235 rtos_wait( ) .............................................................................................................................................................. 235 rtos_yield( ) ............................................................................................................................................................. 236 set_adc_channel( ) ................................................................................................................................................. 236 set_analog_pins( ) .................................................................................................................................................. 237 scanf( ) ................................................................................................................................................................... 237 set_cog_blanking( ) ................................................................................................................................................ 239

  • CCSC Manual

    viii

    set_cog_dead_band( ) ............................................................................................................................................ 240 set_cog_phase( ) .................................................................................................................................................... 240 set_compare_time( ) ............................................................................................................................................... 241 set_hspwm_duty( ) ................................................................................................................................................. 241 set_hspwm_event( ) ............................................................................................................................................... 242 set_hspwm_override( ) ........................................................................................................................................... 243 set_hspwm_phase( ) .............................................................................................................................................. 243 set_nco_inc_value( ) .............................................................................................................................................. 244 set_power_pwm_override( ) ................................................................................................................................... 245 set_power_pwmx_duty( ) ....................................................................................................................................... 245 set_pullup( ) ............................................................................................................................................................ 246 set_pwm1_duty( ) set_pwm2_duty( ) set_pwm3_duty( ) set_pwm4_duty( ) set_pwm5_duty( ) ............................. 246 set_rtcc( ) set_timer0( ) set_timer1( ) set_timer2( ) set_timer3( ) set_timer4( ) set_timer5( ) ........................... 247 set_ticks( ) .............................................................................................................................................................. 248 setup_sd_adc_calibration( ).................................................................................................................................... 248 set_sd_adc_channel( ) ........................................................................................................................................... 249 set_timerA( ) ........................................................................................................................................................... 249 set_timerB( ) ........................................................................................................................................................... 250 set_timerx( )............................................................................................................................................................ 250 set_rtcc( ) set_timer0( ) set_timer1( ) set_timer2( ) set_timer3( ) set_timer4( ) set_timer5( ) ........................... 251 set_tris_x( ) ............................................................................................................................................................. 251 set_uart_speed( ) ................................................................................................................................................... 252 setjmp( ) ................................................................................................................................................................. 253 setup_adc(mode) .................................................................................................................................................... 253 setup_adc_ports( ) .................................................................................................................................................. 254 setup_adc_reference( ) .......................................................................................................................................... 254 setup_at( ) .............................................................................................................................................................. 255 setup_ccp1( ) setup_ccp2( ) setup_ccp3( ) setup_ccp4( ) setup_ccp5( ) setup_ccp6( ) ......................................... 255 setup_clc1() setup_clc2() setup_clc3() setup_clc4() ............................................................................................... 257 setup_comparator( ) ............................................................................................................................................... 257 setup_counters( ) .................................................................................................................................................... 258 setup_cog( )............................................................................................................................................................ 259 setup_crc( )............................................................................................................................................................. 259 setup_cwg( ) ........................................................................................................................................................... 260 setup_dac( )............................................................................................................................................................ 261 setup_external_memory( ) ...................................................................................................................................... 261 setup_high_speed_adc( ) ....................................................................................................................................... 262 setup_high_speed_adc_pair( ) ............................................................................................................................... 262 setup_hspwm_blanking( ) ....................................................................................................................................... 263 setup_hspwm_chop_clock( ) .................................................................................................................................. 264 setup_hspwm_trigger( ) .......................................................................................................................................... 264 setup_hspwm_unit( ) .............................................................................................................................................. 265 setup_hspwm( ) ...................................................................................................................................................... 266 setup_hspwm_unit_chop_clock( ) .......................................................................................................................... 266 setup_lcd( ) ............................................................................................................................................................. 267 setup_low_volt_detect( ) ......................................................................................................................................... 268 setup_nco( )............................................................................................................................................................ 268 setup_opamp1( ) setup_opamp2( ) ........................................................................................................................ 269 setup_opamp1( ) setup_opamp2( ) ........................................................................................................................ 269 setup_oscillator( ) ................................................................................................................................................... 270 setup_pid( )............................................................................................................................................................. 270 setup_pmp(option,address_mask) ......................................................................................................................... 271 setup_power_pwm( ) .............................................................................................................................................. 272 setup_power_pwm_pins( ) ..................................................................................................................................... 273 setup_psp(option,address_mask) ........................................................................................................................... 273 setup_pwm1( ) setup_pwm2( ) setup_pwm3( ) setup_pwm4( ) .............................................................................. 274 setup_qei( )............................................................................................................................................................. 275 setup_rtc( ) ............................................................................................................................................................. 275 setup_rtc_alarm( ) .................................................................................................................................................. 276 setup_sd_adc( ) ...................................................................................................................................................... 276 setup_smtx( ) .......................................................................................................................................................... 277 setup_spi( ) setup_spi2( ) ....................................................................................................................................... 278

  • Table of Contents

    ix

    setup_timer_A( ) ..................................................................................................................................................... 278 setup_timer_B( ) ..................................................................................................................................................... 279 setup_timer_0( ) ..................................................................................................................................................... 279 setup_timer_1( ) ..................................................................................................................................................... 280 setup_timer_2( ) ..................................................................................................................................................... 280 setup_timer_3( ) ..................................................................................................................................................... 281 setup_timer_4( ) ..................................................................................................................................................... 281 setup_timer_5( ) ..................................................................................................................................................... 282 setup_uart( ) ........................................................................................................................................................... 282 setup_vref( ) ........................................................................................................................................................... 283 setup_wdt( ) ............................................................................................................................................................ 283 setup_zdc( ) ............................................................................................................................................................ 284 shift_left( ) ............................................................................................................................................................... 284 shift_right( )............................................................................................................................................................. 285 sleep( ) ................................................................................................................................................................... 285 sleep_ulpwu( ) ........................................................................................................................................................ 286 smtx_read( ) ........................................................................................................................................................... 287 smtx_reset_timer( ) ................................................................................................................................................. 288 smtx_start( )............................................................................................................................................................ 288 smtx_status( ) ......................................................................................................................................................... 288 smtx_stop( ) ............................................................................................................................................................ 289 smtx_write( ) ........................................................................................................................................................... 289 smtx_update( ) ........................................................................................................................................................ 290 spi_data_is_in( ) spi_data_is_in2( ) ........................................................................................................................ 290 spi_init() .................................................................................................................................................................. 291 spi_prewrite(data); .................................................................................................................................................. 291 spi_read( ) spi_read2( ) ........................................................................................................................................ 292 spi_read_16() ......................................................................................................................................................... 292 spi_read2_16() ....................................................................................................................................................... 292 spi_read3_16() ....................................................................................................................................................... 292 spi_read4_16() ....................................................................................................................................................... 292 spi_speed ............................................................................................................................................................... 293 spi_write( ) spi_write2( ) ......................................................................................................................................... 293 spi_xfer( )................................................................................................................................................................ 294 SPII_XFER_IN() ..................................................................................................................................................... 295 sprintf( ) .................................................................................................................................................................. 295 sqrt( ) ...................................................................................................................................................................... 296 srand( ) ................................................................................................................................................................... 296 STANDARD STRING FUNCTIONS( ) memchr( ) memcmp( ) strcat( ) strchr( ) strcmp( ) strcoll( ) strcspn( ) strerror( ) stricmp( ) strlen( ) strlwr( ) strncat( ) strncmp( ) strncpy( ) strpbrk( ) strrchr( ) strspn( ) strstr( ) strxfrm( ) ....................................................................................................................................... 297 strcpy( ) strcopy( ) ................................................................................................................................................... 298 strtod( ) ................................................................................................................................................................... 298 strtok( ) ................................................................................................................................................................... 299 strtol( ) .................................................................................................................................................................... 300 strtoul( ) .................................................................................................................................................................. 300 swap( ) .................................................................................................................................................................... 301 tolower( ) toupper( ) ................................................................................................................................................ 301 touchpad_getc( ) ..................................................................................................................................................... 302 touchpad_hit( ) ........................................................................................................................................................ 303 touchpad_state( ) .................................................................................................................................................... 303 tx_buffer_available() ............................................................................................................................................... 304 tx_buffer_bytes() ..................................................................................................................................................... 304 tx_buffer_full( ) ........................................................................................................................................................ 305 va_arg( ) ................................................................................................................................................................. 306 va_end( ) ................................................................................................................................................................ 306 va_start ................................................................................................................................................................... 307 write_bank( ) ........................................................................................................................................................... 307 write_configuration_memory( ) ............................................................................................................................... 308 write_eeprom( ) ...................................................................................................................................................... 308 write_external_memory( ) ....................................................................................................................................... 309 write_extended_ram( ) ............................................................................................................................................ 310

  • CCSC Manual

    x

    write_program_eeprom( ) ....................................................................................................................................... 310 write_program_memory( ) ...................................................................................................................................... 310 zdc_status( ) ........................................................................................................................................................... 312

    Standard C Include Files ............................................................................................................................................ 313 errno.h .................................................................................................................................................................... 313 float.h ...................................................................................................................................................................... 313 limits.h .................................................................................................................................................................... 314 locale.h ................................................................................................................................................................... 314 setjmp.h .................................................................................................................................................................. 314 stddef.h ................................................................................................................................................................... 315 stdio.h ..................................................................................................................................................................... 315 stdlib.h .................................................................................................................................................................... 315

    Error Messages .......................................................................................................................................................... 317 Compiler Error Messages ....................................................................................................................................... 317

    Compiler Warning Messages ..................................................................................................................................... 325 Compiler Warning Messages.................................................................................................................................. 325

    Common Questions & Answers ................................................................................................................................. 327 How are type conversions handled? ....................................................................................................................... 327 How can a constant data table be placed in ROM? ................................................................................................ 328 How can I use two or more RS-232 ports on one PIC? ....................................................................................... 328 How can the RB interrupt be used to detect a button press? ................................................................................. 329 How do I directly read/write to internal registers? ................................................................................................... 329 How do I do a printf to a string? .............................................................................................................................. 330 How do I get getc() to timeout after a specified time? ............................................................................................. 330 How do I put a NOP at location 0 for the ICD? ....................................................................................................... 331 How do I wait only a specified time for a button press? .......................................................................................... 331 How do I write variables to EEPROM that are not a byte? ..................................................................................... 331 How does one map a variable to an I/O port? ........................................................................................................ 33