Interrupt broken
Posted: Mon Apr 25, 2016 6:56 am
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
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