Hi everybody,
Could anyone guide me on the following issue.
I am pairing ds3231 RTC with esp-12. GPIO4 is SCL, GPIO5 is SDA. GPIO12 is setup as input to detect falling-edge with pull-up enabled.
When RTC alarm1 matches, it sends neg signal, interrupt callback fires. But it keeps firing until watchdog takes over. I can disable the interrupt and code in callback works fine. But I can not trap the second alarm interrupt as interrupt is disabled.
Thanks.
How to prevent GPIO Interrupt from keep firing
Re: How to prevent GPIO Interrupt from keep firing
Postby eriksl » Sat Aug 15, 2015 9:38 pm
The procedure for getting a pin change interrupt (in ATmel lingo) is a bit... peculiar. Do it exactly the way I now do it, and it works. Do it any differently and it doesn't work. The documentation about this is really... substandard.
https://github.com/eriksl/esp8266-unive ... ios.c#L209
In short: enable the interrupt "somewhere". When it fires you will get to the handler. At that point CLEAR ALL INTERRUPTS using gpio_intr_ack(pc). You cannot selectively ack one pin's interrupt and rely on the handler being called again for that interrupt. Now check the pc (mask) for all interrupts that fired set a flag for them "somewhere" and handle them later (not in the interrupt handler!). That "later" might a "posted" callback or a timer (or even better, a posted callback FROM a timer). At that point when you have actually handled the interrupt, you can enable it again, which is required. It's all one-shot, apparently.
Don't use the examples you'll find with google, they're for older SDK-versions.
https://github.com/eriksl/esp8266-unive ... ios.c#L209
In short: enable the interrupt "somewhere". When it fires you will get to the handler. At that point CLEAR ALL INTERRUPTS using gpio_intr_ack(pc). You cannot selectively ack one pin's interrupt and rely on the handler being called again for that interrupt. Now check the pc (mask) for all interrupts that fired set a flag for them "somewhere" and handle them later (not in the interrupt handler!). That "later" might a "posted" callback or a timer (or even better, a posted callback FROM a timer). At that point when you have actually handled the interrupt, you can enable it again, which is required. It's all one-shot, apparently.
Don't use the examples you'll find with google, they're for older SDK-versions.
Who is online
Users browsing this forum: No registered users and 56 guests
Login
Newbies Start Here
Are you new to ESP8266?
Unsure what to do?
Dunno where to start?
Start right here!
Latest SDK
Documentation
Complete listing of the official ESP8266 related documentation release by ESPRESSIF!
Must read here!
- All times are UTC+08:00
- Top
- Delete all board cookies
About Us
Espressif Systems is a fabless semiconductor company providing cutting-edge low power WiFi SoCs and wireless solutions for wireless communications and Internet of Things applications. We are the manufacturer of ESP8266EX.