SETINT command

eddydde

Member
As a newbie to PICAXE I am trying to come to terms with the SETINT command before I use it in a project.

On page 182 of the PICAXE manual an example is given:

main:

low 1
Pause 2000
goto main

interrupt:

high 1
if pin 7 = 1 then interupt
pause 2000
setint %10000000, %10000000
return

I cannot see how it ever exits from the first two lines of the interrupt routine. Seems to me to be in a continuous loop.
Shouldn't there be a SETINT OFF command in there before it continues on to the pause 2000 and subsequent lines?

I am sure there is an easy explanation to this but I cannot see it.
 

westaust55

Moderator
DO not forget the line above the main: label

That is:

setint %10000000,%10000000 ‘ activate interrupt when pin7 only goes high

Without that line the interrupt is never set up in the first place.


In reality, rev Ed would have done well to have a label such as Init: before that first line.



With respect to the rest of your query,

The interrupt condition is automatically turned off when the interrupt subroutine is entered. That is why we need to have another SETINT command just beofer the RETURN command. (read the notes at the end for the SETINT command in the PICAXE manual.)

Then with the SETINT in place at the very start, then the lop only occurs until pin 7 goes back to a low state
 
Last edited:
Top