Syntax and Functions

Items marked with * are for 24-bit parts only.
Data Types
  • int1
  • int8
  • int16
  • int32
  • int48*
  • int64*
  • float
  • float48*
  • float64*
  • short
  • char
  • int
  • long
  • double*
  • _fixed(n)
  • unsigned
  • signed
  • void

Standard C Syntax
  • if, else, while, do, switch, case, for, return, goto, break, continue
  • ! ~ ++ -- * = = , & |
  • * / % << >> ^ && || ?:
  • <= < > >= == !=
  • = += -= *= /= %= >>= <<= &= ^=m |=
  • typedef, static, auto, const, enum, struct, union
  • Arrays up to 5 subscripts
  • Structures and Unions may be nested.
  • Custom bit fields (1-8 bits) within structures.
  • Enumurated types
  • Constant variables, arrays, structures and strings.
  • Full function parameter support (any number and kind).
  • C++ reference parameters and comments allowed

Items marked with * are for PIC10 – PIC18 compilers only.
Items marked with + are for PIC24 and dsPIC® compilers only.
Built-In Functions:

ALL

  • _mul( )
  • abs( )
  • acos( )
  • adc_done( )
  • adc_done( )
  • adc_done2( )+
  • adc_done2( )+
  • asin( )
  • assert( )
  • atan( )
  • atan2( )
  • atoe( )
  • atof( )
  • atof48( )+
  • atof64( )+
  • atoi( )
  • atoi32( )+
  • atoi48( )+
  • atol( )
  • atol32( )*
  • bit_clear( )
  • bit_first( )+
  • bit_last( )+
  • bit_set( )
  • bit_test( )
  • brownout_enable( )*
  • bsearch( )
  • calloc( )
  • ceil( )
  • clear_interrupt( )
  • cos( )
  • cosh( )
  • crc_calc(mode)+
  • crc_calc8( )+
  • crc_init(mode)+
  • dac_write( )
  • dci_data_received( )+
  • dci_read( )+
  • dci_start( )+
  • dci_transmit_ready( )+
  • dci_write( )+
  • delay_cycles( )
  • delay_ms( )
  • delay_us( )
  • disable_interrupts( )
  • div( )
  • dma_start( )+
  • dma_status( )+
  • enable_interrupts( )
  • erase_eeprom( )*
  • erase_program_eeprom( )*
  • erase_program_memory( )+
  • exp( )
  • ext_int_edge( )
  • fabs( )
  • fgetc( )
  • fgets( )
  • floor( )
  • fmod( )
  • fprintf( )
  • fputc( )
  • fputs( )
  • free( )
  • frexp( )
  • get_capture( )+
  • get_motor_pwm_count( )+
  • get_timer_x( )*
  • get_timerx( )+
  • get_timerxy( )+
  • get_tris_x( )
  • getc( )
  • getch( )
  • getchar( )
  • getenv( )
  • gets( )
  • goto_address( )
  • i2c_isr_state( )
  • i2c_poll( )
  • i2c_read( )
  • i2c_slaveaddr( )
  • i2c_speed( )
  • i2c_start( )
  • i2c_stop( )
  • i2c_write( )
  • input( )
  • input_change_x( )
  • input_state( )
  • input_x( )
  • interrupt_active( )
  • isalnum( )
  • isalpha(char)
  • isamong( )
  • iscntrl(x)
  • isdigit(char)
  • isgraph(x)
  • islower(char)
  • isprint(x)
  • ispunct(x)
  • isspace(char)
  • isupper(char)
  • isxdigit(char)
  • itoa( )
  • jump_to_isr( )*
  • kbhit( )
  • label_address( )
  • labs( )
  • lcd_contrast( )*
  • lcd_load( )*
  • lcd_symbol( )*
  • ldexp( )
  • ldiv( )
  • log( )
  • log10( )
  • longjmp( )
  • make16( )
  • make32( )
  • make8( )
  • malloc( )
  • memchr( )
  • memcmp( )
  • memcpy( )
  • memmove( )
  • memset( )
  • modf( )
  • nargs( )
  • offsetof( )
  • offsetofbit( )
  • output_X( )*
  • output_bit( )
  • output_drive( )
  • output_float( )
  • output_high( )
  • output_low( )
  • output_toggle( )
  • output_x( )+
  • perror( )
  • pmp_address(address)+
  • pmp_input_full( )+
  • pmp_output_full( )+
  • pmp_overflow( )+
  • pmp_read( )+
  • pmp_write( )+
  • port_x_pullups( )*
  • pow( )
  • printf( )
  • psp_input_full( )
  • psp_output_full( )
  • psp_overflow( )
  • psp_read( )+
  • psp_write( )+
  • putc( )
  • putchar( )
  • puts( )
  • pwr( )+
  • qei_get_count( )+
  • qei_set_count( )+
  • qei_status( )+
  • qsort( )
  • rand( )
  • read_adc( )
  • read_adc( )
  • read_adc2( )+
  • read_adc2( )+
  • read_bank( )*
  • read_calibration( )*
  • read_configuration_memory( )
  • read_eeprom( )
  • read_external_memory( )*
  • read_program_eeprom( )*
  • read_program_memory( )
  • read_rom_memory( )+
  • realloc( )
  • reset_cpu( )
  • restart_cause( )
  • restart_wdt( )
  • rotate_left( )
  • rotate_right( )
  • rtc_alarm_read( )*
  • rtc_alarm_read( )+
  • rtc_alarm_write( )*
  • rtc_alarm_write( )+
  • rtc_read( )*
  • rtc_read( )+
  • rtc_write( )+
  • rtos_await( )
  • rtos_disable( )
  • rtos_enable( )
  • rtos_msg_poll( )
  • rtos_msg_read( )
  • rtos_msg_send( )
  • rtos_overrun( )
  • rtos_run( )
  • rtos_signal( )
  • rtos_stats( )
  • rtos_terminate( )
  • rtos_wait( )
  • rtos_yield( )
  • set_adc_channel( )
  • set_adc_channel( )
  • set_adc_channel2( )+
  • set_adc_channel2( )+
  • set_compare_time( )+
  • set_motor_pwm_duty( )+
  • set_motor_pwm_event( )+
  • set_motor_unit( )+
  • set_power_pwm_override( )*
  • set_power_pwmx_duty( )*
  • set_pullup( )+
  • set_pwm1_duty( )*
  • set_pwm2_duty( )*
  • set_pwm3_duty( )*
  • set_pwm4_duty( )*
  • set_pwm5_duty( )*
  • set_pwm_duty( )+
  • set_rtcc( )*
  • set_timerx( )
  • set_timerxy( )+
  • set_tris_x( )
  • set_uart_speed( )
  • setjmp( )
  • setup_adc( )
  • setup_adc( )
  • setup_adc2( )+
  • setup_adc2( )+
  • setup_adc_ports( )
  • setup_adc_ports( )
  • setup_adc_ports2( )+
  • setup_adc_ports2( )+
  • setup_capture( )+
  • setup_ccp1( )*
  • setup_ccp2( )*
  • setup_ccp3( )*
  • setup_ccp4( )*
  • setup_ccp5( )*
  • setup_ccp6( )*
  • setup_comparator( )*
  • setup_comparator( )+
  • setup_compare( )+
  • setup_counters( )*
  • setup_crc(mode)+
  • setup_dac( )
  • setup_dac( )*
  • setup_dci( )+
  • setup_dma( )+
  • setup_external_memory( )*
  • setup_lcd( )*
  • setup_low_volt_detect( )+
  • setup_motor_pwm( )+
  • setup_opamp1( )*
  • setup_opamp2( )*
  • setup_oscillator( )
  • setup_pmp( )*
  • setup_pmp(option, address_mask)+
  • setup_power_pwm( )
  • setup_power_pwm_pins( )
  • setup_psp(option, address_mask)
  • setup_qei( )+
  • setup_rtc( )*
  • setup_rtc( )+
  • setup_rtc_alarm( )*
  • setup_rtc_alarm( )+
  • setup_spi( )
  • setup_spi2( )
  • setup_timer_0( )*
  • setup_timer_1( )*
  • setup_timer_2( )*
  • setup_timer_3( )*
  • setup_timer_4( )*
  • setup_timer_5( )*
  • setup_timerx ( )+
  • setup_uart( )
  • setup_vref( )+
  • setup_wdt ( )+
  • setup_wdt( )*
  • shift_left( )
  • shift_right( )
  • sin( )
  • sinh( )
  • sleep( )
  • sleep_ulpwu( )*
  • spi_data_is_in( )
  • spi_data_is_in2( )
  • spi_read( )
  • spi_read2( )
  • spi_write( )
  • spi_write2( )
  • spi_xfer( )
  • sprintf( )
  • sqrt( )
  • srand( )
  • strcat( )
  • strchr( )
  • strcmp( )
  • strcoll( )
  • strcopy( )
  • strcpy( )
  • strcspn( )
  • strerror( )
  • stricmp( )
  • strlen( )
  • strlwr( )
  • strncat( )
  • strncmp( )
  • strncpy( )
  • strpbrk( )
  • strrchr( )
  • strspn( )
  • strstr( )
  • strtod( )
  • strtof( )+
  • strtof48( )+
  • strtok( )
  • strtol( )
  • strtoul( )
  • strxfrm( )
  • swap( )
  • tan( )
  • tanh( )
  • tolower( )
  • touchpad_getc( )
  • touchpad_hit( )
  • touchpad_state( )
  • toupper( )
  • va_arg( )
  • va_end( )
  • va_start( )
  • write_bank( )*
  • write_configuration_memory( )
  • write_eeprom( )
  • write_external_memory( )*
  • write_program_eeprom( )*
  • write_program_memory( )

