am i doing "cogstop" correctly?
im not sure if im referencing the cogstop correctly. when i press the pushbutton it stops the green led. im guessing that it is stopping the cog that contains the command "cogstop" instead of the red led , the one im trying to reference.what am i doing wrong?
{Object_Title_and_Purpose}
CON
_clkmode = xtal1 + pll16x 'Standard clock mode * crystal frequency = 80 MHz
_xinfreq = 5_000_000
VAR
long stack[100]
pub main
dira[8]~~
dira[2]~
cognew (led,@stack)
repeat
!outa[8] 'flash green led
waitcnt(clkfreq/2+cnt)
if ina[2]==0 'if button is pushed stop red led
cogstop (led)
pub led
dira[9]~~
repeat
!outa[9] 'flash red led
waitcnt(clkfreq/2+cnt)

Comments
{Object_Title_and_Purpose} CON _clkmode = xtal1 + pll16x 'Standard clock mode * crystal frequency = 80 MHz _xinfreq = 5_000_000 VAR long stack[100], c pub main dira[8]~~ dira[2]~ c:= cognew (led,@stack) repeat !outa[8] 'flash green led waitcnt(clkfreq/2+cnt) if ina[2]==0 'if button is pushed stop red led cogstop (c) pub led dira[9]~~ repeat !outa[9] 'flash red led waitcnt(clkfreq/2+cnt)That should fix it. Making c = to the cog called allows you sotp the cog with cogstop(c). Hope this helps!Where does one get a cogs ID from? Well cognew returns the cog ID of the cog it started. So use something like
redCogId = cognew (led, @stack);
then use
cogstop(redCogId);
Check the manual for details of how this all works.