#include <p18f2525.h>
#include <stdio.h>
#pragma config OSC = XT,FCMEN = OFF,IESO = OFF //CONFIG1H
#pragma config PWRT = ON,BOREN = OFF,BORV = 0 //CONFIG2L
#pragma config WDT = OFF,WDTPS = 32768 //CONFIG2H
#pragma config MCLRE = ON,LPT1OSC = OFF,PBADEN = OFF,CCP2MX = PORTC//CONFIG3H
#pragma config STVREN = OFF,LVP = OFF,XINST = OFF,DEBUG = OFF//CONFIG4L
#pragma config CP0 = ON,CP1 = ON,CP2 = ON//CONFIG5L
#pragma config CPB = ON,CPD = ON//CONFIG5H
#pragma config WRT0 = ON,WRT1 = ON,WRT2 = ON//CONFIG6L
#pragma config WRTB = ON,WRTC = ON,WRTD = ON//CONFIG6H
#pragma config EBTR0 = ON,EBTR1 = ON,EBTR2 = ON//CONFIG7L
#pragma config EBTRB = ON//CONFIG7H
volatile unsigned int micro_cadaver;//variable de la interrupcion
void interrupciones(void);//prototipo de la interrupción
//
//******************************************************//
// Vector de Interrupcion
//******************************************************//
//
#pragma code prioridad_nomal = 0X0008
void interrupcion_normal (void)
{
_asm goto interrupciones _endasm
}
#pragma code //fin de la interrupcion (retfie en el ASM)
//
//******************************************************//
// Rutina de Interrupcion
//******************************************************//
//
#pragma interrupt interrupciones
void interrupciones(void)
{
if(INTCONbits.RBIF) //pregunta por bandera de interrupción
{
PORTA=~PORTA;
micro_cadaver=1;
while(micro_cadaver!=0)
micro_cadaver++;
//*******************************
//truquito para el proteus jijiji
_asm MOVF PORTB,0,ACCESS _endasm
//no implemententar en la realidad
//********************************
INTCONbits.RBIF = 0; //limpia bandera y salimos
//*******************************
//truquito para el proteus jijiji
_asm MOVF PORTB,0,ACCESS _endasm
//no implemententar en la realidad
//********************************
}
}
//
//******************************************************
//******************************************************
//
//
//
//******************************************************//
//******************************************************//
//
//
// Programa Principal
//
//
//******************************************************//
//******************************************************//
//
void main(void)
{
ADCON0 = 0X00,ADCON1 = 0X0F,CMCON = 0X07;
//puerto A con todos los pines digitales
TRISA = 0X00,TRISB = 0XFF,TRISC = 0X00;
PORTA = 0X00,PORTB = 0X00,PORTC = 0X00;
RCON = 0X00;//IPEN = 0
INTCON = 0X88;//configuramos la interrupcion por cambio de estado RB4-RB7
INTCON2 = 0X80;//deshabilitamos las pull-up
//*******************************************************
//*******************************************************
while (1);
//*******************************************************
//*******************************************************
}