Quick interrupt question.

roho

Member
Hi all,

Hopefully, with a simple definitive answer. Is it possible to set and invoke an interrupt from within the interrupt subroutine or do you have to return from the interrupt subroutine before you can interrupt again?

Thanks for any help?

Roger.
 

oracacle

Senior Member
Is there a reason why you want this to happen?
I imagine it could cause issues with return stacks, but that doesn't mean that it cant be done.
try it and find out is the ultimate answer.
 

roho

Member
Well, it came about because of the way I wrote my code, but having got to that point there's also an element of curiosity about it. I have tried it and it doesn't work, and I wasn't certain whether I should continue debugging my code or whether I was trying the impossible.
 

hippy

Technical Support
Staff member
On the PICAXE interrupts cannot be nested. Interrupts will only be re-enabled when the RETURN of the interrupt routine is executed.
 

roho

Member

eggdweather

Senior Member
The way I would do what I read your trying to do on the PICAXE is to emulate nested responses by status flags and I would describe it logically like this:
main_interrupt:
if event_1 or condition occurs then enable sub_interrupt1 flag
if event_2 or condition occurs then enable sub_interrupt2 flag
...and so on
if sub_interrupt1 flag is enabled process_activity_for_interrupt1 and return to here
if sub_interrupt2 flag is enabled process_activity_for_interrupt2 and return to here
return

Then if the main_interrupt refresh/trigger rate was high compared with your needs, it would to all intents and purposes act as multiple interrupts.

I have designed systems where they spend most of their time in the interrupt routine (let's call it background) rather than the foreground.
 
Top