Propeller Manual

Table Of Contents
2: Spin Language Reference – COGSTOP
COGSTOP
Command: Stop cog by its ID.
((PUB PRI))
COGSTOP (CogID )
CogID is the ID (0 – 7) of the cog to stop.
Explanation
COGSTOP stops a cog whose ID is CogID and places that cog into a dormant state. In the
dormant state, the cog ceases to receive System Clock pulses so that power consumption is
greatly reduced.
To stop a cog, issue the COGSTOP command with the ID of the cog to stop. For example:
VAR
byte Cog 'Used to store ID of newly started cog
PUB Start(Pos) : Pass
'Start a new cog to run Update with Pos,
'return TRUE if successful
Pass := (Cog := cognew(@Update, Pos) + 1) > 0
PUB Stop
'Stop the cog we started earlier, if any.
if Cog
cogstop(Cog~ - 1)
This example, from the COGNEW description, uses COGSTOP in the public Stop method to stop
the cog that was previously started by the
Start method. See COGNEW, page 78, for more
information about this example.
Propeller Manual v1.1 · Page 83