Name:
end
Syntax:

END

Description:

Sleep terminally until the power cycles (program re-runs) or the PC connects for a new download.

Power is reduced to an absolute minimum (assuming no loads are being driven) and internal timers are switched off. The end command places the microcontroller into low power mode after a program has finished. Note that as the compiler always places an end instruction after the last line of a program, this command is rarely required. The end command switches off internal timers, and so commands such as servo and pwmout that require these timers will not function after an end command has been completed.

If you do not wish the end command to be carried out, place a ‘stop’ command at the bottom of the program. The stop command does not enter low power mode. The main use of the end command is to separate the main program loop from sub-procedures as in the example below. This ensures that programs do not accidentally ‘fall into’ the sub-procedure.

Applies To:
All
See Also:
Related Create:
    Share:
    Print:

    Call a gosub subroutine

    Flash an LED multiple times using a gosub subroutine

    Code Example:
    main:	let b2 = 15		; set b2 value
    	pause 2000		; wait for 2 seconds
    	gosub flsh		; call sub-procedure
    	let b2 = 5		; set b2 value
    	pause 2000		; wait for 2 seconds
    	end			; stop accidentally falling into sub
    
    flsh:	for b0 = 1 to b2	; define loop for b2 times
    	  high B.1		; switch on output B.1
    	  pause 500		; wait 0.5 seconds
    	  low B.1		; switch off output B.1
    	  pause 500		; wait 0.5 seconds
    	next b0			; end of loop
    	return			; return from sub-procedure
    Copy Code Submit an Example

    Submit Your Own Code!

    You must be logged in to submit code examples. Login now.

    Comments

    • Login to leave a comment.