-
Notifications
You must be signed in to change notification settings - Fork 7.6k
timerAttachInterrupt(timer, onTimerISR, true); ISR is called immediately on timerAlarmEnable, not after the time #7336
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
Comments
Direct hardware access of the timers on the ESP32 is possible but tricky. I believe one of the hardware timers on the ESP32 is used for generating system ticks. I suspect you are accidentally modifying that timer. You may need to dig into ESP-IDF to determine which hardware timer they are using. We use the arduino-esp32 "Ticker" class. Works great for our needs. |
I had a similar issue. |
What is happening here is that you are enabling the timer, but the period has already expired. I tested your code and observed similar behaviour to what you have described. I used Thinking about it for a bit I added a |
Awesome. I'll try this today. Thanks. |
@mianos did this work for you and if so, can you close the issue? |
No time. I assume this is the fix. Closing. |
Board
ESP32 Dev Module
Device Description
Tried on, Heltec Lora 32. Lilygo bare ESP and TTGO ESP32 LCD
Hardware Configuration
None, stanadlone
Version
v2.0.5
IDE Name
Platformio
Operating System
Windows
Flash frequency
40Mhz
PSRAM enabled
yes
Upload speed
115200
Description
On timer ISR is called as soon as the timer is enabled, not after the time.
Connecting an oscilloscope to pin 18 I can see it's only about 20uS between zcisr and onTimerISR no matter what the delay is.
The sketch in the following block is the ESP32 version.
The same thing in ESP8266 works:
Sketch
Debug Message
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: