#include <idea.h>
#USE FAST_IO(A)
#USE FAST_IO(B)
#byte TRISB_REG = 0x86
#byte OPTION_REG = 0x81
#bit RBPU = OPTION_REG.7 // option register RBPUbit - enables pullup resistors on port B if is clear
#byte WPUB_REG = 0x95 // WPUB register, each bit enables the corresponding pullup resistor on port B if is set
#byte IOCB_REG = 0x96 //defines which pin of port B may cause an interrupt if is set and if is enabled.
#byte INTCON_REG = 0x8B
#bit RBIE = INTCON_REG.3 //RB Port Change Interrupt Enable bit. Enables port B interrupts if is set.
#bit RBIF = INTCON_REG.0 //RB Port Change Interrupt Flag bit. It is set if interrupt occured.
#bit GIE = INTCON_REG.7 //Global Interrupt Enable interrupts are enabled if is set.
#int_RB
void RB_isr(void)
{
output_toggle(PIN_A0);
RBIE = 0; //Interrupciones desabilitadas en el puerto B
//clear_interrupt (INT_rb);
//RBIE = 1; //Interrupciones habilitadas en el puerto B
}
void main()
{
set_tris_a (0); //Configurar el puerto A
setup_adc_ports( NO_ANALOGS );
trisb_reg = 0b11110000; //PB[7 - 4] son entradas
RBPU = 0; // Pull-up resistencias habilitadas
WPUB_REG = 0b11110000; //PB[7 - 4] pullup habilitadas
IOCB_REG = 0b11110000; //PB[7 - 4] habilitadas las interrupciones
INTCON_REG = 0b11110000;
RBIF = 0; //Limpiar Flag
GIE = 1;
RBIE = 1; //Interrupciones habilitadas en el puerto B
while(TRUE)
{
}
}