pin timer callback to specific core?

ffrige
Posts: 22
Joined: Thu Oct 15, 2020 3:44 am

pin timer callback to specific core?

Postby ffrige » Tue Apr 13, 2021 9:13 am

I normally pin a task to a specific core using xTaskCreatePinnedToCore.

Now I need to execute the content of a high-speed timer callback on core 1, but I cannot find any way to do that by looking at the docs for esp_timer_create.

I could leave the callback on core 0 and just use it to send a notification to a task running on core 1. But I don't know if the notification process is fast/precise enough? I'm hoping to run that code every 100us with as small jitter as possible. Are there better ways to do that?

ESP_Sprite
Posts: 9014
Joined: Thu Nov 26, 2015 4:08 am

Re: pin timer callback to specific core?

Postby ESP_Sprite » Wed Apr 14, 2021 1:12 am

From what I call, the esp_timer subsystem does callbacks from its own task; it may be configurable in Menuconfig on what core it runs.

Esp_timer is a shared resource as in: if something else has scheduled a callback at the same time as your program, your callback could be delayed until the earlier callback has finished. If you truly need low-latency at all times, you might be better off using one of the hardware timers.

ffrige
Posts: 22
Joined: Thu Oct 15, 2020 3:44 am

Re: pin timer callback to specific core?

Postby ffrige » Wed Apr 14, 2021 9:07 am

Ah, thank you, I will try using a hardware timer then instead of the esp_timer.

But in terms of what core the ISR runs on, does that make any difference? I still need a way to run the callback on core 1.

The documentation for the timer_isr_register function is not clear to me:
Register Timer interrupt handler, the handler is an ISR. The handler will be attached to the same CPU core that this function is running on.
Does that mean that I have to create a task on core 1 just to call this timer_isr_register function?

The example on github does not even use this function: it uses the timer_isr_callback_add instead. What is the difference? Should I call this timer_isr_callback_add from a task in core1?
https://github.com/espressif/esp-idf/bl ... ple_main.c

Who is online

Users browsing this forum: No registered users and 89 guests