Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Files

os.h/os_time.c

Prototype

Code Block
void  OSTimeDly (OS_TICK   dly,
                 OS_OPT    opt,
                 OS_ERR   *p_err)

Arguments

dly

is the desired delay expressed in number of clock ticks. Depending on the value of the opt field, delays can be relative or absolute.

...

A periodic delay means the period (in number of ticks). µC/OS-III saves the current time + dly in .TcikCtrPrevTickCtrPrev so the next time OSTimeDly() is called, we use .TickDlyPrev + dly.

An absolute delay means that the task will wake up when OSTickCtr reaches the value specified by dly.

...

Specifies a relative delay.

OS_OPT_TIME_TIMEOUT

Same as OS_OPT_TIME_DLY.

OS_OPT_TIME_PERIODIC

Specifies periodic mode.

...

If OS_CFG_ARG_CHK_EN is set to 1 in DEF_ENABLED in os_cfg.h: if a valid option is not specified.

OS_ERR_OS_NOT_RUNNING

If OS_CFG_INVALID_OS_CALLS_CHK_EN is set to DEF_ENABLED in os_cfg.h: if µC/OS-III is not running yet.

OS_ERR_SCHED_LOCKED

If the scheduler is locked.

OS_ERR_TIME_DLY_ISR

If OS_CFG_CALLED_FROM_ISR_CHK_EN set to 1 in DEF_ENABLED in os_cfg.h: if calling this function from an ISR.

...

Notes/Warnings

None

Example Usage

Code Block
titleOSTimeDly() example usage
          void TaskX (void *p_arg)
          {
            OS_ERR  err;
           
           
            while (DEF_ON) {
              :
              :
              OSTimeDly(10,
                        OS_OPT_TIME_PERIODIC,
                        &err);
              /* Check "err" */
              :
              :
            }
          }