How to wait for a period of time using a timer

  • version

    1.1.1

  • scope

    Example.

    This code is provided as example code for a user to base their code on.

  • description

    How to wait for a period of time using a timer

  • boards

    Unless otherwise specified, this example runs on the SliceKIT Core Board, but can easily be run on any XMOS device by using a different XN file.

Timers can be used to pause a task until a certain amount of time has passed. First input the current time from the timer:

t :> start_time;

Next compute the time you want the task to wait until, by adding the desired number of timer ticks to the start time:

end_time = start_time + 123;

Finally use the following statement to wait for end_time to be reached:

t when timerafter(end_time) :> void;