esp_register_freertos_tick_hook() verus FreeRTOS vApplicationTickHook()
esp_register_freertos_tick_hook() verus FreeRTOS vApplicationTickHook()
Hi all
I need to setup a regular tick feature. The freeRTOS "vanilla" vApplicationTickHook() would work, but I see that the ESP-IDF provides it’s own time hook API (esp_register_freertos_tick_hook), one for each core. This seems like a better choice than the FreeRTOS option, but I can find very the little information on setting up the IDF versions (unless I've missed something in this forum - in which case I apologise for wasting your time) and none of the IDF examples seem to have code with the esp_register_freertos_tick_hook included.
so herewith:
1) I assume that esp_register_freertos_tick_hook() is setup in the configuration options, but which one/s?
2) I am assuming that the CONFIG_FREERTOS_HZ setting is for the freeRTOS "vanilla" vApplicationTickHook() and not the esp_register_freertos_tick_hook()? Or does it do both hooks, depending which one is activate / select?
3) I see that I can actively enable the CONFIG_FREERTOS_LEGACY_TICK_HOOK - does that mean that if this is not activated the ESP-IDF esp_register_freertos_tick_hook() is active?
4) Can I run esp_register_freertos_tick_hook() for each core concurrently?
5) and if yes, can I set a different tick frequency for each core?
many thanks
Frank
I need to setup a regular tick feature. The freeRTOS "vanilla" vApplicationTickHook() would work, but I see that the ESP-IDF provides it’s own time hook API (esp_register_freertos_tick_hook), one for each core. This seems like a better choice than the FreeRTOS option, but I can find very the little information on setting up the IDF versions (unless I've missed something in this forum - in which case I apologise for wasting your time) and none of the IDF examples seem to have code with the esp_register_freertos_tick_hook included.
so herewith:
1) I assume that esp_register_freertos_tick_hook() is setup in the configuration options, but which one/s?
2) I am assuming that the CONFIG_FREERTOS_HZ setting is for the freeRTOS "vanilla" vApplicationTickHook() and not the esp_register_freertos_tick_hook()? Or does it do both hooks, depending which one is activate / select?
3) I see that I can actively enable the CONFIG_FREERTOS_LEGACY_TICK_HOOK - does that mean that if this is not activated the ESP-IDF esp_register_freertos_tick_hook() is active?
4) Can I run esp_register_freertos_tick_hook() for each core concurrently?
5) and if yes, can I set a different tick frequency for each core?
many thanks
Frank
Re: esp_register_freertos_tick_hook() verus FreeRTOS vApplicationTickHook()
For the information about FreeRTOS hooks in ESP-IDF, please see https://docs.espressif.com/projects/esp ... html#hooks.
CONFIG_FREERTOS_HZ sets RTOS tick frequency. Same tick frequency is used for both CPUs, although ticks on the two CPUs are not synchronized. Both the traditional FreeRTOS hook and IDF per-CPU hooks are called from tick interrupt, therefore the frequency is CONFIG_FREERTOS_HZ on each core.
CONFIG_FREERTOS_HZ sets RTOS tick frequency. Same tick frequency is used for both CPUs, although ticks on the two CPUs are not synchronized. Both the traditional FreeRTOS hook and IDF per-CPU hooks are called from tick interrupt, therefore the frequency is CONFIG_FREERTOS_HZ on each core.
Re: esp_register_freertos_tick_hook() verus FreeRTOS vApplicationTickHook()
Thank you - that's much clearer. Much appreciated.
Frank
Frank
Re: esp_register_freertos_tick_hook() verus FreeRTOS vApplicationTickHook()
I am using "esp_register_freertos_idle_hook_for_cpu" to register my function to get called every 1ms.
Is this good way.
Thanks,
Naeem
Is this good way.
Thanks,
Naeem
Re: esp_register_freertos_tick_hook() verus FreeRTOS vApplicationTickHook()
Idle hooks are only a good solution if you have a function you'd like called when the CPU is idle, only.snahmad75 wrote:I am using "esp_register_freertos_idle_hook_for_cpu" to register my function to get called every 1ms.
Is this good way.
To get code which is called regularly you can use a FreeRTOS Timer:
https://docs.espressif.com/projects/esp ... Function_t
FreeRTOS timers will run at the RTOS tick rate, maximum.
If you need higher precision timers then you can use the esp_timer APIs:
https://docs.espressif.com/projects/esp ... timer.html
Re: esp_register_freertos_tick_hook() verus FreeRTOS vApplicationTickHook()
I can see esp_register_freertos_tick_hook_for_cpu or esp_register_freertos_tick_hook is not accurate for LED fading and increment or milliseconds count. we need accurate milliseconds counter. Do Esp32 have this already.
For LED on/off or fading every 1ms. This is not good enough.
Should I try use a FreeRTOS Timer then.
I did try higher precision timers then you can use the esp_timer APIs, but problem is esp timer queye gets overflow when I keep my CPU busy with hevy task like scan wifi access points or joining AP.
For LED on/off or fading every 1ms. This is not good enough.
Should I try use a FreeRTOS Timer then.
I did try higher precision timers then you can use the esp_timer APIs, but problem is esp timer queye gets overflow when I keep my CPU busy with hevy task like scan wifi access points or joining AP.
Re: esp_register_freertos_tick_hook() verus FreeRTOS vApplicationTickHook()
Why not just use the LED_PWM controller?snahmad75 wrote:For LED on/off or fading every 1ms. This is not good enough.
Re: esp_register_freertos_tick_hook() verus FreeRTOS vApplicationTickHook()
ok, will try out and let you know.
Re: esp_register_freertos_tick_hook() verus FreeRTOS vApplicationTickHook()
I am using led_pwm controller.
I do ledc_fade_func_install.
but I need to call below functions every 1ms.
ledc_set_duty();
ledc_update_duty()
In which Task/thread can I do it. I was using esp timer. I avoid using est timer. queue gets overflow when cpu gets busy.
I do ledc_fade_func_install.
but I need to call below functions every 1ms.
ledc_set_duty();
ledc_update_duty()
In which Task/thread can I do it. I was using esp timer. I avoid using est timer. queue gets overflow when cpu gets busy.
Re: esp_register_freertos_tick_hook() verus FreeRTOS vApplicationTickHook()
Maybe use the timer peripheral to generate sub millisecond interrupts, then modify ledc pwm in an ISR?snahmad75 wrote:but I need to call below functions every 1ms.
Who is online
Users browsing this forum: No registered users and 94 guests