New Propeller coder
I received my propeller demo board recently and I have been playing with it, trying to figure out how to utilize its parallel processing capabilites. One thing I am having trouble with is starting multiple cogs. Chapter 4 of the documentation lists I can use 'cognew' or 'coginit' to have a function be executed by a cog. Below is a code segment from my spin object MultiBlink:
OBJ
blinkers : "BlinkLed"
...
blinkers[noparse][[/noparse]0].init(pin1, delay2)
blinkers.init(pin2, delay1)
blinkers.init(pin3, delay2)
coginit(2, blinkers[noparse][[/noparse]0].start, @cogStack1)
coginit(3, blinkers.start, @cogStack2)
coginit(4, blinkers.start, @cogStack3)
The goal is to have 3 separate blinking leds runnning on three separate cogs. When I run this code, only the FIRST runs. Is there some other trick I am missing when I assign functions to cogs?
Thanks!
(you may see my code that is attached)
OBJ
blinkers : "BlinkLed"
...
blinkers[noparse][[/noparse]0].init(pin1, delay2)
blinkers.init(pin2, delay1)
blinkers.init(pin3, delay2)
coginit(2, blinkers[noparse][[/noparse]0].start, @cogStack1)
coginit(3, blinkers.start, @cogStack2)
coginit(4, blinkers.start, @cogStack3)
The goal is to have 3 separate blinking leds runnning on three separate cogs. When I run this code, only the FIRST runs. Is there some other trick I am missing when I assign functions to cogs?
Thanks!
(you may see my code that is attached)
Comments
I've been having mixed successes and failures with starting both assembly and spin cogs. Been re-reading the documents, reading and trying example codes, trying lots of variations. Bean, your BlinkLEDAsm.spin has been real helpful; thanks for posting that.
I've got a homemade board with only one on-board LED, and it seems like this testing would go much better if I were to add more. I was thinking that maybe a 7-segment LED display would make a nice debugging device; I could either use individual segments, as in this multiple cog testing, or display complete digits, or even display that sort of slithering worm pattern like some old minicomputers had on the rear of their system unit, which would speed up and slow down depending on system load. I always thought that looked cool.
So I hope somebody has some clues!
David
This example program uses all 8 cogs, they each seperatly blink the CogId+1 then wait for all to finish, then ClkSet($80) reboots.
http://forums.parallax.com/forums/default.aspx?f=25&m=126127
and this program for the demo board c.
http://forums.parallax.com/forums/attach.aspx?a=7428
I added a 7-segment display to my homemade board, and used it to develop and demo starting multiple cogs, with a few variations, flashing LEDs at slightly different clock speeds.
PMartin, this is much like your code but with a few distinct differences. I can't yet say which difference is what fixed the multiple cog demonstration, but this does work, so maybe this will help you get yours up and running.
David
Cheers!
PUB start(s)
cogVal := cognew(blink, @stack) + 1
I changed to
PUB start(s)
cogVal := cognew(blink, s) + 1
and
blinkers[noparse][[/noparse]0].start(@cogStack1)
blinkers.start(@cogStack2)
blinkers.start(@cogStack3)
now can each pass @cogStack1,2,3 to "s" so that it acts as if it were @cogStack1,2,3
Or with your original program
OBJ
blinkers : "BlinkLed"
is called 3 times and creates 3 seperate objects,
are there 3 seperate
long stack[noparse][[/noparse]10]
1 for for each object ?
both versions blink the same.
Phillip Y.
blinkers[noparse][[/noparse]0].start(@cogStack1)
blinkers.start(@cogStack2)
blinkers.start(@cogStack3)
blinkers[noparse][[/noparse]0].start ~~~
blinkers.start ~~~
blinkers.start ~~~
I think the @ is looking like a email address or something when posting, and the font size is being alterd.
It is the [noparse][[/noparse]1] and [noparse][[/noparse]2] that are deleted, looks ok in the preview before posting.
-Martin
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Martin Hebel
Southern Illinois University Carbondale - Electronic Systems Technologies
Personal Links with plenty of BASIC Stamp info
StampPlot - Graphical Data Acquisition and Control
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Life is one giant teacup ride.
Edit: That was written in a quick-reply box... I just added the [noparse]/noparse code and /code tags manually.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Don't visit my new website...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Just tossing my two bits worth into the bit bucket
KK
·
It works for any tag (e.g. urls My band's website)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
OS-X: because making Unix user-friendly was easier than debugging Windows
-Phil
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
OS-X: because making Unix user-friendly was easier than debugging Windows
Thanks a lot!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Just tossing my two bits worth into the bit bucket
KK
·