Hey group,
I am finally tackling DT's instant INT's
I have been able to get his LED blink sample working using INT_INT (pin RA2 on the 16F690, the external INT pin)
using this code...
Code:
include "ALLDIGITAL.pbp"
INCLUDE "DT_INTS-14.bas" ; Base Interrupt System
INCLUDE "ReEnterPBP.bas" ; Include if using PBP interrupts
wsave VAR BYTE $70 SYSTEM ' alternate save location for W
DEFINE OSC 4
TrisA = %00000100
TrisB = %00000000
TrisC = %00000011
LED0 VAR PORTC.0 'this LED is controlled by the "INT" pin, 16F690=RA2
LED1 var PortC.1 'this LED is controlled by the Main program loop
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler INT_INT, _ToggleLED1, PBP, yes
endm
INT_CREATE ; Creates the interrupt processor
ENDASM
@ INT_ENABLE INT_INT ; enable external (INT) interrupts
Main:
PAUSE 1000
Toggle led1
GOTO Main
'---[INT - interrupt handler]---------------------------------------------------
ToggleLED1:
TOGGLE LED0
@ INT_RETURN
But I can not get the interupt to work using RB7(Individually controlled interrupt-onchange.
Individually enabled pull-up.)
I have tried several of the various INT choices and the one that seems to compile without errors is RABC_INT. But the program acts weird. I have two LED's one connected to RC0 that should be controlled by the instantINT. And another LED connected to RC1 that should be blinking at a 1 second rate controlled by the "Main" program loop.
Here is the code for that...
Code:
include "ALLDIGITAL.pbp"
INCLUDE "DT_INTS-14.bas" ; Base Interrupt System
INCLUDE "ReEnterPBP.bas" ; Include if using PBP interrupts
wsave VAR BYTE $70 SYSTEM ' alternate save location for W
DEFINE OSC 4
TrisA = %00000000
TrisB = %10000000
TrisC = %00000000
CM1CON0 = 0 'turn off the comparator 1
CM2CON0 = 0 'turn off the comparator 2
OPTION_REG.7=1 'Turn OFF weak pull ups
LED0 VAR PORTC.0 'this LED is controlled by the "INT" pin, 16F690=RA2
LED1 var PortC.1 'this LED is controlled by the Main program loop
IOCB.7=1
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler RABC_INT, _ToggleLED1, PBP, yes
endm
INT_CREATE ; Creates the interrupt processor
ENDASM
@ INT_ENABLE RABC_INT ; enable external (INT) interrupts
Main:
PAUSE 1000
Toggle led1
GOTO Main
'---[INT - interrupt handler]---------------------------------------------------
ToggleLED1:
TOGGLE LED0
@ INT_RETURN
LED0 controlled by the "Main" program loop is working correctly.
LED1 (should be controlled by RB7 INT) does not work correctly... it blinks erratically. ON dim, ON bright and OFF
and the LED1 ONLY blinks if in include this line of code... IOCB.7=1
What am I doing wrong??
How does one know which INT to use??
My goal is to impliment instantINT using a rotary encoder on RB6 & 7, and a third INT for the encoder push-button on RB5.
HELP! please
Bookmarks