Another Newbe question...
denno
Posts: 223
Given....I am using a Scott Edwards 4x40 LCD, as a DEBUG terminal, which I have been successful at.
What I am trying to do now, is keep track, which COG is running at that time, by using: success := (cog := cognew(BlahBlah), @stack) + 1) and setting cog as a global variable, and then sending it to the display.
However, does anyone have some code that will do COGINIT(7,BlahBlah,@stack), and put that COG ID into a variable, that I could send to the LCD display. In other words, I have code, that I what to send to different COGs, of which they will produce a GLOBAL variable, or other uses. But, I want to know, what the variable is which is sent to the LCD, and I want to know what COG is running at that time.
Last question...Does each OBJECT, run it it's own COG, or is it in the first COG...?
Thanks to all for your help..Denno
What I am trying to do now, is keep track, which COG is running at that time, by using: success := (cog := cognew(BlahBlah), @stack) + 1) and setting cog as a global variable, and then sending it to the display.
However, does anyone have some code that will do COGINIT(7,BlahBlah,@stack), and put that COG ID into a variable, that I could send to the LCD display. In other words, I have code, that I what to send to different COGs, of which they will produce a GLOBAL variable, or other uses. But, I want to know, what the variable is which is sent to the LCD, and I want to know what COG is running at that time.
Last question...Does each OBJECT, run it it's own COG, or is it in the first COG...?
Thanks to all for your help..Denno
Comments
Cog #0 starts out running the Spin interpreter. The other seven cogs are only active if they have been launched by an object.
I often list the cogs used by a program up near the OBJ section. If you look at the Start method of the various objects, you can usually see if the object launches a new cog or not. Most object which launch a new cog keep the cog running continuously.
Some objects have "Start" methods which would better be called "Init" methods since they don't start a cog. You can use ctrl+F to find "cognew" or (hopefully not) "coginit" statements and see if the object launches a cog (or more than one in some cases).
There is an object which counts the cogs in use but I've never used it since the number of cogs is pretty easy to count by keeping track of which objects launch new cogs.
BTW, I also found this cog vs object business confusing when I was first learning to use the Propeller. Fortunately Mike Green and others explained this stuff multiple times and it eventual sunk in.
I learn Spin from the version 1.0 Propeller Manual. There's a link to this manual in post #3 of my index (and I just added a link to this post). The Propeller Education Kit is also a good tutorial. The PEK can be found in the "Help" menu of the Propeller Tool (there's also a link to it in my index).
DenO