Page 1 of 1

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

Posted: Fri Dec 23, 2016 11:27 am
by gearwalker
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!

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

Posted: Fri Dec 23, 2016 11:40 am
by ESP_igrr
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();

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

Posted: Fri Dec 23, 2016 11:54 am
by gearwalker
Many thanks! :-D