Report Bugs Here

Moderator: Mmiscool

User avatar
By Electroguard
#46145 I think 'interrupt' may be broken.

It's quite a crucial command for reading any pins, so I think it's something that needs checking when possible, and probably a worthwhile contender for including a working example added to it's doc entry in Lang Ref.

if it helps, I've included a 'test' program which I think shows there's a problem, and hopefully can make things a bit quicker to check out - it uses cicciocb's UDP_debugger utility just to show what's happening under the covers without worrying about having to update screen info, and has embedded comments to explain things.

There's also related info here... http://www.esp8266.com/viewtopic.php?f=45&t=9622


Code: Select all'Trying to get INTERRUPT working using gpio00 button to toggle gpio01 led, but can't get anything to happen!
'Sending udp msg just to prove led can be toggled ok, therefore the problem must be something to do with interrupt
'Any udp garbage msg will do, it's just used to trigger the udp branch
'Using identical goto branches except that interrupt [gowait] wait's, but udp [goloop] returns to [loop] for new msgs
'Both branches will send udp msg to prove themselves - but nothing ever comes from [waitloop]
'Am I doing something wrong?
'Or is it an interrupt bug?


let inputpin = 0     'onboard gpio00 flashing button       
let ledpin = 1       'onboard gpio01 led
let ledstate = 1     'toggle state

let localIP = ip()   'sets up udp for sending and receiving activity msgs
pos = instrrev(localIP,".")
subnetIP = left(localIP,pos)
nodeIP = mid(localIP,pos+1)
udpbegin udpport
interrupt inputpin [gowait]

[loop]
'interrupt inputpin [gowait] ' Think it only needs initial declaration (as above), but tried using it here anyway
udpbranch [goloop]
wait
end                   ' (never should be reached)


[gowait]   
'interrupts should come here, but never does
udpwrite subnetIP & "255",  5001, "this is from interrupt branch"   ' but is never transmitted
if ledstate == 1 then let ledstate = 0 else let ledstate = 1
po ledpin ledstate                                                  ' never works on gpio00 pin interrupt
'return
wait

[goloop]     
'udp msgs should come here, and alwayd do
udpwrite subnetIP & "255",  5001, "this is from udp branch"    ' returns confirmations ok when udp msgs are received
if ledstate == 1 then let ledstate = 0 else let ledstate = 1
po ledpin ledstate                                             ' works when sent any udp msgs
return
'wait
User avatar
By cicciocb
#46184 Hi, your code works very well if you :

put the following line at the beginning :
let udpport = 5001

With this change, your code works!

CiccioCB
User avatar
By Electroguard
#46187 Cheers matey, but I still can't get interrupt to work for me even if I copy and past your replacement line in - or manually type it in for that matter - and I know I already tried using an absolute pin number for it in the past rather than a variable cos I don't like troubling you busy guys until I've tried everything I can think of first.

I'm wondering if this isn't some sort of regional keyboard thing again... like the double-quote turkey pretending to be a duck!

When you get the time, could you post up a quick interrupt example that you know definitely works 'as-is' for me to copy and paste and try - then if it still doesn't work for me, it would suggest there may be a regional problem which needs looking into.
User avatar
By cicciocb
#46190 Listen, I copy/pasted your code and I tried before to put 0 instead of inputpin in the interrupt line.
I tried and the interrupt was working. So I put back inputpin in the line and it was working too.
So I don't know why don't works for you.