I am working on KRC2 KSS5.6
I have a main program that calls a sub program 'pick', that in turn calls a sub program 'movepick'.
During 'movepick', normally an interrupt is expect as a sensor will be activated.
I take care that in the program 'movepick' at the end there is $ADVANCE=0 to stop the advance run pointer.
At the end of the interrupt program there is a 'bread' and 'resume' command.
If I declare the interrupt in the program 'pick' (before the call of movepick), the interrupt and the return to the code line where 'movepick' was called seems to work ok.
It does not work ok when I declare the interrupt in the 'main' program.
Is this correct that you have to declare the interrupt in the program to where an interrupt routine is to jump back when a 'bread' and 'resume' is in the interrupt routine?
Also if my interrupt declaration is in 'pick', the declaration is done everytime the 'pick' routine is run through, I suppose this is not a problem?
Jump back to program after interrupt
-
Plc_User -
March 23, 2016 at 3:21 PM -
Thread is marked as Resolved.
-
-
On a RESUME, the program pointer returns to the stack level where the Interrupt was declared. So, if your interrupt is declared in your main program, but the interrupt occurs 5 subroutines deep, the RESUME command will jump the program pointer all the way back up to the main program. So you have to be very careful about how you arrange your program calls and stack depths when using Interrupts with RESUME.
Interrupts can be re-declared at pretty much any time. The last declaration of a given interrupt number overwrites any earlier one, so if you declare Interrupt 10 in your main program, then declare it again three subroutines deeper, then the interrupt occurs 5 subroutines deep, the RESUME command will jump back to the 3rd level rather than the main level. Or, if your program runs normally, and the program pointer gets back to the main program, the interrupt will no longer be declared, because the subroutine containing the last declaration is no longer in the call stack.