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
high precision timer
Re: high precision timer
I recently stumbled upon this repo:
https://github.com/botofancalin/M5Stack ... cilloscope
Might find some info there.
https://github.com/botofancalin/M5Stack ... cilloscope
Might find some info there.
-
- Posts: 39
- Joined: Tue Mar 20, 2018 6:28 pm
Re: high precision timer
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;
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 141 guests