problems using ESP.getCycleCount to measure intervals

ArjayV
Posts: 1
Joined: Tue Mar 13, 2018 11:03 pm

problems using ESP.getCycleCount to measure intervals

Postby ArjayV » Thu Mar 15, 2018 1:32 am

I'm trying to measure some intervals that are too fast for the micros() function. So I want to use the clock cycle count (using ESP.getCycleCount) as the basis of my timing measurements. I ran a few tests to determine how feasible this approach is and the results weren't encouraging. Unfortunately, it seems that getCycleCount doesn't always take the same amount of time. But hopefully I'm doing something wrong.

My first test involved calling digitalRead followed by getCycleCount four times, storing the cycle count in a different variable each time. (Each digitalRead occurred on a different pin.) I expected the splits to be roughly the same, but they were wildly different. The same split across multiple runs was roughly the same, though. The following numbers are representative:
  • count2 - count1: 588
  • count3 - count2: 52
  • count4 - count3: 332
I then ran some tests using my oscilloscope. Basically digitalRead and getCycleCount calls sandwiched between digitalWrite High/Low pairs. Again I got wildly varying results - from as low as .3 microseconds to as long as 3.7 us. Doing just getCycleCount alone between the output pulses produced similar results.

Any ideas?

larissadj
Posts: 4
Joined: Thu Apr 04, 2019 12:15 pm

Re: problems using ESP.getCycleCount to measure intervals

Postby larissadj » Thu Apr 04, 2019 12:37 pm

Can you show me please how you're using this fonction ESP.getCycleCount in your code? I am new in ESP32 und i have tried to use it, but a Fehler is occured by Compiling.

Who is online

Users browsing this forum: No registered users and 53 guests