Hardware interupts

centrex

Senior Member
I would like to implement the Hardware interrupt available in the Picaxe 20X2.
My question is does it work the same as a normal interrupt ie with some code within the....

Do something
Interrupt
Do something
Return
Do more things

Thanks Centrex

I
 

hippy

Ex-Staff (retired)
Yes, hardware interrupts work the same way as SETINT interrupts. Control passes to the interrupt routine, that completes, RETURN is executed and the program continues from where the original code was interrupted.
 

westaust55

Moderator
Yes.

You need to use the HINTSETUP command and the SETINTFLAGS commands to set up the respond to hardware interrupts. See PICAXE manual 2.

Then when an interrupt occurs are the manual states for the SETINTFLAGS command:
If the particular
inputs condition is true, a ‘gosub’ to the interrupt sub-procedure is executed
immediately. When the sub-procedure has been carried out, program execution
continues from the main program
.
 

techElder

Well-known member
One point that is seldom mentioned when someone first starts checking out interrupts is this:

When the interrupt occurs, it looks for and executes a subroutine (provided by you) in your program that is actually labeled "interrupt:".
 

westaust55

Moderator
Note 1 of the SETINT command does sort of state that for those who read the PICAXE manual:

Notes:
1) Every program which uses the SETINT command must have a corresponding
interrupt: sub-procedure (terminated with a return command) at the bottom of the program.
also see note 2 on the same page of the PICAXE manual about resumeing interrrupt capabilities:
2) When the interrupt occurs, the interrupt is permanently disabled. Therefore to re-enable the interrupt (if desired) a SETINT command must be used within
the interrupt: sub-procedure itself. The interrupt will not be enabled until the ‘return’ command is executed.
 
Top