LEGO Mindstorms EV3


Timer

Timer


Delay execution (500mS)

  DATA32  MyTimer                                 //  Declare your unique timer place holder

  TIMER_WAIT(500,MyTimer)                         //  Initialise your timer
  TIMER_READY(MyTimer)                            //  Wait for the time to expire - use VM power in other vmthreads

Check for timer timeout (500mS)

  DATA32  MyTimer                                 //  Declare your unique timer place holder
  DATA32  TmpTime                                 //  Need a working variable

  TIMER_READ(MyTimer)                             //  Initialise your timer
                                                  //
Loop:                                             //
                                                  //  Do the task until timeout
                                                  //
  TIMER_READ(TmpTime)                             //  Get the actual time
  SUB32(TmpTime,MyTimer,TmpTime)                  //  Calculate elapsed time
  JR_LT32(TmpTime,500,Loop)                       //  Compare it to the timeout time (500mS) and loop until expired

Check for small timer timeout (100uS)

  DATA32  MyTimer                                 //  Declare your unique timer place holder
  DATA32  TmpTime                                 //  Need a working variable

  TIMER_READ_US(MyTimer)                          //  Initialise your timer
                                                  //
Loop:                                             //
                                                  //  Do the task until timeout
                                                  //
  TIMER_READ_US(TmpTime)                          //  Get the actual time
  SUB32(TmpTime,MyTimer,TmpTime)                  //  Calculate elapsed time
  JR_LT32(TmpTime,100,Loop)                       //  Compare it to the timeout time (100uS) and loop until expired

LEGO® Robotics Firmware Documentation
Confidential Information © 2013 The LEGO Group