#include <stdio.h>
#include <stdlib.h>
#include <pic16f886.h>
#include <xc.h> //librería del compilador de C XC8
/* Estas dos definiciones están como macros desde customice en XC8 compiler */
#define _XTAL_FREQ 4000000 // necesario para macros __delay_ms()
#define __delay_ms(x) _delay((unsigned long)((x)*(_XTAL_FREQ/4000.0)))
#pragma config FOSC = XT// Oscillator Selection bits (INTOSC oscillator: CLKOUT function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled and can be enabled by SWDTEN bit of the WDTCON register)
#pragma config PWRTE = ON // Power-up Timer Enable bit (PWRT disabled)
#pragma config MCLRE = OFF // RE3/MCLR pin function select bit (RE3/MCLR pin function is MCLR)
#pragma config CP = OFF // Code Protection bit (Program memory code protection is disabled)
#pragma config CPD = OFF // Data Code Protection bit (Data memory code protection is disabled)
#pragma config BOREN = ON // Brown Out Reset Selection bits (BOR enabled)
#pragma config IESO = OFF // Internal External Switchover bit (Internal/External Switchover mode is disabled)
#pragma config FCMEN = OFF // Fail-Safe Clock Monitor Enabled bit (Fail-Safe Clock Monitor is disabled)
#pragma config LVP = OFF // Low Voltage Programming Enable bit (RB3 pin has digital I/O, HV on MCLR must be used for programming)
// CONFIG2
#pragma config BOR4V = BOR40V // Brown-out Reset Selection bit (Brown-out Reset set to 4.0V)
#pragma config WRT = OFF // Flash Program Memory Self Write Enable bits (Write protection off)
void main()
{
ANSEL =0X00 ; //Deshabilitar ADC
ANSELH =0X00 ; //Deshabilitar ADC
TRISB = 0xF0 ; // Configurar puerto B como entradas/salidas;
TRISC = 0XF0 ; // Configurar puerto C como salidas;
PORTB = 0X00 ; // Poner las salidas a cero;
PORTC = 0X00;
TRISA = 0X00 ; // Configurar puerto A como salidas;
PORTA= 0X00;
INTCON=0;
OPTION_REGbits.nRBPU=0;
INTCONbits.RBIE=1;
INTCONbits.RBIF=0;
INTCONbits.GIE=1;
while(1){
PORTCbits.RC2=1;
__delay_ms(300);
PORTCbits.RC2=0;
__delay_ms(300);
}
}
void interrupt pinb ()
{
if(INTCONbits.RBIF==1)
{
//PORTCbits.RC3=1;
PORTBbits.RB3=1;
__delay_ms(200);
}
INTCONbits.RBIF=0;
__delay_ms(10);
}