The cog will stop no matter what it's doing. The hardware for the cog gets turned off by the hub, the cog stops executing instructions and drops into a low power state.
Well, you could try re-starting the cog (after stopping it) if you believe stopping it is not working.
I accidently used "stop" as a "variable" once when it was clearly define as a method to stop a my cog.
That worked very well at stopping my pasm and causing me a great debug headache for a time [noparse]:)[/noparse]
Since·the cog is in an inifinite loop, I am assuming you are trying to shut down a cog externally. Cogid returns the cog number where executed, since this is external, it will not return the value you are looking for. The best way to get the cogid of cog that you want to stop is to grab the return value of cognew, it will be the cogid of the cog which was started up with the process pointed to in cognew. You can then use this number to stop the process at a later time.
>> jazzed, i don't understand how restarting a cog that hasn't stopped will tell anything.
Only that you can regain control. You can use coginit to restart a cog without using cogstop.
You might consider looking at some of the library objects as examples to emulate.
Here is a very simple flasher that uses start/stop following the library example.
{{
Very simple COG LED flasher object
}}
VAR
long cog
long stack[noparse][[/noparse]8]
PUB main
repeat
waitcnt(clkfreq+cnt)
stop
waitcnt(clkfreq+cnt)
start
PUB start
{{
Start the LED flashing
}}
stop ' many objects stop first to save the user trouble
result := cog := cognew(flash(1),@stack) + 1
waitcnt(clkfreq/10+cnt)
PUB stop
{{
Stop the cog
}}
if cog
cogstop(cog~ - 1)
PRI flash(bit)
{
Flash LED at bit number about 10x/second
}
dira[noparse][[/noparse]bit]~~ ' ensure set to output by new cog
repeat
!outa[noparse][[/noparse]bit]
waitcnt(clkfreq/10+cnt)
Comments
the cog will stop if its in a finite loop, but not in an infinite loop.
I accidently used "stop" as a "variable" once when it was clearly define as a method to stop a my cog.
That worked very well at stopping my pasm and causing me a great debug headache for a time [noparse]:)[/noparse]
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
Does this mean the Propeller's hub controller can solve the halting problem? [noparse];)[/noparse]
--Micah
still can't see what i'm doing wrong that i can't stop the cog in an infinite loop.
jazzed, i don't understand·how restarting a cog that hasn't stopped will tell anything.
paul, that is my intention. probably a syntax or indention problem.· i'll keep looking.
Only that you can regain control. You can use coginit to restart a cog without using cogstop.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
-Phil
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'Still some PropSTICK Kit bare PCBs left!
not to sure about proper use of coginit
Shouldn't that be ...
Otherwise you're getting the CogId of the one which launched 'drive' not CogId of 'drive'.
You might consider looking at some of the library objects as examples to emulate.
Here is a very simple flasher that uses start/stop following the library example.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