You are on page 1of 19

COMPILADOR C

DE CCS

PRINCIPALES
FUNCIONES Y
DIRECTIVAS
DIRECTIVAS DE
PREPROCESADO
#DEVICE

Syntax: #device chip options


chip is the name of a specific processor
(like: PIC16C74),
Options are qualifiers to the standard
operation of the device.
Example:
#device PIC16F877
#INCLUDE

Syntax:
#include <filename>
#include "filename

Ejemplos:
#include <16f877.h>
#include lcd.h
#DEFINE

Syntax: #define id text


Used to provide a simple string
replacement of the ID with the given text
from this point of the program and on.
Examples:
#define verdadero 1
#define falso 0
#USE ****_I/O

Afectan a como utilizamos los TRISX


Syntax:
#use fast_io (port)
#use fixed_io (port_outputs=pin, pin?)
#USE STANDARD_IO (port)
Ejemplo
#use fast_io (A)
#USE DELAY

Syntax: #use delay (clock=speed(Hz))


Tells the compiler the speed of the
processor and enables the use of the
built-in functions: delay_ms() and
delay_us().
Ejemplo:
#use delay (clock=20000000)
#BYTE

Syntax: #byte id = x
Elements: id is a valid C identifier, x is a
C variable or a constant
Coloca la variable id en la posicion de
memoria x.
Ejemplo:
#byte portb=5
#INT_xxx

Indica que la funcion a continuacion es


la rutina de atencion de una
determinada interrupcin

#INT_EXT External interrupt


#INT_RTCC Timer 0 (RTCC) overflow
#INT_TIMER1 Timer 1 overflow
FUNCIONES ESPECIFICAS
DEL COMPILADOR
RS232 I/O Bit/Byte
I2C I/O Capt/Comp/PWM

Discrete I/O Timers


A/D Conversion
SPI two wire I/O
EEPROM
Parallel Slave I/O
C Math
Delays
Etc.
Processor
Controls
DELAYS

delay_ms(tiempo)

delay_us(tiempo)

delay_cycles(ciclos) (0-255)
1 ciclo= 4 ciclos de reloj
INPUT( )

Syntax: value = input (pin)


Returns:
0 (or FALSE) if the pin is low,
1 (or TRUE) if the pin is high
Ejemplo:
Encendido=input(PIN_A4)
INPUT_x()

Syntax:
value = input_a()
value = input_b()
value = input_c()
...
Returns: An 8 bit int representing the
port input data.
OUTPUT_X()

Syntax:
output_a (value)
output_b (value)
...
Parameters: value is an 8 bit int
Function: Output an entire byte to a
port.
OUTPUT_BIT( )

Syntax: output_bit (pin, value)


Function: Outputs the specified value (0
or 1) to the specified I/O pin.
Ejemplos
Output_bit (PIN_D1,0)
Output_bit(PIN_A3,1)
OUTPUT_xxxx()

OUTPUT_HIGH( )
Syntax: output_high (pin)
Function: Sets a given pin to the high state.

OUTPUT_LOW( )
Syntax: output_low (pin)
Function: Sets a given pin to the ground
state.
SET_TRIS_X()

Configura los registros de


direccionamiento de los puertos (TRIS)
0 significa salida
1 significa entrada
Ejemplo:
Set_tris_a(0b00001011)
ENABLE/DISABLE
INTERRUPTS
Permiten o inhiben las interrupciones.

Ejemplos:
enable_interrupts(GLOBAL);
disable_interrupts(INT_TIMER0);
enable_interrupts(INT_TIMER1);
OTRAS FUNCIONES

setup_adc_ports()
setup_adc()
set_adc_channel() swap()
read_adc()

setup_timer_X() setup_ccpX()
set_timer_X() set_pwmX_duty()
get_timer_X()

You might also like