1 / 19

COMPILADOR C DE CCS

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.

cornell
Download Presentation

COMPILADOR C DE CCS

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. COMPILADOR C DE CCS PRINCIPALES FUNCIONES Y DIRECTIVAS

  2. DIRECTIVAS DE PREPROCESADO

  3. #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

  4. #INCLUDE • Syntax: • #include <filename> • #include "filename“ • Ejemplos: • #include <16f877.h> • #include “lcd.h”

  5. #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

  6. #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)

  7. #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)

  8. #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

  9. #INT_xxx • Indica que la funcion a continuacion es la rutina de atencion de una determinada interrupción • #INT_EXT External interrupt • #INT_RTCC Timer 0 (RTCC) overflow • #INT_TIMER1 Timer 1 overflow

  10. FUNCIONES ESPECIFICAS DEL COMPILADOR • RS232 I/O • I2C I/O • Discrete I/O • SPI two wire I/O • Parallel Slave I/O • Delays • Processor Controls • Bit/Byte • Capt/Comp/PWM • Timers • A/D Conversion • EEPROM • C Math • Etc.

  11. DELAYS • delay_ms(tiempo) • delay_us(tiempo) • delay_cycles(ciclos) (0-255) • 1 ciclo= 4 ciclos de reloj

  12. 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)

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

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

  15. 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)

  16. 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.

  17. SET_TRIS_X() • Configura los registros de direccionamiento de los puertos (TRIS) • 0 significa salida • 1 significa entrada • Ejemplo: • Set_tris_a(0b00001011)

  18. ENABLE/DISABLE INTERRUPTS • Permiten o inhiben las interrupciones. • Ejemplos: • enable_interrupts(GLOBAL); • disable_interrupts(INT_TIMER0); • enable_interrupts(INT_TIMER1);

  19. setup_adc_ports() setup_adc() set_adc_channel() read_adc() setup_timer_X() set_timer_X() get_timer_X() swap() setup_ccpX() set_pwmX_duty() OTRAS FUNCIONES

More Related