am i doing "cogstop" correctly?
mikea
Posts: 283
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
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.