RS232 I/O

  • assert( )
  • fgetc( )
  • fgets( )
  • fprintf( )
  • fputc( )
  • fputs( )
  • getc( )
  • getch( )
  • getchar( )
  • gets( )
  • kbhit( )
  • perror( )
  • printf( )
  • putc( )
  • putchar( )
  • puts( )
  • set_uart_speed( )
  • setup_uart( )

SPI TWO WIRE I/O

  • setup_spi( )
  • setup_spi2( )
  • spi_data_is_in( )
  • spi_data_is_in2( )
  • spi_read( )
  • spi_read2( )
  • spi_write( )
  • spi_write2( )
  • spi_xfer( )

DISCRETE I/O

  • get_tris_x( )
  • input( )
  • input_change_x( )
  • input_state( )
  • input_x( )
  • output_X( )*
  • output_bit( )
  • output_drive( )
  • output_float( )
  • output_high( )
  • output_low( )
  • output_toggle( )
  • output_x( )+
  • port_x_pullups( )*
  • set_pullup( )+
  • set_tris_x( )

PARALLEL PORT

  • pmp_address(address)+
  • pmp_input_full( )+
  • pmp_output_full( )+
  • pmp_overflow( )+
  • pmp_read( )+
  • pmp_write( )+
  • psp_input_full( )
  • psp_output_full( )
  • psp_overflow( )
  • psp_read( )+
  • psp_write( )+
  • setup_pmp(option, address_mask)+
  • setup_psp(option, address_mask)

I2C I/O

  • i2c_isr_state( )
  • i2c_poll( )
  • i2c_read( )
  • i2c_slaveaddr( )
  • i2c_speed( )
  • i2c_start( )
  • i2c_stop( )
  • i2c_write( )

PROCESSOR CONTROLS

  • brownout_enable( )*
  • clear_interrupt( )
  • disable_interrupts( )
  • enable_interrupts( )
  • ext_int_edge( )
  • getenv( )
  • goto_address( )
  • interrupt_active( )
  • jump_to_isr( )*
  • label_address( )
  • read_bank( )*
  • reset_cpu( )
  • restart_cause( )
  • setup_oscillator( )
  • sleep( )
  • write_bank( )*

BIT/BYTE MANIPULATION

  • _mul( )
  • bit_clear( )
  • bit_first( )+
  • bit_last( )+
  • bit_set( )
  • bit_test( )
  • make16( )
  • make32( )
  • make8( )
  • rotate_left( )
  • rotate_right( )
  • shift_left( )
  • shift_right( )
  • swap( )

STANDARD C MATH

  • abs( )
  • acos( )
  • asin( )
  • atan( )
  • atan2( )
  • atoe( )
  • atof48( )+
  • atof64( )+
  • atoi32( )+
  • atoi48( )+
  • ceil( )
  • cos( )
  • cosh( )
  • div( )
  • exp( )
  • fabs( )
  • floor( )
  • fmod( )
  • frexp( )
  • labs( )
  • ldexp( )
  • ldiv( )
  • log( )
  • log10( )
  • modf( )
  • pow( )
  • pwr( )+
  • sin( )
  • sinh( )
  • sqrt( )
  • tan( )
  • tanh( )

