-
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
[BUG] ISR dispatch and GPTIMER problematic enable (IDFGH-13527) #14418
Comments
Startup as: |
I think there is no problem with sharing resources between two separate timers. Can you provide a simple reproduction project? Also, which version of the idf and which chip are you using? I will try to reproduce it. |
Hi, the problem is among the GPTIMER dispatch, it has a serious problem. gptimer_config_t IRAM_ATTR timer_config_us_up = { timer_creation_result = gptimer_new_timer(&timer_config_us_up, &gptimer_timelapse_action); int IRAM_ATTR onoff = 1; if (onoff){ Ocisloscope DS1104z with 100MHz 1GSa/s To have a minimum ammount of failures the highest level 1 is needed to have small ammount of error. There is no free error GPTImer at all. |
@filzek |
@florentbr in this case makes no difference as the size part of the memory read and write is always exacly the same, it could have a problem with a uint/string larger type, but for int family there is no such as problem. In the timer handle and others strucs the compiler moves it to the correct aligned part as well, it does it since sdk v3. |
Hi @filzek |
@filzek Does the comment in #14418 (comment) help? |
@AxelLin, we have already configured it to use IRAM. The issue seems to be directly related to how the SDK manages processes. Shifting all applications, including WiFi and BLE, to core 0 and isolating only the TIMER and ISR on core 1 helps reduce the problem, but it still persists. |
I have a similar problem, regularily the GPTimer is delayed (about 2 times per seconds but vary) have you found a solution ? |
How many microseconds of delay are there each time? And have you tried installing GPTimer on another core or putting your code to IRAM? @rickou |
i haven't the measure exactly (need to get the oscilloscope) but i can heard the delay in the motor noise 😁 i think it is due to Wifi (STA mode) and/or UDP socket i use. After many readings on internet, there is only 2 things more that i can/need do.. I will try to make some measure for frequency and delay. |
in addition, i replaced calls to GPIO function to direct register acces, replaced the sqrtf calls by my own implementation in IRAM but i still have some calls to xthal without IRAM_ATTR regarding saving float coprocessor registers, but i have no alternatives for theses functions: |
Have you tried this example?
So the alarm interval is around 20us, which is a high real time requirement IMO. I'm afraid you can hardly achieve it. The biggest problem is, we have many code that can disable the interrupt (enter critical section). |
Just trying to implement my own version.. 😜
yes, but ESP run quite faster... on 2 cores ! so 20us should not be a real problem.. ok for some small drifts.. to be honest, i'm more comfortable with much smaller MCU like PIC or STM32. ok i don't use Wifi and OS.. but using interrupts should not be so different... |
Answers checklist.
General issue report
### Issue Description:
We are encountering an issue with the ESP32 GPTimer system when attempting to execute two timers in rapid succession, both being set from within an ISR. Specifically, the first GPTimer (gptimer_triacs) always executes perfectly, but the second GPTimer (gptimer_triacs_all_off) sometimes fails to execute entirely. No errors are reported during the arming or setting of the timers, but the callback for gptimer_triacs_all_off occasionally does not get dispatched.
### Code Overview:
The following GPTimers are created and configured:
### Timer Arming in ISR:
Inside an ISR, both timers are re-armed sequentially:
Problem Summary:
This issue persists even though:
Test Conditions:
- gptimer_triacs: 5250μs
- gptimer_triacs_all_off: 5500μs
Even under these conditions, the issue occurs.
Observations:
Request for Guidance or any Changes to Try to Solve Addressed Issue
We are seeking clarification on whether there are known issues with GPTimer under the following conditions:
Is there any potential for a race condition or other underlying issue that could cause the second timer not to dispatch its callback? Any advice or suggested debugging steps to identify why this is happening would be greatly appreciated.
The text was updated successfully, but these errors were encountered: