In my code I do a bunch of stuff then wait doing nothing for an interrupt some mS later, then when that happens I want to run my bunch of stuff again, forever and ever. Rather than return to where the interrupt occurred in my 'wait doing nothing'....
I see the obvious way is to put my 'bunch of stuff code in the interrupt handler subroutine, but that makes the int handler routine very big and the 'main' code very small. Looks all wrong to me. Is that the way to do it or is there a proper way to get the int handler to go to my 'bunch of stuff' rather than return to where it was interrupted from ?
Code:
LED1 VAR GPIO.1
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 TMR1_INT, _ToggleLED1, PBP, yes
endm
INT_CREATE ; Creates the interrupt processor
ENDASM
T1CON = $01 ; Prescaler = 1, TMR1ON
@ INT_ENABLE TMR1_INT ; enable Timer 1 interrupts
Main:
Big bunch of stuff
wait_here:
pause 1
Goto wait_here 'wait for an interrupt here
(Return from Interrupt would hang here ?)
GOTO Main 'should never happen
'---[TMR1 - interrupt handler]--------------------------------------------------
ToggleLED1:
T1CON = %0
TMR1L = $23
TMR1H = $A8
T1CON = %1
TOGGLE LED1
@ INT_RETURN
Bookmarks