cogs why doesnt this work ?
Sawmiller
Posts: 276
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
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
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.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chip Gracey
Parallax, Inc.
Post Edited (Chip Gracey (Parallax)) : 5/16/2006 12:31:05 AM GMT
thanks for the input chip
dan
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