Shop OBEX P1 Docs P2 Docs Learn Events
Another Newbe question... — Parallax Forums

Another Newbe question...

dennodenno Posts: 223
edited 2014-12-29 15:14 in Propeller 1
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

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2014-12-28 03:50
    denno wrote: »
    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.
    Will coginit(ID := 7, fn, @stack) be acceptable (coginit itself doesn't have a return value)?
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-12-29 07:02
    denno wrote: »
    Does each OBJECT, run it it's own COG, or is it in the first COG...?
    Duane Degn wrote: »
    Cogs and objects really have nothing to do with each other. You can have one object use all 8 cogs and you could easy have 8 objects in a single cog. Cogs run assembly code. The assembly code is either a PASM section of code launched with cognew or the Spin interpreter from ROM. The Spin interpreter is launched when a Spin method (from within the current object) and stack location are the parameters of the cognew statement.

    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).
  • dennodenno Posts: 223
    edited 2014-12-29 15:14
    Thank you again...Duane...I will continue on this quest to learn a new language....besides English. Yes, you are right in saying that there is some confusion on my part about COGs and OBJECTS. I will keep plugging away at it.

    DenO
Sign In or Register to comment.