VOLTAGE REF

  • setup_low_volt_detect( )*
  • setup_vref( )*

A/D CONVERSION

  • adc_done( )
  • adc_done2( )+
  • read_adc( )
  • read_adc2( )+
  • set_adc_channel( )
  • set_adc_channel2( )+
  • setup_adc( )
  • setup_adc2( )+
  • setup_adc_ports( )
  • setup_adc_ports2( )+

STANDARD C CHAR / STRING

  • atof( )
  • atoi( )
  • atol( )
  • atol32( )*
  • isalnum( )
  • isalpha(char)
  • isamong( )
  • iscntrl(x)
  • isdigit(char)
  • isgraph(x)
  • islower(char)
  • isprint(x)
  • ispunct(x)
  • isspace(char)
  • isupper(char)
  • isxdigit(char)
  • itoa( )
  • sprintf( )
  • strcat( )
  • strchr( )
  • strcmp( )
  • strcoll( )
  • strcopy( )
  • strcpy( )
  • strcspn( )
  • strerror( )
  • stricmp( )
  • strlen( )
  • strlwr( )
  • strncat( )
  • strncmp( )
  • strncpy( )
  • strpbrk( )
  • strrchr( )
  • strspn( )
  • strstr( )
  • strtod( )
  • strtof( )+
  • strtof48( )+
  • strtok( )
  • strtol( )
  • strtoul( )
  • strxfrm( )
  • tolower( )
  • toupper( )

TIMERS

  • get_timer_x( )*
  • get_timerx( )+
  • get_timerxy( )+
  • restart_wdt( )
  • set_rtcc( )*
  • set_timerx( )
  • set_timerxy( )+
  • setup_counters( )*
  • setup_timer_0( )*
  • setup_timer_1( )*
  • setup_timer_2( )*
  • setup_timer_3( )*
  • setup_timer_4( )*
  • setup_timer_5( )*
  • setup_timerx ( )+
  • setup_wdt ( )+
  • setup_wdt( )*

STANDARD C MEMORY

  • calloc( )
  • free( )
  • longjmp( )
  • malloc( )
  • memchr( )
  • memcmp( )
  • memcpy( )
  • memmove( )
  • memset( )
  • offsetof( )
  • offsetofbit( )
  • realloc( )
  • setjmp( )

CAPTURE/ COMPARE/PWM

  • get_capture( )+
  • get_motor_pwm_count( )+
  • set_compare_time( )+
  • set_motor_pwm_duty( )+
  • set_motor_pwm_event( )+
  • set_motor_unit( )+
  • set_power_pwm_override( )*
  • set_power_pwmx_duty( )*
  • set_pwm1_duty( )*
  • set_pwm2_duty( )*
  • set_pwm3_duty( )*
  • set_pwm4_duty( )*
  • set_pwm5_duty( )*
  • set_pwm_duty( )+
  • setup_capture( )+
  • setup_ccp1( )*
  • setup_ccp2( )*
  • setup_ccp3( )*
  • setup_ccp4( )*
  • setup_ccp5( )*
  • setup_ccp6( )*
  • setup_compare( )+
  • setup_motor_pwm( )+
  • setup_power_pwm( )
  • setup_power_pwm_pins( )

