Shop OBEX P1 Docs P2 Docs Learn Events
cogs why doesnt this work ? — Parallax Forums

cogs why doesnt this work ?

SawmillerSawmiller Posts: 276
edited 2006-05-19 03:57 in Propeller 1
hi ya'll experimenting with cogs... i declared some objects then tried to start cogs using them, the first one i start will start but the other will not ( propclip on a breadboard with all my experiments still on it)
i can switch them and the other will start, but cant run both

CON
· _clkmode = xtal1 + pll16x
· _xinfreq = 5_000_000
·
··················
VAR··· ' Global Variables and Cog Stack Space

······ long stack[noparse][[/noparse]20]
······ long stack1[noparse][[/noparse]20]
OBJ······················ ' create objects
··· lcd :·· "lcd_test-ilm-216"· ' lcd tester
··· seven : "sevenseg"········· ' seven segment spi tester

PUB Start
····· coginit(4,lcd.main,@stack1)·········· '·starting procedure in lcd , same on the seven seg

····· coginit(3,seven.start,@stack)



basicly using a blank program to call 2 other programs and get them started....

what am i missing ?
thanks
dan

Comments

  • cgraceycgracey Posts: 14,133
    edited 2006-05-15 23:06
    I would imagine any requisite stacks would be declared in the objects, themselves, and any COGs would be put to use by the methods within those objects.
    I don't know the composition of the objects you're using, but it would seem to me that this is what you would need to do:

    · lcd.main
    · seven.start

    What you were doing was forcing the launch of assembly language programs (that didn't exist) into COGs 3 and 4. To start a COG running spin code, you must name a local (to your object) PUB or PRI routine, along with a valid stack start address. If you refer to the manual, there should be some explanation of this. Also, study the objects which Parallax has provided. You can make a lot of inferences from those.
    Sawmiller said...
    hi ya'll experimenting with cogs... i declared some objects then tried to start cogs using them, the first one i start will start but the other will not ( propclip on a breadboard with all my experiments still on it)
    i can switch them and the other will start, but cant run both

    CON
    · _clkmode = xtal1 + pll16x
    · _xinfreq = 5_000_000
    ·
    ··················
    VAR··· ' Global Variables and Cog Stack Space

    ······ long stack[noparse][[/noparse]20]
    ······ long stack1[noparse][[/noparse]20]
    OBJ······················ ' create objects
    ··· lcd :·· "lcd_test-ilm-216"· ' lcd tester
    ··· seven : "sevenseg"········· ' seven segment spi tester

    PUB Start
    ····· coginit(4,lcd.main,@stack1)·········· '·starting procedure in lcd , same on the seven seg

    ····· coginit(3,seven.start,@stack)



    basicly using a blank program to call 2 other programs and get them started....

    what am i missing ?
    thanks
    dan
    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Chip Gracey
    Parallax, Inc.

    Post Edited (Chip Gracey (Parallax)) : 5/16/2006 12:31:05 AM GMT
  • SawmillerSawmiller Posts: 276
    edited 2006-05-16 00:00
    i was tring to include, without having a lot of subroutines in the current program, another unrelated program to see if i could make the propeller run 2 different outputs... i can include one program that doesnt have any local public or private, so i was tring to get 2 to run since i have 8 cogs, have been studing the manual.... chapters 1,2, and 4 anyways..... will go look again..

    thanks for the input chip

    dan
  • Stan671Stan671 Posts: 103
    edited 2006-05-19 03:57
    Dan, I ran into the exact same problem.· I wrote an object to load the graphics demo into one cog and my LCD demo into another and then·blink an LED to show three things going·running in·three cogs at the same time.· And the program never got past the first COGNEW.· When I commented out the first COGNEW, the second one ran, but then the·LED never blinked. Etc.

    I discovered, as Chip said (since he seems to know what he is talking about <grin>) that the objects loaded into a cog need to be defined in the object loading the cog.· I was trying to·COGNEW an object listed in the OBJ section of my loader object instead of a PRI or PUB object defined IN my main object.

    Once I moved the "sub-objects" so to speak, into my main object, then the COGNEW's worked perfectly and now all three things work fine.· A lesson learned the hard way ...

    Attached it a picture of my test rig doing the above:

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Stan Dobrowski
    600 x 800 - 336K
Sign In or Register to comment.