Hello.
I've been searching and found many ways to do a timeout.
*** Obs. I Don't want to use millis, micros, interrupts or timers of any kind or external circuit. So don't bother suggesting it ***
I would like to implement something like:
.
.
.
noInterrupts(); // Something else needed?
unsigned long counter = n_cycles_value;
while (counter-- > 0) // or counter = 0 + while (counter++ < nnn)
{
asm("nop\n\t"); // 62.5ns at 16MHz
asm("nop\n\t");
asm("nop\n\t");
// + some nops else, upto the correct amount
}
.
.
.
In order to have a "programmable" predefined precise timeout loop.
The question: Do someone know how to, or can point out how can I obtain the "overhead" cycles time value of the while loop with the unsigned long variable incremented, in order to, adding the 'nop' instructions in a precise quantity, so I can have the timeout loop calculation to the most precise way (what I can get with the arduino ex. a nano) ?
Of course I could experiment with reasonable precision making tests and a chronometer.
That's my plan B
Thanks