What is the most accurate way of determining the time between two interrupt events?

olney_one
Posts: 5
Joined: Mon Sep 16, 2024 9:28 pm

What is the most accurate way of determining the time between two interrupt events?

Postby olney_one » Mon Sep 16, 2024 9:52 pm

I am new to ESP32s. I have an application that generates two interrupts on separate GPIO lines. Accessing timestamps for real time seems to be an integer. Would using this in conjunction with a CPU clock tick count be the most accurate way of measuring the interval? Or is there a better way?

MicroController
Posts: 1734
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: What is the most accurate way of determining the time between two interrupt events?

Postby MicroController » Tue Sep 17, 2024 7:06 am

esp_timer_get_time() and esp_cpu_get_cycle_count() are probably the best option.
The CPU cycle count is 32 bits, so at 240MHz you can measure intervals up to ~17.9 seconds using this counter alone.

olney_one
Posts: 5
Joined: Mon Sep 16, 2024 9:28 pm

Re: What is the most accurate way of determining the time between two interrupt events?

Postby olney_one » Tue Sep 17, 2024 7:50 pm

Thank you, I will try this.

olney_one
Posts: 5
Joined: Mon Sep 16, 2024 9:28 pm

Re: What is the most accurate way of determining the time between two interrupt events?

Postby olney_one » Thu Sep 19, 2024 8:56 am

This works really well and is extremely fast. Thank you again.

Who is online

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