esp_register_freertos_tick_hook() verus FreeRTOS vApplicationTickHook()

frankket
Posts: 5
Joined: Mon May 14, 2018 7:14 pm

esp_register_freertos_tick_hook() verus FreeRTOS vApplicationTickHook()

Postby frankket » Tue Jun 19, 2018 6:28 pm

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

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: esp_register_freertos_tick_hook() verus FreeRTOS vApplicationTickHook()

Postby ESP_igrr » Tue Jun 19, 2018 11:38 pm

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.

frankket
Posts: 5
Joined: Mon May 14, 2018 7:14 pm

Re: esp_register_freertos_tick_hook() verus FreeRTOS vApplicationTickHook()

Postby frankket » Wed Jun 20, 2018 7:35 pm

Thank you - that's much clearer. Much appreciated.

Frank

snahmad75
Posts: 445
Joined: Wed Jan 24, 2018 6:32 pm

Re: esp_register_freertos_tick_hook() verus FreeRTOS vApplicationTickHook()

Postby snahmad75 » Wed Oct 24, 2018 7:38 pm

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

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: esp_register_freertos_tick_hook() verus FreeRTOS vApplicationTickHook()

Postby ESP_Angus » Thu Oct 25, 2018 5:35 am

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.
Idle hooks are only a good solution if you have a function you'd like called when the CPU is idle, only.

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

snahmad75
Posts: 445
Joined: Wed Jan 24, 2018 6:32 pm

Re: esp_register_freertos_tick_hook() verus FreeRTOS vApplicationTickHook()

Postby snahmad75 » Thu Oct 25, 2018 9:46 am

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.

ESP_Dazz
Posts: 308
Joined: Fri Jun 02, 2017 6:50 am

Re: esp_register_freertos_tick_hook() verus FreeRTOS vApplicationTickHook()

Postby ESP_Dazz » Thu Oct 25, 2018 1:16 pm

snahmad75 wrote:For LED on/off or fading every 1ms. This is not good enough.
Why not just use the LED_PWM controller?

snahmad75
Posts: 445
Joined: Wed Jan 24, 2018 6:32 pm

Re: esp_register_freertos_tick_hook() verus FreeRTOS vApplicationTickHook()

Postby snahmad75 » Thu Oct 25, 2018 4:32 pm

ok, will try out and let you know.

snahmad75
Posts: 445
Joined: Wed Jan 24, 2018 6:32 pm

Re: esp_register_freertos_tick_hook() verus FreeRTOS vApplicationTickHook()

Postby snahmad75 » Fri Oct 26, 2018 10:39 am

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.

ESP_Dazz
Posts: 308
Joined: Fri Jun 02, 2017 6:50 am

Re: esp_register_freertos_tick_hook() verus FreeRTOS vApplicationTickHook()

Postby ESP_Dazz » Mon Oct 29, 2018 6:29 am

snahmad75 wrote:but I need to call below functions every 1ms.
Maybe use the timer peripheral to generate sub millisecond interrupts, then modify ledc pwm in an ISR?

Who is online

Users browsing this forum: Majestic-12 [Bot], Teh2024 and 147 guests