-->
Page 1 of 2

interrupt triggering twice

PostPosted: Tue Jan 05, 2016 6:25 am
by sadat007
Dear I placed LED on PORT 12 with one end connected to VCC via 470ohms and a switch one point connected to PORT 13 other to GND. Also PORT 13 pulled up to VCC via 4.7k.
With following codes when I press switch the LED on and then off after 1500ms. Also get twice "Switch" on hyper terminal with 1500ms delay. I think it is a bug!

Code: Select allprint "Testing Port Out and Interrupt"
print "Switch on P13 LED on P12"
interrupt 13 [T.LED]
let a = 0
po 12 0
wait
[T.LED]
print "Switch"
if a = 0 then po 12 0 else po 12 1
if a = 0 then a = 1 else a = 0
delay 1500
wait

Re: interrupt triggering twice

PostPosted: Tue Jan 05, 2016 6:24 pm
by Mmiscool
Interrupts trigger on a pin change. So if a pin goes from high to low or low to high. This will cause 2 trigger events.

You are best to check the status of the pin from in side the branch being triggered.

Re: interrupt triggering twice

PostPosted: Wed Jan 06, 2016 2:23 am
by sadat007
Dear, Sorry but I do not agree that this behavior is normal because never seen like this with microcontrollers. Well your suggestion can fix this. May be this is hardware issue of ESP8266. OH! ESP8266 trigger on state change! so when I pressed button it change from 1 to 0 first trigger then released button 0 to 1 second trigger..... So it is hardware limitation of ESP8266 ???? Thanks dear

Re: interrupt triggering twice

PostPosted: Wed Jan 06, 2016 5:22 am
by Mmiscool
It's not a hardware limitation.its just how its coded.

Having it let you know when a button is pushed or release is important. The pins full status can be checked.