NON-VOLATILE MEMORY

  • erase_eeprom( )*
  • erase_program_eeprom( )*
  • erase_program_memory( )+
  • read_calibration( )*
  • read_configuration_memory( )
  • read_eeprom( )
  • read_external_memory( )*
  • read_program_eeprom( )*
  • read_program_memory( )
  • read_rom_memory( )+
  • setup_external_memory( )*
  • write_configuration_memory( )
  • write_eeprom( )
  • write_external_memory( )*
  • write_program_eeprom( )*
  • write_program_memory( )

STANDARD C SPECIAL

  • bsearch( )
  • nargs( )
  • qsort( )
  • rand( )
  • srand( )
  • va_arg( )
  • va_end( )
  • va_start( )

DELAYS

  • delay_cycles( )
  • delay_ms( )
  • delay_us( )

ANALOG COMPARE

  • setup_comparator( )*

RTOS

  • rtos_await( )
  • rtos_disable( )
  • rtos_enable( )
  • rtos_msg_poll( )
  • rtos_msg_read( )
  • rtos_msg_send( )
  • rtos_overrun( )
  • rtos_run( )
  • rtos_signal( )
  • rtos_stats( )
  • rtos_terminate( )
  • rtos_wait( )
  • rtos_yield( )

LCD

  • lcd_contrast( )*
  • lcd_load( )*
  • lcd_symbol( )*
  • setup_lcd( )*

D/A CONVERSION

  • dac_write( )
  • setup_dac( )

REAL TIME CLOCK CALENDAR

  • rtc_alarm_read( )*
  • rtc_alarm_write( )*
  • rtc_read( )*
  • setup_dac( )*
  • setup_rtc( )*
  • setup_rtc_alarm( )*

CAPACITIVE TOUCH PAD

  • touchpad_getc( )
  • touchpad_hit( )
  • touchpad_state( )

PARALLEL MASTER PORT

  • setup_pmp( )*

MISC.

  • setup_opamp1( )*
  • setup_opamp2( )*
  • sleep_ulpwu( )*

VOLTAGE REF/ COMPARE

  • setup_comparator( )+
  • setup_low_volt_detect( )+
  • setup_vref( )+

DMA

  • dma_start( )+
  • dma_status( )+
  • setup_dma( )+

QEI

  • qei_get_count( )+
  • qei_set_count( )+
  • qei_status( )+
  • setup_qei( )+

DCI

  • dci_data_received( )+
  • dci_read( )+
  • dci_start( )+
  • dci_transmit_ready( )+
  • dci_write( )+
  • setup_dci( )+

RTC

  • rtc_alarm_read( )+
  • rtc_alarm_write( )+
  • rtc_read( )+
  • rtc_write( )+
  • setup_rtc( )+
  • setup_rtc_alarm( )+

CRC

  • crc_calc(mode)+
  • crc_calc8( )+
  • crc_init(mode)+
  • setup_crc(mode)+
Pre-Processors:

