Where can I find the documentation for esp_timer_get_time()?

akashdeepsingh
Posts: 9
Joined: Thu Feb 28, 2019 8:28 pm

Where can I find the documentation for esp_timer_get_time()?

Postby akashdeepsingh » Sat Mar 02, 2019 10:52 pm

Hi,

I am looking to get time with nanoseconds precision. I know the function esp_timer_get_time() gives time in microseconds. I was hoping that I can modify it. Where can I find the source code/documentation to how it works.?

Thanks

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

Re: Where can I find the documentation for esp_timer_get_time()?

Postby ESP_igrr » Sun Mar 03, 2019 1:13 am

The source code along with some inline comments is here: https://github.com/espressif/esp-idf/bl ... er_esp32.c

esp_timer_impl_get_time in this file is the actual implementation of esp_timer_get_time.

Although if you only need to get current time in nanoseconds, and supporting DFS is not a concern, an implementation based on one of the Timer Group timers will be way more straightforward. This is because timer group timers are 64 bit, so you can ignore the issue of overflows (for 7.5 thousand years, at least).
That implementation is going to be, basically: start the timer with a prescaler of 1, and when you need to know the value of time in nanoseconds, read the counter and multiply by 12.5ns.

akashdeepsingh
Posts: 9
Joined: Thu Feb 28, 2019 8:28 pm

Re: Where can I find the documentation for esp_timer_get_time()?

Postby akashdeepsingh » Sun Mar 03, 2019 5:38 am

That implementation is going to be, basically: start the timer with a prescaler of 1, and when you need to know the value of time in nanoseconds, read the counter and multiply by 12.5ns.
Thanks, any do you have a sample on Github for this?

Who is online

Users browsing this forum: Bing [Bot] and 167 guests