esp_timer consumes 50% of CPU time, please help
Posted: Sat May 11, 2024 11:15 am
Hello all!
I ran into a speed issue with my code. So I gathered the info on all tasks and noticed that the task esp_timer is consuming about half of the available CPU time. See stats here:
My timer tick is set to 100 Hz as I need only time intervals in the range of 10ms to a few minutes.
In the timer callback all I do is put a message on a queue, which is later handled in a task, like this:
In order to monitor how often the timer puts a message on the queue, I put some log outputs on the timer event handling in the task. As normally expected they hardly ever get called and cannot explain the high CPU load of the esp_timer.
What can I do to reduce the load of esp_timer on the CPU?
What are the typical reasons for such load?
Thanks a lot!
cheers
JRA
I ran into a speed issue with my code. So I gathered the info on all tasks and noticed that the task esp_timer is consuming about half of the available CPU time. See stats here:
Code: Select all
W (587604) AUDIOBOX: # task name core free stack run time in %%
W (587614) AUDIOBOX: 0 AudioTask 1 13856 373664 <1%
W (587614) AUDIOBOX: 1 main 0 2056 463896 <1%
W (587614) AUDIOBOX: 2 IDLE 1 936 585918953 99%
W (587634) AUDIOBOX: 3 IDLE 0 928 274725393 46%
W (587634) AUDIOBOX: 4 esp_periph 0 2316 2387659 <1%
W (587634) AUDIOBOX: 5 Tmr Svc 0 160 924679 <1%
W (587634) AUDIOBOX: 6 file 0 2176 268981 <1%
W (587634) AUDIOBOX: 7 mp3 0 3892 2513101 <1%
W (587634) AUDIOBOX: 8 filter 0 2960 1114041 <1%
W (587634) AUDIOBOX: 9 i2s 0 2640 599156 <1%
W (587634) AUDIOBOX: 10 ipc0 0 952 8576 <1%
W (587644) AUDIOBOX: 11 hciT 0 1568 504208 <1%
W (587644) AUDIOBOX: 12 BTU_TASK 0 2964 752456 <1%
W (587644) AUDIOBOX: 13 BTC_TASK 0 1508 355212 <1%
W (587644) AUDIOBOX: 14 btController 0 2016 5001571 <1%
W (587644) AUDIOBOX: 15 esp_timer 0 3324 296709377 50%
W (587644) AUDIOBOX: 16 input_key_servi 1 2472 68 <1%
In the timer callback all I do is put a message on a queue, which is later handled in a task, like this:
Code: Select all
err = xQueueSend( queue_toStateMachine, ( void * ) &outMsg, ( TickType_t ) 2 );
What can I do to reduce the load of esp_timer on the CPU?
What are the typical reasons for such load?
Thanks a lot!
cheers
JRA