-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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
hw_timer_t can't be retriggered from inside an interrupt in 2.0.2+ #6693
Comments
Hello, are you please able to retest this with newly release 2.0.3 stable version please? |
Hi I will retest, just need confirmation on how I would set this up with Platformio. I am assuming that I can do something like this in my platformio.ini file: platform_packages = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.3 I'll try this and get back to you. Edit: I am specifying this to be clear: platform = https://github.com/platformio/platform-espressif32.git#v4.2.0 platform_packages = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.3 |
Just tested with the configuration below and the issue still persists: Edit: doing further testing from a completely clean platformio installation.
|
Full clean platformio install with 2.0.3 and the issue persists:
|
Hi @sweetlilmre, |
Hi @P-R-O-C-H-Y Thank you for your response. The sample I have provided is just the smallest possible example of the functionality I am using in a bigger project. I do not want the timer to repeat as per your code above. In the actual project:
So my implementation is logically correct and works as stated for anything pre 2.0.2. If there is a change in the API that would require me to implement this functionality differently then that would be helpful to understand. I have updated the example code to make the use-case explicit. Apologies for any confusion caused. |
@sweetlilmre remove the call to Be warned however, using HW Timers to adjust GPIO pins WILL generate inconsistencies in your signal! I initially was using the timers in this code and moved to the RMT for accuracy/compliance purposes. You can see some externally captured timing here. |
Hi @atanisoft I tried your suggestion. Unfortunately this does not solve the 2.0.3 issue and additionally stops the timer from re-firing in 2.0.1 so it seems to be necessary in this "repeating one-shot" context. Luckily signal inconsistency is not a huge issue in my application and it definitely works for use-case. Thank you very much for the links, I've been meaning to look into the RMT stuff for a while but the complexity scared me off. |
tl;dr I can achieve the desired behaviour on 2.0.1 and 2.0.2 (I'm assuming that 2.0.3+ will also work) by doing the following:
In other words, not using a one-shot, but adjusting repeat time. I've looked into this in some more detail and found the following: The IDF 4.4. timer driver code contains the following logic:
With the specific logic in question being: So two conditions will result in the re-arming of the timer alarm:
Digging further, the example supplied in the documentation: https://github.com/espressif/esp-idf/blob/58f378602faa075585e710df3d0803f62db8e331/examples/peripherals/timer_group/main/timer_group_example_main.c Uses
At any rate I now have a solution that works pre and post the 2.0.2 move the the IDF 4.4 timer driver. |
@sweetlilmre Can I close this as solved? |
@VojtechBartoska it can as I now have a means to make the timer work in the way I'd like it to. I was thinking of contributing an example sketch to demonstrate this, if that would be of interest? |
Closing |
Hi @sweetlilmre, sorry for replying a bit late but I was an vacation. Example sketch sounds good, what do you think @P-R-O-C-H-Y? |
@sweetlilmre Hi, did you have a time for a sketch to demonstrate this :) Thanks |
@P-R-O-C-H-Y firstly let me apologize for the long wait, many life things happened that I will not bore you with. Here is a sample sketch to demonstrate my required functionality which seems to work across framework versions from 2.0.2 up to 2.0.5. Let me know if you would like any additional examples or changes:
|
@VojtechBartoska can you reopen this bug? stumbled across this in 2.0.7 and 2.0.8, having the same use-case as @sweetlilmre (thanks for the investigation!). Use-Case: Have a single-shot timer which determines the next firing-timestamp in the ISR, so it "hops" from event to event at different time intervals. For this it should be sufficient to set a new target counter and (re-)start the timer, or? BTW, used a counting-downwards timer, same faulty behaviour ( |
@P-R-O-C-H-Y Can you please take a look on this again? Thanks |
Hello @x29a, have you tried the approach from @sweetlilmre? This case is not a bug btw, but it's more about what you can / can't run within ISR context. On the other hand I have good news. With the new version 3.0.0 which we are currently working on, the timer is already refactored and from what I remember and tested, all function will be allowed to run within ISR context. |
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
v2.0.2
IDE Name
Platformio 4.2.0 Visual Studio Code
Operating System
Windows 10 x64
Flash frequency
80 MHz
PSRAM enabled
no
Upload speed
921600
Description
The code below works in framework-arduinoespressif32 3.20001.0 (2.0.1) and below, but not 2.0.2 and above, including https://github.com/espressif/arduino-esp32.git#142fceb8563cd1795d619829e0a103770a344e1a (which I believe is 2.0.3 as based on the info from this issue: #6689 )
In 2.0.1 or below the serial output shows an increasing value for 'tick', but in any framework version greater than 2.0.1, 'tick' stays at 1 indicating that the interrupt is not retriggered by the timer code inside of it.
Using the PIO Arduino support 4.1.0 (2.0.1) <- Works, tick increments
Using the PIO Arduino support 4.2.0 (2.0.2) <- Does not work, tick is 1 (interrupt fired once)
Using the PIO Arduino support 4.2.0 (2.0.3 from the git hash mentioned above) <- Does not work, tick is 1 (interrupt fired once)
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: