SPIN inner workings
El Paisa
Posts: 375
I am trying to grasp some of the concepts of SPIN.
When Parallax will be able to release more documentation about SPIN?.
For instance, in one of the examples which consist·in blink two leds five times using two COGS
The program specifies a stack for each COG.
Also specifies:
VAR
· long· stack0[noparse][[/noparse]20]·················· 'Sets up a stack space for a Cog(processor)
· long· stack1[noparse][[/noparse]20]·················· 'Sets up a stack space for a second Cog(processor)
·········································· 'long stack0[noparse][[/noparse]20]: Allocates 20 longs for the stack.
········································· ·'long stack1[noparse][[/noparse]20]: Allocates 20 longs for the stack.
Why 20 longs per stack per cog?
Only one·pin is·used five times for each COG.
What determines the depth of the stack?
When·the depth of the stack be bytes, nibles, words, longs?
You have to excuse me if I am lost in some of these concepts.
·
When Parallax will be able to release more documentation about SPIN?.
For instance, in one of the examples which consist·in blink two leds five times using two COGS
The program specifies a stack for each COG.
Also specifies:
VAR
· long· stack0[noparse][[/noparse]20]·················· 'Sets up a stack space for a Cog(processor)
· long· stack1[noparse][[/noparse]20]·················· 'Sets up a stack space for a second Cog(processor)
·········································· 'long stack0[noparse][[/noparse]20]: Allocates 20 longs for the stack.
········································· ·'long stack1[noparse][[/noparse]20]: Allocates 20 longs for the stack.
Why 20 longs per stack per cog?
Only one·pin is·used five times for each COG.
What determines the depth of the stack?
When·the depth of the stack be bytes, nibles, words, longs?
You have to excuse me if I am lost in some of these concepts.
·
Comments
On your question regarding stack space, that will depend on what the cog in question is doing. Phil Pilgrim wrote a neat little spin program that keeps track of an object's stack and determines actual usage (displayed on LEDs). I have found this handy for decreasing stack size to what is needed; too much is a waste, too little may cause unreliable operation.
Stack space must be declared as an array of longs because it is used to hold intermediate results of computations which are always longs.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax