-
Notifications
You must be signed in to change notification settings - Fork 7.6k
timerAttachInterrupt() and timerDetachInterrupt() broken in 2.0.2+ #6730
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
@sweetlilmre Thanks for the report. I am adding that to roadmap. |
Possible workaround: try Ticker class. It works great in our projects. |
@mrengineer7777 Thanks for the suggestion. The Ticker class does not have a fine enough resolution (ms, I require us). I performed some tests using the |
@mrengineer7777 circling back here. I tried this out and there doesn't seem to be sufficient resolution / accuracy for my use-case. |
Sorry to hear that. I'm just a fellow engineer, so you'll need to wait for one of the maintainers to fix the code. Try this: look at the history of changes on that library and see if you can spot the change that broke it. Any of us can suggest a fix via a PR. |
I think it was in 2.0.2 where timer was refactored to use ESP-IDF API as many other peripherals in order to work on all chips and be ready for future chip support. The timer itself isn't broken, it works as expected. But as you reported there are few thing that are unnecessary or forgotten to change when code was refactored. |
I have submitted a PR. |
Board
ESP32 Dev Module
Device Description
https://www.banggood.com/ESP32-WiFi-+-bluetooth-Development-Board-Ultra-Low-Power-Consumption-Dual-Core-ESP-32-ESP-32S-Similar-ESP8266-Geekcreit-for-Arduino-products-that-work-with-official-Arduino-boards-p-1175488.html
Hardware Configuration
16x2 LCD connected via I2C
SD card connected via SDMMC pins
Rotary encoder connected to general IO
Version
latest master (checkout manually)
IDE Name
PlatformIO
Operating System
Windows 10 x64
Flash frequency
80 MHz
PSRAM enabled
no
Upload speed
921600
Description
Preamble:
After digging through a lot of code in my mission to figure out a resolution to issue #6693 I traced a calls from 2.0.1 through to master, to see what was happening in the timer code.
While I am no closer to a resolution for that issue, it seems that in the move to IDF, esp32-hal-timer.c has not been completely refactored.
Firstly:
timer_enable_intr(timer->group, timer->num);
is called. This is handled in driver/timer.c in IDF-4.4, so I'm not sure why it's handled here.void (*fn)(void)
call back is cast totimer_isr_t
astypedef bool (*timer_isr_t)(void *);
so there is no way to allow a yield as specified in the IDF docs (if needed), also the cast seems dodgy.static void IRAM_ATTR timer_isr_default(void *arg)
in driver/timer.cSecondly:
This is the previous implementation from pre 2.0.2 code, where passing
NULL
totimerAttachInterrupt
would effectively undo the attach. See 2.0.1 and previous code inesp32-hal-timer.c
.Suggestions:
For
timerAttachInterrupt
:timer_isr_callback_add()
void (*fn)(void)
in atypedef bool (*timer_isr_t)(void *);
For
timerDetachInterrupt
:timer_isr_callback_remove()
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: