Interrupt and Return problem

PiX

New Member
My project has a stop button which invokes an interrupt sub-routine (turn off all the outputs, bleep a buzzer twice).

At the end of that sub-routine I know that I have to put a RETURN command but the problem is that I want the program to return to the first line not the next line due to be executed.

Obviously a GOTO (the first line) before RETURN can do what I want but then the interrupt cannot be reset (even if the the first line of the program is SETINT....).

I can't use a hardware interrupt as the Picaxe is an 18M2, plus I've already committed to a PCB.

I have thought that the interrupt routine could set a flag and that the flag could be checked with an IF..THEN..GOTO between every program line but that doesn't seem very elegant even though I have enough memory to do it.

What am I missing here?

Any ideas very welcome fellow forum members !!
 

AllyCat

Senior Member
Hi,

Is there anything wrong with putting a RESET command at the end of the Interrupt Routine?

If you want the "restart" to behave in some way differently to a "Normal Power-up", then maybe set a marker "flag" in the EEPROM (and clear it in your initialisation sequence only if it has been set).

Cheers, Alan.
 
Last edited:

hippy

Technical Support
Staff member
An interrupt RETURN can only go back to wherever it was when the interrupt occurred. You can jump out of the interrupt but then, as you have found, only the first ever interrupt will be acted upon. A hardware interrupt won't help even if that is available because it will act in the same way.

Your easiest option is to use the RESET command within the interrupt to force the whole program to restart again.
 

inglewoodpete

Senior Member
The only ways to change EEPROM values are:
  1. At download time, include EEPROM directives with values to be written.
  2. At run time, with the WRITE command.
 

AllyCat

Senior Member
Hi,

Will RESET clear EEPROM values?
No, and I'm not sure about the higher RAM values from 28 to 511 (accessible only via @bptr and PEEK/POKE).

Note that the EEPROM can eventually "wear out" (but it takes at least 100k write cycles). Hence my suggestion to write to it only when a value needs to be changed.

Cheers, Alan.
 
Top