Skip to content

attachInterrupt CHANGE acts like POSEDGE not ANYEDGE #322

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
chaeplin opened this issue May 24, 2015 · 5 comments
Closed

attachInterrupt CHANGE acts like POSEDGE not ANYEDGE #322

chaeplin opened this issue May 24, 2015 · 5 comments

Comments

@chaeplin
Copy link
Contributor

ESP-12 / pin 12 grounded with switch.

IDE 1.6.1-esp8266-1 / mac osx --> Working --> ANYEDGE
IDE 1.6.5 / mac osx( 775e9d4..49c25b9 esp8266 -> origin/esp8266) ---> NOT --> POSEDGE


int pin1 = 14;
volatile int state = LOW;

void setup()
{
Serial.begin(38400);
pinMode(pin1, OUTPUT);
pinMode(12, INPUT_PULLUP);
attachInterrupt(12, blink, CHANGE);
}

void loop()
{
digitalWrite(pin1, state);
//
Serial.print("state: ");
Serial.print(state);
Serial.print("\tread : ");
Serial.println(digitalRead(12));
delay(500);
}

void blink()
{
state = !state;
}


result
IDE 1.6.1-esp8266-1 / mac osx --> Working
IDE 1.6.5 / mac osx( 775e9d4..49c25b9 esp8266 -> origin/esp8266) ---> NOT


1.6.1-esp8266-1
state: 0 read : 1
state: 0 read : 1
state: 0 read : 1
state: 0 read : 1
state: 1 read : 0 --> change
state: 1 read : 0
state: 1 read : 0
state: 1 read : 0
state: 1 read : 0
state: 0 read : 1 --> change
state: 0 read : 1
state: 0 read : 1
state: 0 read : 1
state: 0 read : 1
state: 1 read : 0 --> change
state: 1 read : 0
state: 1 read : 0
state: 1 read : 0
state: 1 read : 0
state: 0 read : 1 --> change
state: 0 read : 1
state: 0 read : 1
state: 0 read : 1
state: 0 read : 1
state: 0 read : 1
state: 0 read : 1
state: 0 read : 1


775e9d4..49c25b9 esp8266 -> origin/esp8266
state: 0 read : 1
state: 0 read : 1
state: 0 read : 1
state: 0 read : 0 --> should be changed
state: 0 read : 0
state: 0 read : 0
state: 0 read : 0
state: 0 read : 0
state: 0 read : 0
state: 1 read : 1
state: 1 read : 1
state: 1 read : 1
state: 1 read : 0 --> should be changed
state: 1 read : 0
state: 1 read : 0
state: 1 read : 0
state: 1 read : 0
state: 1 read : 0
state: 1 read : 0
state: 0 read : 1
state: 0 read : 1
state: 0 read : 1
state: 0 read : 1
state: 0 read : 1
state: 0 read : 1
state: 0 read : 0 --> should be changed
state: 0 read : 0
state: 0 read : 0
state: 0 read : 0
state: 0 read : 0
state: 0 read : 0
state: 0 read : 0
state: 0 read : 0
state: 1 read : 1
state: 1 read : 1
state: 1 read : 1
state: 1 read : 1
state: 1 read : 1
state: 1 read : 0
state: 1 read : 0
state: 1 read : 0
state: 1 read : 0
state: 0 read : 1
state: 0 read : 1
state: 0 read : 1

@chaeplin chaeplin changed the title interrupt CHANGE acts like RISING / attachInterrupt attachInterrupt CHANGE acts like RISING May 25, 2015
@chaeplin chaeplin changed the title attachInterrupt CHANGE acts like RISING attachInterrupt CHANGE acts like POSEDGE not ANYEDGE May 25, 2015
@rayshobby
Copy link

I second this issue: I was trying to get RC-Switch library to work with ESP8266 so that I can receive signals from a remote control. It didn't work. After debugging, it seems interrupt mode 'CHANGE' is not capturing all rising and falling edges, instead, it's capturing only one type of edge.

@hariprasadiit
Copy link

same here.CHANGE is acting like RISING.

temporary solution would be changing interrupt something like this

if(L1_rising) {
attachInterrupt(L1_STATUS_PIN, onL1StateChange , FALLING);
L1_rising=false;
}
else{
attachInterrupt(L1_STATUS_PIN, onL1StateChange , RISING);
L1_rising=true;
}

but this puts some overhead on ESP chip i think.

@vshymanskyy
Copy link

Experienced same problem.

@igrr
Copy link
Member

igrr commented Jun 15, 2015

Thanks for the reports, I've found the bug, fix coming up.

@chaeplin
Copy link
Contributor Author

Test result : +1: 
---
CHANGE
state: 0    read : 1
state: 0    read : 1
state: 0    read : 1
state: 0    read : 1
state: 0    read : 1
state: 0    read : 1
state: 0    read : 1
state: 0    read : 1
state: 0    read : 1
state: 0    read : 1
state: 1    read : 0 <-----
state: 1    read : 0
state: 1    read : 0
state: 1    read : 0
state: 1    read : 0
state: 1    read : 0
state: 1    read : 0
state: 1    read : 0
state: 1    read : 0
state: 0    read : 1  <-----
state: 0    read : 1
state: 0    read : 1
state: 0    read : 1
state: 0    read : 1
state: 0    read : 1
state: 1    read : 0  <-----
state: 1    read : 0
state: 1    read : 0
state: 1    read : 0
state: 1    read : 0
state: 1    read : 0
state: 1    read : 0
state: 0    read : 1  <-----
state: 0    read : 1
state: 0    read : 1
state: 0    read : 1
state: 0    read : 1
state: 1    read : 0  <-----
state: 1    read : 0
state: 1    read : 0
state: 0    read : 1  <-----
state: 0    read : 1
state: 0    read : 1
state: 0    read : 1
state: 0    read : 1


---
RISING

state: 0    read : 1
state: 0    read : 1
state: 0    read : 1
state: 0    read : 1
state: 0    read : 1
state: 0    read : 1
state: 0    read : 0
state: 0    read : 0
state: 0    read : 0
state: 0    read : 0
state: 0    read : 0
state: 1    read : 1  <-----
state: 1    read : 1
state: 1    read : 1
state: 1    read : 1
state: 1    read : 0
state: 1    read : 0
state: 1    read : 0
state: 1    read : 0
state: 1    read : 0
state: 0    read : 1  <-----
state: 0    read : 1
state: 0    read : 1
state: 0    read : 1
state: 0    read : 0
state: 0    read : 0
state: 0    read : 0
state: 0    read : 0
state: 0    read : 0
state: 1    read : 1  <-----
state: 1    read : 1
state: 1    read : 1
state: 1    read : 1
state: 1    read : 1
state: 1    read : 1

---
FALLING

state: 0    read : 1
state: 0    read : 1
state: 0    read : 1
state: 0    read : 1
state: 0    read : 1
state: 1    read : 0  <-----
state: 1    read : 0
state: 1    read : 0
state: 1    read : 0
state: 1    read : 0
state: 1    read : 1
state: 1    read : 1
state: 1    read : 1
state: 1    read : 1
state: 1    read : 1
state: 1    read : 1
state: 1    read : 1
state: 0    read : 0  <-----
state: 0    read : 0
state: 0    read : 0
state: 0    read : 0
state: 0    read : 0
state: 0    read : 0
state: 0    read : 1
state: 0    read : 1
state: 0    read : 1
state: 0    read : 1
state: 1    read : 0  <-----
state: 1    read : 0
state: 1    read : 0
state: 1    read : 0
state: 1    read : 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants