Vous êtes sur la page 1sur 2

/* #pragma config VREGEN = #pragma config CP0 = OFF

* File: interruccion.c OFF // USB Voltage // Code Protection bit (Block 0


* Author: Eduardo Regulator Enable bit (USB (000800-001FFFh) is not
* voltage regulator disabled) code-protected)
* Created on 17 de abril de #pragma config CP1 = OFF
2018, 01:33 PM // CONFIG2H // Code Protection bit (Block 1
*/ #pragma config WDT = OFF (002000-003FFFh) is not
// Watchdog Timer Enable bit code-protected)
(WDT disabled (control is #pragma config CP2 = OFF
// PIC18F4550 Configuration placed on the SWDTEN bit)) // Code Protection bit (Block 2
Bit Settings #pragma config WDTPS = (004000-005FFFh) is not
32768 // Watchdog Timer code-protected)
// 'C' source line config Postscale Select bits #pragma config CP3 = OFF
statements (1:32768) // Code Protection bit (Block 3
(006000-007FFFh) is not
// CONFIG1L // CONFIG3H code-protected)
#pragma config PLLDIV = 1 #pragma config CCP2MX =
// PLL Prescaler Selection bits ON // CCP2 MUX bit // CONFIG5H
(No prescale (4 MHz oscillator (CCP2 input/output is #pragma config CPB = OFF
input drives PLL directly)) multiplexed with RC1) // Boot Block Code Protection
#pragma config CPUDIV = #pragma config PBADEN = bit (Boot block (000000-
OSC1_PLL2// System Clock OFF // PORTB A/D Enable 0007FFh) is not code-
Postscaler Selection bits bit (PORTB<4:0> pins are protected)
([Primary Oscillator Src: /1][96 configured as digital I/O on #pragma config CPD = OFF
MHz PLL Src: /2]) Reset) // Data EEPROM Code
#pragma config USBDIV = 1 #pragma config LPT1OSC = Protection bit (Data EEPROM
// USB Clock Selection bit OFF // Low-Power Timer 1 is not code-protected)
(used in Full-Speed USB Oscillator Enable bit (Timer1
mode only; UCFG:FSEN = 1) configured for higher power // CONFIG6L
(USB clock source comes operation) #pragma config WRT0 = OFF
directly from the primary #pragma config MCLRE = ON // Write Protection bit (Block 0
oscillator block with no // MCLR Pin Enable bit (MCLR (000800-001FFFh) is not
postscale) pin enabled; RE3 input pin write-protected)
disabled) #pragma config WRT1 = OFF
// CONFIG1H // Write Protection bit (Block 1
#pragma config FOSC = HS // CONFIG4L (002000-003FFFh) is not
// Oscillator Selection bits (HS #pragma config STVREN = write-protected)
oscillator (HS)) ON // Stack Full/Underflow #pragma config WRT2 = OFF
#pragma config FCMEN = Reset Enable bit (Stack // Write Protection bit (Block 2
OFF // Fail-Safe Clock full/underflow will cause Reset) (004000-005FFFh) is not
Monitor Enable bit (Fail-Safe #pragma config LVP = OFF write-protected)
Clock Monitor disabled) // Single-Supply ICSP Enable #pragma config WRT3 = OFF
#pragma config IESO = OFF bit (Single-Supply ICSP // Write Protection bit (Block 3
// Internal/External Oscillator disabled) (006000-007FFFh) is not
Switchover bit (Oscillator #pragma config ICPRT = OFF write-protected)
Switchover mode disabled) // Dedicated In-Circuit
Debug/Programming Port // CONFIG6H
// CONFIG2L (ICPORT) Enable bit (ICPORT #pragma config WRTC = OFF
#pragma config PWRT = OFF disabled) // Configuration Register Write
// Power-up Timer Enable bit #pragma config XINST = OFF Protection bit (Configuration
(PWRT disabled) // Extended Instruction Set registers (300000-3000FFh)
#pragma config BOR = OFF Enable bit (Instruction set are not write-protected)
// Brown-out Reset Enable bits extension and Indexed #pragma config WRTB = OFF
(Brown-out Reset disabled in Addressing mode disabled // Boot Block Write Protection
hardware and software) (Legacy mode)) bit (Boot block (000000-
#pragma config BORV = 3 0007FFh) is not write-
// Brown-out Reset Voltage // CONFIG5L protected)
bits (Minimum setting 2.05V)
#pragma config WRTD = OFF LATBbits.LB5 = INTCON3bits.INT2IF =
// Data EEPROM Write 1;//Cuando atiende la 0;//Esta bandera es
Protection bit (Data EEPROM instruccion de bit de alta modificada por la llegada del
is not write-protected) prioridad el led de flanco en la terminal de
//alta prioridad entrada
// CONFIG7L LB5 se enciende //debido a lo
#pragma config EBTR0 = OFF retardo(5000); cual se pone en 1 , YO LA
// Table Read Protection bit LATBbits.LB5 = TENGO QUE BORRAR
(Block 0 (000800-001FFFh) is 0;//Despues de 5 seg , vuelve DENTRO DE RUTINA DE
not protected from table reads a apagarse
executed in other blocks) INTCON3bits.INT2IF = //INTERRUPCION si no estara
#pragma config EBTR1 = OFF 0;//Con eso inhabilitamos la interrumpiendo la rutina
// Table Read Protection bit bandera y la apagamos INTCON3bits.INT2IE =
(Block 1 (002000-003FFFh) is } 1;//Habilita la interrupcion
not protected from table reads } externa INT0
executed in other blocks) INTCON3bits.INT2IP =
#pragma config EBTR2 = OFF void interrupt low_priority 1;//definimos de alta priordad
// Table Read Protection bit RSI_int1(void)//baja prioridad INTCON2bits.INTEDG0 =
(Block 2 (004000-005FFFh) is { 1;//Configura INT0 sensible al
not protected from table reads flanco, se usa push botton con
executed in other blocks) if(INTCON3bits.INT1IF)//Cuan resistencia
#pragma config EBTR3 = OFF do atiende la instruccion de bit //pull-up y
// Table Read Protection bit de alta prioridad el led de queremos que detecte flanco
(Block 3 (006000-007FFFh) is //alta prioridad descendente, y esto es
not protected from table reads LB6 se enciende inmediatamente
executed in other blocks) { //que se
LATBbits.LB6 = 1; presione el push botton
// CONFIG7H retardo(5000);
#pragma config EBTRB = OFF LATBbits.LB6 = //baja prioridad,utilizamos
// Boot Block Table Read 0;//Despues de 5 seg , vuelve las mismas intrucciones
Protection bit (Boot block a apagarse menos en INT1IP es
(000000-0007FFh) is not INTCON3bits.INT1IF = //igual a 0 por ser de baja
protected from table reads 0;//Con eso inhabilitamos la prioridad
executed in other blocks) bandera y la apagamos
} INTCON3bits.INT1IF = 0;
// #pragma config statements } INTCON3bits.INT1IE = 1;
should precede project file void main(void) INTCON3bits.INT1IP = 0;
includes. { INTCON2bits.INTEDG1 = 1;
// Use project enums instead int num = 0;
of #define for ON and OFF. INTCONbits.GIEH = RCONbits.IPEN =
0;////Interrumpe las 1;//declaramos que tenemos
interrupciones para que no GIEG Y GIEH habilitados
tenga problemas en el INTCONbits.GIEL =
#include <xc.h> desarrollo 1;//habilitamos las
#define _XTAL_FREQ //de mi programa interrupciones
20000000 TRISBbits.RB2 = 1; INTCONbits.GIEH = 1;
void retardo(int num) // tiempo //prioridad alta //habilitamos las interrupciones
{ TRISBbits.RB1 = 1;// globales y las de alta prioridad
for(int i=0;i<num;i++) prioridad baja while(1);
{ return;
__delay_ms(1); TRISBbits.RB5 =
} 0;//estados de los les
} TRISBbits.RB6 = 0;
void interrupt high_priority //alta prioridad }
RSI_int2(void)//Alta prioridad
{ INTCONbits.GIEH=1;//habilta
if(INTCON3bits.INT2IF) mos las prioridaes
{

Vous aimerez peut-être aussi