PAUSE Example | Syntax |
' ------------------------------------------------------------------------- ' Program Description ' ------------------------------------------------------------------------- ' ' Variable-rate LED blinker. Puts PAUSE into a subroutine for greatest ' flexibility and program space conservation. ' ------------------------------------------------------------------------- ' Device Settings ' ------------------------------------------------------------------------- DEVICE SX28, OSC4MHZ, TURBO, STACKX, OPTIONX FREQ 4_000_000 ID "PAUSE" ' ------------------------------------------------------------------------- ' IO Pins ' ------------------------------------------------------------------------- Led VAR RB.0 ' ------------------------------------------------------------------------- ' Variables ' ------------------------------------------------------------------------- idx VAR Byte ' loop counter timing VAR Word tmpW1 VAR Word ' for subroutines ' ========================================================================= PROGRAM Start ' ========================================================================= ' ------------------------------------------------------------------------- ' Subroutine Declarations ' ------------------------------------------------------------------------- DELAY SUB 1, 2 ' delay in milliseconds ' ------------------------------------------------------------------------- ' Program Code ' ------------------------------------------------------------------------- Start: DO FOR idx = 1 TO 10 ' loop 1 to 10 HIGH Led ' LED on timing = 50 * idx ' calculate on timing DELAY timing ' pause 50 to 500 ms LOW Led ' LED off timing = 50 * idx DELAY timing NEXT LOOP ' ------------------------------------------------------------------------- ' Subroutine Code ' ------------------------------------------------------------------------- ' Use: DELAY ms ' -- 'ms' is delay in milliseconds, 1 - 65535 DELAY: IF __PARAMCNT = 1 THEN tmpW1 = __PARAM1 ' save byte value ELSE tmpW1 = __WPARAM12 ' save word value ENDIF PAUSE tmpW1 RETURN