Interrupt not working

Greeper

New Member
I've done a few things with the PICAXE and have had some success. When things don't work, break it down into the basics and work through it...this is the first time I've tried to use an interrupt, but it made sense and I can't get it to work. So I simplified it and it still doesn't work.

Here's the simple version (on a 14M2):


setint %00000001,%00000000,C ; interrupt when pinC.0 goes low

main: low B.3 ; switch output B.3 OFF
pause 2000 ; wait 2 seconds
serTXD("MAIN")
goto main ; loop back to start

interrupt: high B.3 ; switch output B.1 ON
pause 2000 ; wait 2 seconds
serTXD("Interrupt")
setint %00000001,%00000000,C ; re-activate interrupt
return ; return from sub

This is straight from the example on the Wiki, with the pins changed. I expect that when I push the button that pulls C.0 low the LED on B.3 will turn on. The terminal gives me the MAIN message but never the Interrupt message.

What the heck am I doing wrong?
 

AllyCat

Senior Member
Hi,

With M2 PICaxes, only (some pins of) Port C can be used as an interrupt input, so the command syntax does not require the "C" to be specified. Also, the mask and port images appear to be the wrong way around, so the command should be simply: setint %00000000 , %00000001 ; interrupt when pinC.0 goes low .

Cheers, Alan.
 
Last edited:

Buzby

Senior Member
Your setint lines are wrong, use these ...

setint %00000000,%00000001

This is taken from manual 2, page 224
 

inglewoodpete

Senior Member
Unfortunately, documentation for most devices are written by experts. Not a bad thing, of course! The author usually knows what they are saying but are not always clear in how they say it. The problem you have encountered is the definition of the 'mask' parameter.

Under Syntax, the parameter 'mask' is described '- mask is variable/constant (0-255) which specifies the mask'. I find that using the same word to describe itself is often not helpful. With the benefit of hindsight, the author could have said: '- mask is variable/constant (0-255) whose bits specify the the pins that are to be monitored to cause an interrupt'.

Having said that, deeper in the command description, under Information, the meaning of 'mask' is clarified. 'The interrupt inputs condition is any pattern of '0's and '1's on the input port, masked by the byte 'mask'. Therefore any bits masked by a '0' in byte mask will be ignored.'
 

cpedw

Senior Member
I find that using the same word to describe itself is often not helpful.
Agreed. Another pet hate of mine that I encounter from time to time is to describe the same thing with different names at different places in the text. It's a fine linguistic device in literature but in technical work, it just serves to confuse the non-expert, that's me! Any technical authors, please take note.

Apologies for going off-topic though I think the original question has been resolved.

Derek
 

Greeper

New Member
This is likely the most embarrassed I've been in a forum...I can't believe it was that simple.

In my mind it flows with the left to right and if 'port' is 'state' made sense in my head...Well, never mind.

It works now and I thank you for your help...Now I've got to go do something I'm actually good at to boost my ego.
 

Buzby

Senior Member
"I can't believe it was that simple. "

Yesterday I spent 6 hours trying to get an Ethernet connection to a PC working, then found I was plugged into the wrong Ethernet socket.

It happens to us all !
 

hippy

Technical Support
Staff member
This is likely the most embarrassed I've been in a forum...I can't believe it was that simple.
I wouldn't be too embarrassed. I guessed it may have been the two entities swapped round but I will readily admit that I would have had to read the command specification to check that it was, always have to when it comes to using a SETINT command.

The other trap I have frequently fallen into is "SERIN PIN, BAUD, (b0)". That creates a qualifier, an expectation of receiving whatever is in 'b0' then ignoring it, rather than storing what is received into 'b0'.
 
Top