Try this;
The purpose of WHILE (portb >> 4) != 15 is to wait until a button that generated the interrupt is released. It also reads the port, which is required before DT_INTs can clear the interrupt flag.Code:DEFINE OSC 4 CMCON=%00000111 VRCON = 0 PAUSEus 10 TRISA = %00000110 TRISB = %11110000 ' using upper 4-bits for interrupt PORTA = %00000000 PORTB = %00000001 OPTION_REG.7 = 0 OPTION_REG.6 = 0 led var portA.3 INCLUDE "DT_INTS-14.bas" ; Base Interrupt System INCLUDE "ReEnterPBP.bas" ; Include if using PBP interrupts ASM INT_LIST macro ; IntSource, Label, Type, ResetFlag? INT_Handler RBC_INT, _check, PBP, yes endm INT_CREATE ENDASM @ INT_ENABLE RBC_INT cycle: HIGH led pause 100 LOW led pause 100 @ Sleep goto cycle check: WHILE (portb >> 4) != 15 PAUSE 10 WEND @ INT_RETURN
To clear the interrupt-on-change flag bit you first have to read the port, then clear the flag. If you read the port while a button is still pressed, then clear the flag, another interrupt will be generated once the button is released.




Bookmarks