Is it possible to jump to a different location in a program from the interrupt service routine? This is what I want to do...
Dir SWITCH In
SET IOCAN3 ON 'Waiting for negative going edge
ON Interrupt PORTBCHANGE CALL ChangeMode
Main:
nop
goto Main
SubRoutine1
do stuff
end sub
SubRoutine2
do stuff
end sub
end
TestLabel1:
do stuff
goto TestLabel1
TestLabel2:
do stuff
goto TestLabel2
SUB ChangeMode
Set IOCAF3 OFF
Mode += 1
If Mode = 5 Then Mode = 1
Select Case Mode
Case 1
SubRoutine1
Case 2
SubRoutine2
Case 3
goto TestLabel1
Case 4
goto TestLabel2
end Select
END SUB
Latest GCB build. Using a 16f1825 that can have interrupt on neg. edge.
Last edit: viscomjim 2016-06-24
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Is it possible to jump to a different location in a program from the interrupt service routine? This is what I want to do...
Dir SWITCH In
SET IOCAN3 ON 'Waiting for negative going edge
ON Interrupt PORTBCHANGE CALL ChangeMode
Main:
nop
goto Main
SubRoutine1
do stuff
end sub
SubRoutine2
do stuff
end sub
end
TestLabel1:
do stuff
goto TestLabel1
TestLabel2:
do stuff
goto TestLabel2
SUB ChangeMode
Set IOCAF3 OFF
Mode += 1
If Mode = 5 Then Mode = 1
Select Case Mode
Case 1
SubRoutine1
Case 2
SubRoutine2
Case 3
goto TestLabel1
Case 4
goto TestLabel2
end Select
END SUB
Latest GCB build. Using a 16f1825 that can have interrupt on neg. edge.
Last edit: viscomjim 2016-06-24
Personaly I would use the interupt routeen to set a flag and have the Select Case Construct in the Main Loop.
Jumping out of an interupt could leav context info on the stack which will eventualy overflow and crash.
Cheers
Chris
Excellent point Chris. Thanks!