Picaxe interrupt and program slots

Daniel.A

New Member
It seems when a program is running in a slot, it begins at the start of that program in that slot but not where the command run slot was first initiated. Not like gosub when it returns to where it was first called.
My question is what happens when I have an interrupt in slot 0 but I am running a program in slot 1, would the interrupt still occur in slot 0? Thanks.
 

bpowell

Senior Member
From Manual #2:

"No Gosubs (including the interrupt) can be shared between program slots"
"The gosub/return stack [which the interrupt uses] is reset when moving from one slot to another"

While pin-state, and variables are not reset...it looks like interrupts will not transfer between slots...you will have to set up the same interrupt in Slot 1 as you did in Slot 0 if you want it to work...or, you can always Run 0 to get back to the "main" slot.
 

inglewoodpete

Senior Member
I have used interrupts with multiple slots.

Include an (almost) identical interrupt routine in each slot. Also, set aside a variable for signalling between slots. The code at the start of each slot has a 'case' structure that steers execution to the appropriate code.

Peter
 

Daniel.A

New Member
From Manual #2:

"No Gosubs (including the interrupt) can be shared between program slots"
"The gosub/return stack [which the interrupt uses] is reset when moving from one slot to another"

While pin-state, and variables are not reset...it looks like interrupts will not transfer between slots...you will have to set up the same interrupt in Slot 1 as you did in Slot 0 if you want it to work...or, you can always Run 0 to get back to the "main" slot.
The pin condition that causes the interrupt only stays high for 6 seconds or so. This interrupt function also calls other
subprocedure which means the subprocedure cannot be called from another slot. I guess the programs in slots only works well between each other using pin conditions and variables like the manual 2 page 200.
 

inglewoodpete

Senior Member
This sounds like an occasion where an interrupt routine should not call sub procedures but just set flags.

When designing a large program, it is important to design it well.
 

Daniel.A

New Member
Thanks guys, I think using the flags and set of variables with a case structure would help me work between the slots.
 
Top