I have a control application that needs to run every 500 us (2 kHz). I am using esp_timer() at 500 us, to run the control code. (I send a semaphore to the Control Task each time the esp_timer interrupt fires.) . I have the Control Task pinned to Core 1.
I also am using ESP-NOW (WiFi) on Core 0.
My problem is that when I initialize WiFi (on Core 0), the esp_timer interrupt is affected. It "jitters" by 100 us or more. (more than 20% error)
=> It appears that using ESP-NOW WiFi causes my 2 kHz timer interrupt to not be accurate.
Questions:
Can I run esp_timer() on Core 1 ONLY, so that it is not affected by the WiFi task(s) on Core 0?
Is there a way to configure the esp_timer, or the WiFi, so that the esp_timer is able to accurately run at 2 Khz?
Thanks!
Phil.
WiFi interfering with esp_timer High Resolution Timer
WiFi interfering with esp_timer High Resolution Timer
Last edited by plajjd on Sat Dec 22, 2018 5:00 am, edited 1 time in total.
Re: WiFi interfering with esp_timer High Resolution Timer
Also, it appears the ESP-NOW and/or WiFi libraries are running at a higher priority than the esp_timer task.
Is it possible to increase the priority of the esp_timer operation?
Is it possible to increase the priority of the esp_timer operation?
Re: WiFi interfering with esp_timer High Resolution Timer
Hi plajjd, at the moment there is no option to pin esp_timer task to CPU1, but you can move Wi-Fi task to CPU1 instead: https://docs.espressif.com/projects/esp ... sk-core-id
However, keep in mind that Wi-Fi driver also uses esp_timer for its own callbacks, which might need some time to execute. So the timing of your callbacks might be affected not only by the Wi-Fi task, but also by other timer callbacks. (To check whether this is the case you can use a tool such as SystemView to analyze task switching behavior.)
Another option is to use a separate timer interrupt, such as Timer Group timer interrupt, to trigger execution of your task.
However, keep in mind that Wi-Fi driver also uses esp_timer for its own callbacks, which might need some time to execute. So the timing of your callbacks might be affected not only by the Wi-Fi task, but also by other timer callbacks. (To check whether this is the case you can use a tool such as SystemView to analyze task switching behavior.)
Another option is to use a separate timer interrupt, such as Timer Group timer interrupt, to trigger execution of your task.
Re: WiFi interfering with esp_timer High Resolution Timer
Thank you! Using Timer Group 0 works much better than using esp_timer().
Are there any other subsystems that may be using Timer Group 0 that I should be aware of?
Also - does Timer Group 0 run on Core 0, or Core 1?
Are there any other subsystems that may be using Timer Group 0 that I should be aware of?
Also - does Timer Group 0 run on Core 0, or Core 1?
Re: WiFi interfering with esp_timer High Resolution Timer
No, Timer Group 0 timers aren't used by IDF components (aside from the timer group driver).
Interrupt will be called on the core where it is registered (i.e. esp_intr_alloc or timer_driver_install is called).
Interrupt will be called on the core where it is registered (i.e. esp_intr_alloc or timer_driver_install is called).
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 69 guests