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
Where can I find the documentation for esp_timer_get_time()?
-
- Posts: 9
- Joined: Thu Feb 28, 2019 8:28 pm
Re: Where can I find the documentation for esp_timer_get_time()?
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.
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.
-
- Posts: 9
- Joined: Thu Feb 28, 2019 8:28 pm
Re: Where can I find the documentation for esp_timer_get_time()?
Thanks, any do you have a sample on Github for this?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.
Who is online
Users browsing this forum: No registered users and 126 guests