Consider having a task pinned to core 1, running with no interrupts.
Inside of it, a routine is called, basically as the example below:
Code: Select all
...
unsigned long IRAM_ATTR myLoop(int64_t us)
{
register unsigned long count = 0L;
int64_t m = esp_timer_get_time() + us;
while (esp_timer_get_time() < m)
{
count++;
}
return count;
}
...
Question: the ESP32 is running at 240 MHz, the sole uninterrupted task in core 1 should be running at 240 MHz; Why am I getting a loop performance near to 1 MHz ? does esp_timer_get_time() takes many tenths to hundredths of cycles to execute?
I was expecting the count variable to be incremented many many times faster than that.
Am I missing something here? I was hoping to have, say, 20 counts per microsecond. Or something far from "1.35"...
In time:
I tested a modification of the above loop, where I did:
Code: Select all
while (esp_timer_get_time() < m)
{
count++;
asm(" nop");
asm(" nop");
asm(" nop");
asm(" nop");
asm(" nop");
asm(" nop");
asm(" nop");
asm(" nop");
asm(" nop");
asm(" nop");
}
Can this be improved? Is the esp_timer_get_time code being run from flash or something like it?
Thanks