Using Timeout timer arduino UNO

Discussion in 'Embedded Systems and Microcontrollers' started by Vindhyachal Takniki, Aug 24, 2015.

  1. Vindhyachal Takniki

    Thread Starter Member

    Nov 3, 2014
    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:
    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?