high precision timer

Reiner1210
Posts: 39
Joined: Tue Mar 20, 2018 6:28 pm

high precision timer

Postby Reiner1210 » Mon Apr 02, 2018 10:42 pm

Hello,

I know that with esp_timer_get_time() I can get a timestamp on µsec base. Is there an even better time base resolution possible? Idea behind: Build a low budget logic analyzer. For this the edges of a signal must have very exact timestamps.
An other question: What is the highest frequency on a GPIO input which should trigger an interrupt. Can I go up to some MHz ?

Reiner

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: high precision timer

Postby WiFive » Mon Apr 02, 2018 10:55 pm


Cellie
Posts: 45
Joined: Sat Feb 27, 2016 9:47 pm

Re: high precision timer

Postby Cellie » Tue Apr 03, 2018 7:25 am

I recently stumbled upon this repo:
https://github.com/botofancalin/M5Stack ... cilloscope
Might find some info there.

Reiner1210
Posts: 39
Joined: Tue Mar 20, 2018 6:28 pm

Re: high precision timer

Postby Reiner1210 » Fri Apr 06, 2018 9:12 am

Thanks @WiFive

The following pseudo code will do it

#include "soc/cpu.h"
#include "esp_clk.h"

uint32_t cycle_counts;
uint32_t cycle_counts_last = 0;
int clock_freq = esp_clk_cpu_freq();

RSR(CCOUNT, cycle_counts);
printf("Diff: %llu nsec\n", ((uint64_t)(cycle_counts - cycle_counts_last)*1000000000) / clock_freq);
cycle_counts_last = cycle_counts;

Who is online

Users browsing this forum: No registered users and 160 guests