If this were my puzzle, I'd probably follow this line of logic.
The CPU is executing at a constant processor clock rate ... lets call it C hz. That means that it ticks at C times per second or, each clock tick is 1/C seconds. Let us now assume that 1/C is faster than the delay you want to wait. For example, 1us = 1 / 1000000 of a second = 1MHZ clock rate. So your clock processor clock should be > 1 MHZ (which it is ... don't know the exact number off the top of my head).
In ESP32 assembler, there is a special register called CCOUNT that increments (internally and in the hardware) every processor clock cycle.
What this means is that each time CCOUNT increments, we know that 1/C seconds have passed. Now you can write some code that would (loosely) do the following.
Code: Select all
function delay(period) {
start = CCOUNT;
while (CCOUNT - start < period) {
// do nothing
}
}[
This would busy wait (waste) the cycles, but it should work. You might also have to disable some of the interrupts if you need absolutely delays no matter what. For example, you may be preempted by FreeRTOS.