- I have to use timeout method in program. E.g if for 10ms particular task does not happen then timeout.One method is to do this:
unsigned long DelayTimeOut;
DelayTimeOut = millis() + 1000; /* 1 sec timeout */
while (millis() < DelayTimeOut)
{
}
- problem with this approach may be:
a) it rolls off after 50 days as here:millis() - Arduino Reference
Also micro() rolls off in 70 minutes. So it will provide error in case of roll off.
b) second this approac, calls millis(), regularly, it reads atomic value of internal counter overflow everytime.
Is it a good idea that it a loop continuoulsy interrupts are switched on/off.
- What is best way to do this?