Hello, I'm using an ESP32 (DEV board) to interface to a quadrature encoder using GPIO interrupts. I'm using the Arduino IDE. I'm having issues getting it to work as intended so I've written some simple code to troubleshoot. From my testing it seems it is double counting when I trigger an interrupt on the FALLING edge. It works fine when I trigger on a LEADING edge and CHANGE. It also works when I trigger on HIGH, but does not work when I trigger on LOW. The encoder (100 ppr) I'm using is 5v TTL so I'm shifting the level with a 74AHCT125N powered by the 3.3v from the ESP32. I've looked at the signal with a scope and it the rising and falling edges look fine. I have also tested with a Linear Scale and it acts just the same.
Here is the simple code I'm using to troubleshoot. (sorry not sure how to make this display as code)
Any help would be appreciated.
#define A_pin 34
volatile long NSV = 0;
void IRAM_ATTR EnCnt (){NSV++;}
void setup()
{
Serial.begin(115200);
attachInterrupt(A_pin,EnCnt,LOW);
}
void loop()
{
Serial.println(NSV);
}
/* RISING - works fine, counts to 100 in either direction
CHANGE - works fine, counts to 200 in either direction
FALLING - ERROR , counts to 200 in either direction, s/b 100
HIGH - works fine, counts to 100 in either direction
LOW - ERROR, counts to 200 in either direction, s/b 100, sometimes doesnt work at all.
*/
GPIO Interrupts issues?
Return to “General Discussion”
Jump to
- English Forum
- Explore
- News
- General Discussion
- FAQ
- Documentation
- Documentation
- Sample Code
- Discussion Forum
- Hardware
- ESP-IDF
- ESP-BOX
- ESP-ADF
- ESP-MDF
- ESP-WHO
- ESP-SkaiNet
- ESP32 Arduino
- IDEs for ESP-IDF
- ESP-AT
- ESP IoT Solution
- ESP RainMaker
- Rust
- ESP8266
- Report Bugs
- Showcase
- Chinese Forum 中文社区
- 活动区
- 乐鑫活动专区
- 讨论区
- 全国大学生物联网设计竞赛乐鑫答疑专区
- ESP-IDF 中文讨论版
- 《ESP32-C3 物联网工程开发实战》书籍讨论版
- 中文文档讨论版
- ESP-AT 中文讨论版
- ESP-BOX 中文讨论版
- ESP IoT Solution 中文讨论版
- ESP-ADF 中文讨论版
- ESP Mesh 中文讨论版
- ESP Cloud 中文讨论版
- ESP-WHO 中文讨论版
- ESP-SkaiNet 中文讨论版
- ESP 生产支持讨论版
- 硬件问题讨论
- 项目展示
Who is online
Users browsing this forum: No registered users and 149 guests
- All times are UTC
- Top
- Delete 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. ESP8266EX and ESP32 are some of our products.