Help required with a basic interrupt

jay4708

New Member
Hi

Could someone please help me get my head round this small bit of interrupt code.

I don't understand this line "if pinC.7 = 1 then interrupt", when I run it on the simulator and pin C.7 is high the interrupt works and the code is stepped through right to the 'return' and then it repeats for as long as c.7 is active.

What I've read about "if pin" from the picaxe website I would have thought the interrupt, when activated would make C.4 high then on the next line if C.7 was still active it would jump back up to the start of the interrupt and keep repeating this, only going to the end of the interrupt when C.7 was 0?

The code:

Code:
interrupt:							
[INDENT]high C.4      ; switch output C.4 on
if pinC.7 = 1 then interrupt      ; loop here until the interrupt cleared
pause 2000      ; wait 2 seconds
setint %00000010,%00000010      ; re-activate interrupt
return      ; return from sub[/INDENT]
Thanks for the help
John
 

hippy

Ex-Staff (retired)
From the comment on the "if pinC.7=1" line, the original interrupt should have been activated when a signal on C.7 was brought high, the "if pinC.7=1" line ensuring the interrupt doesn't proceed until the signal clears.

Why it jumps to the HIGH C.4 rather than back to the IF itself is anyone's guess. It doesn't however really make any practical difference.

The SETINT though shows an interrupt on a different pin to C.7 - I would guess there's a mismatch crept in between which pin is being used for the interrupt and which pin is being checked within the interrupt routine.
 

jay4708

New Member
All sorted, thanks Hippy, it was an error on my part.

I was trying to get my head round how an interrupt works by using the example code from the 'setint' picaxe page, I copied the example and modified it slightly so it would simulate on a Picaxe-08, I've just noticed this at the bottom of the 'setint' page:

Applies To: All (except 08, 18, 28)
Thanks for your help
John
 
Top