Documente Academic
Documente Profesional
Documente Cultură
DIRECTIVAS DE PREPROCESADO
#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:
#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:
#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
#INT_EXT External interrupt #INT_RTCC Timer 0 (RTCC) overflow #INT_TIMER1 Timer 1 overflow
A/D
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() ...
OUTPUT_X()
Syntax:
output_a (value) output_b (value) ...
OUTPUT_BIT( )
Syntax: output_bit (pin, value) Function: Outputs the specified value (0 or 1) to the specified I/O pin. Ejemplos
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
Ejemplos:
enable_interrupts(GLOBAL); disable_interrupts(INT_TIMER0); enable_interrupts(INT_TIMER1);
OTRAS FUNCIONES
swap()
setup_ccpX() set_pwmX_duty()