Problems with SPIN Code
comsol
Posts: 7
Hello all folks,
I write the following code:
{{ Output.spin }}
VAR
long StackToggle24[noparse][[/noparse]18] 'Stack space for new cog
long StackToggle26[noparse][[/noparse]18] 'Stack space for new cog
OBJ
T24 : "Toggle24"
T26 : "Toggle26"
PUB Main
{{Start new blinking process in new cog}}
cognew(T24.Toggle24, @StackToggle24)
cognew(T26.Toggle26, @StackToggle26)
'the same result
'T26.Toggle26
'T24.Toggle24
'And I create two objects:
'Toggle24.spin
'and Toggle26.spin
PUB Toggle24
{{Toggle Pin, Count times with DelayMS milliseconds in between. If Count = 0, toggle Pin forever.}}
dira[noparse][[/noparse]24]~~ 'Set I/O pin to output direction
repeat
'Repeat for Count iterations
!outa[noparse][[/noparse]24] ' Toggle I/O Pin
waitcnt(4_000_000 + cnt) ' Wait for Delay cycles 'Clear Cog ID variable
PUB Toggle26
{{Toggle Pin, Count times with DelayMS milliseconds in between. If Count = 0, toggle Pin forever.}}
dira[noparse][[/noparse]26]~~ 'Set I/O pin to output direction
repeat 'Repeat for Count iterations
!outa[noparse][[/noparse]26] ' Toggle I/O Pin
waitcnt(4_000_000 + cnt) ' Wait for Delay cycles 'Clear Cog ID variable
the chip switched not from one cog to other
only the first object method a execute.
What's wrong please help me???
Best Regards: Uwe Reinersmann
Post Edited By Moderator (Chris Savage (Parallax)) : 6/4/2007 8:04:52 PM GMT
I write the following code:
{{ Output.spin }}
VAR
long StackToggle24[noparse][[/noparse]18] 'Stack space for new cog
long StackToggle26[noparse][[/noparse]18] 'Stack space for new cog
OBJ
T24 : "Toggle24"
T26 : "Toggle26"
PUB Main
{{Start new blinking process in new cog}}
cognew(T24.Toggle24, @StackToggle24)
cognew(T26.Toggle26, @StackToggle26)
'the same result
'T26.Toggle26
'T24.Toggle24
'And I create two objects:
'Toggle24.spin
'and Toggle26.spin
PUB Toggle24
{{Toggle Pin, Count times with DelayMS milliseconds in between. If Count = 0, toggle Pin forever.}}
dira[noparse][[/noparse]24]~~ 'Set I/O pin to output direction
repeat
'Repeat for Count iterations
!outa[noparse][[/noparse]24] ' Toggle I/O Pin
waitcnt(4_000_000 + cnt) ' Wait for Delay cycles 'Clear Cog ID variable
PUB Toggle26
{{Toggle Pin, Count times with DelayMS milliseconds in between. If Count = 0, toggle Pin forever.}}
dira[noparse][[/noparse]26]~~ 'Set I/O pin to output direction
repeat 'Repeat for Count iterations
!outa[noparse][[/noparse]26] ' Toggle I/O Pin
waitcnt(4_000_000 + cnt) ' Wait for Delay cycles 'Clear Cog ID variable
the chip switched not from one cog to other
only the first object method a execute.
What's wrong please help me???
Best Regards: Uwe Reinersmann
Post Edited By Moderator (Chris Savage (Parallax)) : 6/4/2007 8:04:52 PM GMT
Comments
please see my comment in the other thread and remove this one to avoid problems of double posting.
http://forums.parallax.com/showthread.php?p=654046
Thomas