Hi,
I've been trying vary to fully understand the RBC_INT interrupt handler in DT_INTS-18.pbp.
So I wrote this little program, Created a simulator circuit model and also a similar hardware circuit.
Here is the Code:
Code:
' RBC TEST.BAS
' PIC 18F6480
' MPLAB IDE V8.40
' PBP V2.60
' Build Options: [-ampasmwin]
' RB4 Momentary Contact Button Goes High on Press, 10K Resistor to Ground
' RB5 Momentary Contact Button Goes High on Press, 10K Resistor to Ground
' RB6 Momentary Contact Button Goes High on Press, 10K Resistor to Ground
' RB7 Momentary Contact Button Goes High on Press, 10K Resistor to Ground
' RC6 22K ohm to RX on 57600-N-8-1 Serial Terminal
INCLUDE "DT_INTS-18.bas" ; Include Darrel Taylor's Base Interrupt System for PIC18F [Version:3.4 (NOV 04, 2009)]
DEFINE OSC 20
DEFINE DEBUG_REG PORTC
DEFINE DEBUG_BIT 6
DEFINE DEBUG_BAUD 57600
DEFINE DEBUG_MODE 1
DEFINE SHOWDIGITAL 1
TRISB=%11111111
ADCON0=%00000000
ADCON1=%00001111
BTN VAR BYTE
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler RBC_INT, _DO_RBC_INT, ASM, yes
endm
INT_CREATE
ENDASM
@ INT_ENABLE RBC_INT
DEBUG "INTERRUPT CREATED",10,13
DEBUG "INTERRUPT ENABLED",10,13
HOLD_HERE:
DEBUG "WAITING FOR INTERRUPT",10,13
PAUSE 2500
GOTO HOLD_HERE
DO_RBC_INT
DEBUG "############### RBC INTERRUPT ACTIVATED #################",10,13
MENU:
PAUSE 200
DEBUG "MENU - READ BUTTONS",10,13
If PORTB.4 = 1 Then PAUSE 250: Goto DO_ENABLE
If PORTB.5 = 1 Then PAUSE 250: Goto DO_DISABLE
If PORTB.6 = 1 Then PAUSE 250: Goto DO_RETURN
If PORTB.7 = 1 Then PAUSE 250: Goto DO_CLEAR
GOTO MENU
DO_ENABLE:
DEBUG "RUNNING DO_ENABLE",10,13
@ INT_ENABLE RBC_INT
Pause 250
GOTO HOLD_HERE
DO_DISABLE:
DEBUG "RUNNING DO_DISABLE",10,13
@ INT_DISABLE RBC_INT
PAUSE 250
GOTO HOLD_HERE
DO_RETURN:
DEBUG "RUNNING DO_RETURN",10,13
@ INT_RETURN
PAUSE 250
GOTO HOLD_HERE
DO_CLEAR:
DEBUG "RUNNING DO_CLEAR",10,13
@ INT_CLEAR RBC_INT
PAUSE 250
GOTO HOLD_HERE
END
Here is the Circuit:

There are 4 buttons connected to PORT B <4.7>
Here are my observations:
The first press of any button activates the RBC Interrupt and sends program to DO_RBC_INT subroutine, then on to MENU where it checks for button presses. This behaves exactly as I would expect it to.
Now...After that....
Pressing Button RB.4 [ENABLE] Runs the DO_ENABLE subroutine then the HOLD_HERE subroutine. At this point, the Interrupt handler seems to shut down as no Port B inputs activate the interrupt handler. I would expect the Interrupt to remain active.
Pressing Button RB.5 [DISABLE] Runs the DO_DISABLE subroutine then the HOLD_HERE subroutine. The Interrupt handler is now disabled as expected.
Pressing Button RB.6 [RETURN] Runs the DO_RETURN subroutine then the HOLD_HERE subroutine. It then sends program to DO_RBC_INT subroutine, then on to MENU. I would expect it to return to HOLD_HERE which is wherr the interrupt was originally activated
Pressing Button RB.7 [CLEAR] Runs the DO_CLEAR subroutine. At this point, the Interrupt handler seems to shut down as no Port B inputs activate the interrupt handler. I would expect this to just clear the interrupt then await another RBC trigger.
So it seems I can only activate the interrupt one time.
It doesn't seem to matter whether I use ASM or PBP types or set Resetflag to yes, or no
Can anyone shed light on what I'm doing wrong, or am I simply misinterpreting the function of the INT_* utilities.
I'm just not sure if I've got a mistake, am staying up too late working on this stuff, or just really don't get it.
Thanks,
Bob
Bookmarks