Need info on prop Stack/memory not quite sure I understand
mikediv
Posts: 825
Guys I am finishing up the methods and cogs class, but I am a bit confused about the stack, when assigning stack space for the cog methods is the stack actually memory space? say I use the cognew or coginit I want to do somehting really simple like turn on an led on P0 using one cog then P1 using a second cog and P3 using a 3 cog on so on why do they number it as Stack0, stack10, stack20 what is the meaning of 0,10,20??? and is the stack space you asine actually mean the ram you need for the program or method?? in its not the memory how do I setup the stack and how would I know how big to make it? if thats the right way to think of it. Second part
I am trying to figure out how to use the cogs in parallel to run some small programs to help me understand how to use the prop to run a bunch of programs all at once , the way I understand it the cogs are adresed serialy anyway right?
meaning the code runs linear cog,0,cog1,cog2 and so on or can they all run all at the same time reading and writing I/O
and not to complicate my questions but what if I have the cogs running I/O and 3 of the cogs will need to access P5 to read an input is this possible or am I complicating matters and confusing myself? Thanks guys.
·
I am trying to figure out how to use the cogs in parallel to run some small programs to help me understand how to use the prop to run a bunch of programs all at once , the way I understand it the cogs are adresed serialy anyway right?
meaning the code runs linear cog,0,cog1,cog2 and so on or can they all run all at the same time reading and writing I/O
and not to complicate my questions but what if I have the cogs running I/O and 3 of the cogs will need to access P5 to read an input is this possible or am I complicating matters and confusing myself? Thanks guys.
·
Comments
2) The cogs do run independently and at the same time (unless they're accessing the shared (hub) memory). Each cog gets one turn at accessing shared memory every hub cycle (once every 200ns at an 80MHz clock). If the program is written in Spin (as opposed to assembly language), there's nearly constant access to shared memory since that's where the Spin program and variables are located, so it's a little more complicated. Several cogs can refer to the same I/O pin at the same time and there's logic to sort that out. Output mode takes priority over input mode and output high takes priority over output low. If all cogs are using an I/O pin as an input (the default), they can all read it simultaneously.
·