ALL

  • #ASM
  • #BANKX+
  • #BANKY+
  • #BANK_DMA+
  • #BIT id=const.const*
  • #BIT id=id.const*
  • #BIT+
  • #BUILD
  • #BYTE id=const*
  • #BYTE id=id*
  • #BYTE+
  • #CASE
  • #DEFINE id string*
  • #DEFINE+
  • #DEFINEDINC
  • #DEVICE chip
  • #ELIF
  • #ELSE
  • #ENDASM
  • #ENDIF
  • #ERROR
  • #EXPORT
  • #EXPORT*
  • #FILL_ROM
  • #FUSES options
  • #HEXCOMMENT
  • #ID "filename"*
  • #ID CHECKSUM*
  • #ID number*
  • #ID+
  • #IF expr*
  • #IF+
  • #IFDEF id*
  • #IFDEF+
  • #IFNDEF
  • #IGNORE_WARNINGS
  • #IMPORT
  • #IMPORT*
  • #INCLUDE "FILENAME"*
  • #INCLUDE+
  • #INLINE
  • #INT_DEFAULT
  • #INT_GLOBAL*
  • #INT_xxx
  • #LINE*
  • #LIST
  • #LOCATE id=const*
  • #LOCATE+
  • #MODULE
  • #NOLIST
  • #OCS
  • #OPT
  • #ORG
  • #PIN_SELECT
  • #PRAGMA cmd*
  • #PRAGMA+
  • #PRIORITY*
  • #RECURSIVE+
  • #RESERVE
  • #ROM
  • #SEPARATE
  • #SERIALIZE
  • #TASK
  • #TYPE
  • #UNDEF id*
  • #UNDEF+
  • #USE DELAY
  • #USE DYNAMIC_MEMORY
  • #USE FAST_IO
  • #USE FIXED_IO
  • #USE I2C
  • #USE RS232
  • #USE RTOS
  • #USE SPI
  • #USE STANDARD_IO
  • #USE TOUCHPAD
  • #WARNING
  • #WORD
  • #ZERO_RAM
  • _ _DATE_ _
  • _ _DEVICE_ _
  • _ _FILENAME_ _
  • _ _FILE_ _
  • _ _LINE_ _
  • _ _PCB_ _*
  • _ _PCD_ _+
  • _ _PCH_ _*
  • _ _PCM_ _*
  • _ _TIME_ _

STANDARD C

  • #DEFINE+
  • #DEFINE id string*
  • #DEFINEDINC
  • #ELIF
  • #ELSE
  • #ENDIF
  • #ERROR
  • #IF+
  • #IF expr*
  • #IFDEF+
  • #IFDEF id*
  • #IFNDEF
  • #INCLUDE+
  • #INCLUDE "FILENAME"*
  • #LIST
  • #NOLIST
  • #PRAGMA+
  • #PRAGMA cmd*
  • #UNDEF+
  • #UNDEF id*
  • #WARNING

FUNCTION QUALIFIER

  • #INLINE
  • #INT_DEFAULT
  • #INT_GLOBAL*
  • #INT_xxx
  • #RECURSIVE+
  • #SEPARATE

PRE-DEFINED IDENTIFIER

  • _ _DATE_ _
  • _ _DEVICE_ _
  • _ _FILENAME_ _
  • _ _FILE_ _
  • _ _LINE_ _
  • _ _PCB_ _*
  • _ _PCD_ _+
  • _ _PCH_ _*
  • _ _PCM_ _*
  • _ _TIME_ _

RTOS

  • #TASK
  • #USE RTOS

DEVICE SPECIFICATION

  • #DEVICE chip
  • #FUSES options
  • #HEXCOMMENT
  • #ID+
  • #ID "filename"*
  • #ID CHECKSUM*
  • #ID number*
  • #PIN_SELECT
  • #SERIALIZE

BUILT-IN LIBRARIES

  • #USE DELAY
  • #USE FAST_IO
  • #USE FIXED_IO
  • #USE I2C
  • #USE RS232
  • #USE SPI
  • #USE STANDARD_IO
  • #USE TOUCHPAD

MEMORY CONTROL

  • #ASM
  • #BANKX+
  • #BANKY+
  • #BANK_DMA+
  • #BIT+
  • #BIT id=const.const*
  • #BIT id=id.const*
  • #BYTE+
  • #BYTE id=const*
  • #BYTE id=id*
  • #ENDASM
  • #FILL_ROM
  • #LINE*
  • #LOCATE+
  • #LOCATE id=const*
  • #ORG
  • #RESERVE
  • #ROM
  • #TYPE
  • #USE DYNAMIC_MEMORY
  • #WORD
  • #ZERO_RAM

COMPILER CONTROL

  • #CASE
  • #EXPORT*
  • #IGNORE_WARNINGS
  • #IMPORT*
  • #MODULE
  • #OCS
  • #OPT
  • #PRIORITY*

LINKER

  • #BUILD
  • #EXPORT
  • #IMPORT