Cogs and Objects returning situacion
HED GROUP
Posts: 15
{{
Hi to everybody can somebody explain us why if we use more than one cog
and call a endless method in the main program the program continue and
cog 2 and 3 blinks led 16 and 23 with led 19 bliking faster.
BUT? if you run the same program using the same method P2 and P3 from a
different object (test1)the first cog (2) run and blink led 16 but the program
stay in that endless method and don't continue with the next instruction.
Is like never return to cog 0 when the cog 2 run it's method from another
object. (Cogs runnig in the same main program have no problem. Cogs runnig
an endless method from another object never return from the first cog - Why ???.
}}
CON
· _clkmode = xtal1+pll16x
· _xinfreq = 5_000_000
VAR
· LONG· cog2ram[noparse][[/noparse]64]
· LONG· cog3ram[noparse][[/noparse]64]
OBJ
· lcd : "TEST1"
PUB Init
COGINIT(2,P2,@COG2ram) ''Blink led 16
COGINIT(3,P3,@COG3ram) ''Blink led 23
DIRa[noparse][[/noparse]19]~~
REPEAT
·!OUTa[noparse][[/noparse]19] ''Blink led 19
·waitcnt(clkfreq / 20 + cnt)
{{===============================================
· COPY ALSO THE FOLLOWING METHODS TO "TEST1" FILE
· Remplace the 2 cogs lines with the following:
· COGINIT(2,lcd.P2,@COG2ram)
· COGINIT(3,lcd.P3,@COG3ram)
· ===============================================
}}
··
PUB P2
DIRa[noparse][[/noparse]16]~~
REPEAT
·!OUTa[noparse][[/noparse]16] ''Blink led 16
·waitcnt(clkfreq + cnt)
···
PUB P3
DIRa[noparse][[/noparse]23]~~
REPEAT
·!OUTa[noparse][[/noparse]23] ''Blink led 23
·waitcnt(clkfreq + cnt)
·
Hi to everybody can somebody explain us why if we use more than one cog
and call a endless method in the main program the program continue and
cog 2 and 3 blinks led 16 and 23 with led 19 bliking faster.
BUT? if you run the same program using the same method P2 and P3 from a
different object (test1)the first cog (2) run and blink led 16 but the program
stay in that endless method and don't continue with the next instruction.
Is like never return to cog 0 when the cog 2 run it's method from another
object. (Cogs runnig in the same main program have no problem. Cogs runnig
an endless method from another object never return from the first cog - Why ???.
}}
CON
· _clkmode = xtal1+pll16x
· _xinfreq = 5_000_000
VAR
· LONG· cog2ram[noparse][[/noparse]64]
· LONG· cog3ram[noparse][[/noparse]64]
OBJ
· lcd : "TEST1"
PUB Init
COGINIT(2,P2,@COG2ram) ''Blink led 16
COGINIT(3,P3,@COG3ram) ''Blink led 23
DIRa[noparse][[/noparse]19]~~
REPEAT
·!OUTa[noparse][[/noparse]19] ''Blink led 19
·waitcnt(clkfreq / 20 + cnt)
{{===============================================
· COPY ALSO THE FOLLOWING METHODS TO "TEST1" FILE
· Remplace the 2 cogs lines with the following:
· COGINIT(2,lcd.P2,@COG2ram)
· COGINIT(3,lcd.P3,@COG3ram)
· ===============================================
}}
··
PUB P2
DIRa[noparse][[/noparse]16]~~
REPEAT
·!OUTa[noparse][[/noparse]16] ''Blink led 16
·waitcnt(clkfreq + cnt)
···
PUB P3
DIRa[noparse][[/noparse]23]~~
REPEAT
·!OUTa[noparse][[/noparse]23] ''Blink led 23
·waitcnt(clkfreq + cnt)
·
Comments
http://forums.parallax.com/forums/default.aspx?f=25&m=331701&g=331706#m331706
Mike Green's comment is the one to consider carefully.
Cheers!
Paul Rowntree
Here is a way to accomplish what you want to do...
MainTest.spin
TEST1.spin
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Post Edited (Beau Schwabe (Parallax)) : 3/7/2009 5:57:14 AM GMT