In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Jon Williams wrote: Since delays are often needed and PAUSE and PAUSEUS take up a bit of code every time thery're used, I tend to have these subroutines in most of my SX/B programs... The declarations: WAIT_US SUB 1, 2 ' delay in microseconds WAIT_MS SUB 1, 2 ' delay in milliseconds And the code: ' Use: WAIT_US microseconds {, multiplier} ' -- multiplier is optional WAIT_US: temp1 = __PARAM1 ' get microseconds IF __PARAMCNT = 1 THEN ' if no multiplier temp2 = 1 ' set to 1 ELSE ' else temp2 = __PARAM2 ' get multiplier ENDIF IF temp1 > 0 THEN ' no delay if either 0 IF temp2 > 0 THEN PAUSEUS temp1 * temp2 ' do the delay ENDIF ENDIF RETURN ' Use: WAIT_MS milliseconds {, multiplier} ' -- multiplier is optional WAIT_MS: temp1 = __PARAM1 ' get milliseconds IF __PARAMCNT = 1 THEN ' if no multiplier temp2 = 1 ' set to 1 ELSE ' else temp2 = __PARAM2 ' get multiplier ENDIF IF temp1 > 0 THEN ' no delay if either 0 IF temp2 > 0 THEN PAUSE temp1 * temp2 ' do the delay ENDIF ENDIF RETURN ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=88882#m88890 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)