-
Notifications
You must be signed in to change notification settings - Fork 7.6k
[v4.2] Hardware timer functions not working, interrupts fail - known issue? #4743
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
To me, in the function setup() the second parameter in the call to timerAttachInterrupt should be onTimer without the '&', like so:
I think this is a bug in the timer examples RepeatTime and WatchdogTimer, but I may be mistaken. |
I am having this issue as well on my ESP32-S2-Saola-1 board. I have taken the direct example, and even tried taking out the pass by reference (&) from the code. When running the code, the serial monitor prints nothing. I have tried printing the incrimenter from the ISR and it stays 0, indicating the ISR is not running. Any updates or solutions on this? Many libraries seem to rely on the Arduino framework instead of the ESP-IDF framework. When there are timers involved in these libraries then I need to adjust the code to compensate for this. I am trying to use a stepper driver library which relies on this right now. |
I am fairly certain the Ticker library still works for a simple timer. If you need more control, the code in the Ticker library can be used as a template. |
Ticker uses the ESP-IDF functions as in my second example, and should be fine for milliseconds and seconds-level timers. Unfortunately it currently doesn't handle microsecond timers and wouldn't work for my library (dscKeybusInterface), which requires a 250 microsecond timer. IR libraries also use microsecond level timers. |
I've tested and I am using the timer driver for Marlin. Please provide a full minimum sketch to reproduce :) |
Here is full example sketch, taken from the OP. Neither attaching the interrupt pass-by-reference or pass-by-copy does anything. I also tried using this board with the ESP32TimerInterrupt library. The author confirmed this library does not work with the S2 variant of the ESP32. It would not be a big deal as long as I had some other way of utilizing Timer/ISR functionality. As it stands currently, this board which has been out for almost 2 years now still does not seem to have timer functionality/support under the Arduino framework whatsoever, and there is no way to combine the frameworks together in a "compatibility" mode, as the compiler complains that the board is unsupported for the
PlatformIO config:
|
Hi @me-no-dev,
I've re-tested the first example on a freshly installed macOS 10.14 system, new Arduino install, new checkout of the 'idf-releases/v4.2' branch with the following steps - only modified to remove
Compiled and uploaded to a NodeMCU esp32 board and again confirmed that the timer interrupt is not firing. Checked out the master branch, re-launched Arduino, re-compiled and uploaded to the board and the timer interrupt is working correctly. Let me know if there's any additional info I can provide to help replicate this issue - thanks! -Nikhil |
@taligentx I'll have a look in a few days, but in general the timer is hardware and Arduino has it's own low-level driver which have not changed, so it is really strange how the hardware would not work between versions :) |
Bumping, right now on master branch (cf43d17) the problem still persist, I even tried with https://github.com/khoih-prog/ESP32TimerInterrupt/commits/master but to no avail. I check-out to idf-release/v3.3 and the same code works without problem. I tried both examples RepeatTimer.ino from ESP32/Timer and TimerInterruptTest.ino from the library. |
Same thing here on a recent install. Timer code from the examples does nothing, cannot get it to fire. Tried:
What a drag/showstopper. Happy to try other things and to troubleshoot/experiment, because my project is dead without a working hardware timer. |
I don't think this is true. It did not help in my case anyway. I tried it. Does it work for you @ClemensAtElektor or were you just speculating? |
|
I took the Timer example code on a known good board and compiled and uploaded it using the Boards manager release version (not Alpha). It runs fine. I then took the same code example and compiled it using the latest git Alpha (on both Win 10 and Ubuntu) and uploaded it. The timer does not work. |
Why was this closed? It is clear that people are still encountering this bug/issue and there is no working solution. |
it was closed automatically by the commit linked above, because it contains the fix |
Apologies.. I did not see the hyperlink to the solution. Great news. Many thanks |
I confirmed tonight that this fix also works for me. Thanks for the work! Very appreciated. 🙏 |
Docs: Fixed typo Docs: Boards tree fixed Removed link from the getting started OS icons Pin layout images updated and added the requirements file for sphinx extensions Copy button extension enabled on conf.py Added information on the Getting Started Guide Removed pygments_style from conf.py Added SoC and Module image Added Windows install guide and boards manager images Added OTA Web Update to the docs and removed from md files Added DFU and ESPNOW files into the docs Fixed Typo Changes on the boards, getting started sections and menu order changed for Lib Builder Added references on the boards to fix broken link Added the basic tutorial as template Fix hardware timers Fixes: #5337 Fixes: #4743 Thanks to @maxgerhardt Added code style reference and WIP on the libs template Added peripherals tutorial Added peripherals tutorial fix Update on the WiFi lib docs and removed old md files Update on the WiFi lib docs Fixed the examples references for WiFi Lib Fixed code-block on begin function - WiFi Docs Updates on WiFi lib docs Fixed the AP section on docs Review in progress: API, boards and tutorials Fixed typo on Strapping pins Review done
I have updated to the latest versions of Arduino (1.8.15) and arduino-esp32 (2.0.0-alpha1), verified that esp32-hal-timer.c includes the fixes in the commit above, recompiled, and I still cannot get the timers to work on the esp32-s2. |
That release is from April 17, for this fix to be merge you need to directly use git latest version. |
hi how did you solved this problem ? |
Pretty sure I just used a version of the code after 8f46bad was merged. |
Hi folks,
The hardware timer functions seem to have an issue in the IDF 4.2 branch. The following sketch correctly blinks the onboard LED in 1.0.5-rc6 - under 4.2, this sketch compiles but fails to fire the interrupt:
The native IDF functions do work in the 4.2 branch, as tested in this example:
Is this currently the expected behavior? Per
esp32-hal-timer.c
:Thanks!
Environment: NodeMCU ESP-32S generic dev module, ESP32-S2 official dev board, macOS 11.1, Arduino IDE 1.8.13, core 1.0.5-rc6 and idf-release/v4.2.
The text was updated successfully, but these errors were encountered: