Hi, i'm creating a project that requires, in multiple blocks of code, to check the actual micros() value. The question is: which aproach is better?
(1) Call micros() only once, save the returned value in an unsigned long and then read this value every time i need it... or...
(2) directly call micros() every time it's needed.
If you use the first option, every TIMER can use the same value.
This might be what is required to synchronize events to the same captured time.
However, I have never run across this need.
Your sketch will probably be a bit faster to read this time once per loop() iteration but there again the faster execution will be microseconds at most.
limonrojo:
Wihich one gives less computational effort terms?
If you save the value of micros() then all tests will use the same value. But that may mean that the time value being used is several microsecs behind the actual time. You have not said whether that would matter.