Using Timeout timer arduino UNO

Thread Starter

Vindhyachal Takniki

Joined Nov 3, 2014
594
1. 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)
{
}

2. problem with this approach may be:
a) it rolls off after 50 days as here:https://www.arduino.cc/en/Reference/Millis
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.


3. What is best way to do this?
 
Top