Page 1 of 1

Finding source code for esp_timer_get_time()

Posted: Thu Jul 30, 2020 2:50 pm
by damithpavithra
Hello
I want to find the source code (Not the header file) for the esp_timer_get_time() function.
I am using Arduino IDE to program ESP32. I searched for this function in entire ESP32 core folder, but only found the esp_timer.h file which only have the definition. Please give me a reference to find the source code.
Is it OK to use esp_timer_get_time() function in multiple tasks/cores without any mutual exclusion?.
Thank you

Re: Finding source code for esp_timer_get_time()

Posted: Fri Jul 31, 2020 3:49 am
by GE_Rita
Hi, damithpavithra

I have not found its path on my Pc exactly.
It may be compiled into any (.a) file or something. Like here.https://github.com/espressif/esp-face/issues/29
But what I find is its open document. https://github.com/espressif/esp-idf/bl ... sp_timer.c
And funcions introduction.https://lang-ship.com/reference/ESP32/l ... 981faa2370
Hope it can help.

Re: Finding source code for esp_timer_get_time()

Posted: Fri Jul 31, 2020 5:19 am
by damithpavithra
Hi GE_Rita

Thank you for the reply. Seems like they pre compiled those into .a files. Dont know why they do that.
It would be really helpful to debug and learn the device if there are uncompiled source files.
https://github.com/espressif/esp-idf/bl ... sp_timer.c only have three lines which uses the function output. Not its source code.
Any idea on mutual exclusivity of the timer function?

Thank you.

Re: Finding source code for esp_timer_get_time()

Posted: Fri Jul 31, 2020 7:37 am
by ESP_Sprite
Where that function is defined depends a bit on the specific hardware timer that it's selected to use... I think by default it's timer group 0, in case the function is aliased to esp_timer_impl_get_time here, with that function defined just above that. (Note that this is for 4.2, other versions may handle this slightly different)

Re: Finding source code for esp_timer_get_time()

Posted: Fri Jul 31, 2020 7:50 am
by damithpavithra
Hello ESP_Sprite

Thank you for the help. Can you please answer this also.
I think version 4.2 is included in the latest ESP32 arduino core, right?.
Currently arduino millis function use this to get the time.
Millis is used all over the arduino. Is it ok to use millis in multiple tasks without mutual exclusivity?.
I also use a timer interrupt attached to timer 0. Is this somehow affect the millis.?

Thank you

Re: Finding source code for esp_timer_get_time()

Posted: Fri Jul 31, 2020 9:52 am
by ESP_Sprite
Yes, that code should be re-entrant. You can also use timer0 for other purposes, esp_timer uses a legacy subsystem of the timer groups that is not usually used/usable by other code.