How the most finest 'tick count' I can get from ESP32 ?

gearwalker
Posts: 5
Joined: Thu Dec 08, 2016 1:10 pm

How the most finest 'tick count' I can get from ESP32 ?

Postby gearwalker » Fri Dec 23, 2016 11:27 am

Hello,

As the topic, I wanna get finest ticks from the system. Currently I can get ticks from FreeRTOS but resolution is not enough. I wonder that we can get something like 'Execution tick count' by some ways.

Thank you!

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: How the most finest 'tick count' I can get from ESP32 ?

Postby ESP_igrr » Fri Dec 23, 2016 11:40 am

1. gettimeofday function. With default settings in menuconfig, gives you time at microsecond resolution. Timekeeping continues in deepsleep (but there is a bug in the current master branch which causes time to be reset when going to deep sleep; follow above link for a workaround).

2. CCOUNT CPU register (one on each CPU). Gives you number of CPU cycles since CPU has started. Counts ticks, so doesn't account for CPU frequency changes (not a problem now, but may be once we implement D(V)FS). Counters of the two CPUs are not synchronized in any way, so take care if your task has no CPU affinity.

Code: Select all

#include "xtensa/core-macros.h"
uint32_t ccount = XTHAL_GET_CCOUNT();

gearwalker
Posts: 5
Joined: Thu Dec 08, 2016 1:10 pm

Re: How the most finest 'tick count' I can get from ESP32 ?

Postby gearwalker » Fri Dec 23, 2016 11:54 am

Many thanks! :-D

Who is online

Users browsing this forum: Gaston1980 and 105 guests