All 8 cogs at once
alienmindsinc
Posts: 2
Good afternoon, guys,
I've been searching the net all morning, but I can't find any examples of how to call assembly code from an already running cog.
Basically, I'm running all of the cogs at once, and 7 of the 8 start just fine, but the 8th already contains the code to run the other 7, and after it starts the other 7 I would like it to run the same code as the other 7.
The code looks like:
This is just the main part of the code that I'm running. What it does is each "wait" object runs a PWM/delay setup to remove the comm link propagation delay of our entire rig.
What I would like to do is call the entry routine·after cog 6 starts, or just switch the current cog to the routine all of the others are running. What I've tried is stopping·the current cog, and restarting,·coginit, and creating a new cog. Nothing seems to work, and there doesn't seem to be a documented way to use spin·code and then jump to assembly code.
So, what am I missing here?
Thanks,
-M
·
I've been searching the net all morning, but I can't find any examples of how to call assembly code from an already running cog.
Basically, I'm running all of the cogs at once, and 7 of the 8 start just fine, but the 8th already contains the code to run the other 7, and after it starts the other 7 I would like it to run the same code as the other 7.
The code looks like:
OBJ wait : "gpl" ' The wait cycle object PUB start
'start each cog wait.start(0,1,10,0, PW) ' delay is set per link location wait.start(2,3,15,1,PW) wait.start(4,5,5,2,PW) wait.start(6,7,100,3,PW) wait.start(8,9,100,4,PW) wait.start(10,11,100,5,PW) wait.start(12,13,100,6,PW)
DAT {{ ASM Code to do the delay circuit }} org 0 entry or dira, out ' Set the correct output pin
---------- lots more code--------
This is just the main part of the code that I'm running. What it does is each "wait" object runs a PWM/delay setup to remove the comm link propagation delay of our entire rig.
What I would like to do is call the entry routine·after cog 6 starts, or just switch the current cog to the routine all of the others are running. What I've tried is stopping·the current cog, and restarting,·coginit, and creating a new cog. Nothing seems to work, and there doesn't seem to be a documented way to use spin·code and then jump to assembly code.
So, what am I missing here?
Thanks,
-M
·
Comments
PUB run(arg1,..,argN)
' do stuf
PUB start(arg1,...,argN)
cognew(@run,@args)
Then in the calling object:
wait.start(cog1...)
...
wait.start(cog6...)
wait.run(....) <-- your initial cog runs the code
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.mikronauts.com - my site 6.250MHz custom Crystals for running Propellers at 100MHz
Las - Large model assembler for the Propeller Largos - a feature full nano operating system for the Propeller
Morpheus & Mem+ Advanced dual Propeller SBC with XMM and 256 Color VGA
Please use mikronauts _at_ gmail _dot_ com to contact me off-forum, my PM is almost totally full
If your launching all the other cogs through spin, then its most likely that cog zero is doing this.
You just need to call cogint on cog zero with the asm code it should load.
The cog then will reload itself with the new asm code. You don't need to stop the cog however.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,
Thanks for taking the time to reply!
-M
If you want the SPIN code to invoke the PASM code using the same cog (so the SPIN code stops, and the PASM code starts), you'd use COGINIT( COGID, @cogstart, longptr ).· Again, there's a ~8000 CLK delay before the PASM code starts executing.· Note: use COGID rather than assuming cog #0.
PASM also has a COGINIT instruction (which can also start an unused cog like COGNEW), but it can only start PASM code (and you will need to figure out a way to get the hub addresses).· People have figured out how to kickstart SPIN after reloading HUB RAM (same as the built-in bootloader), but I don't think anyone has figured out how to invoke a SPIN object/method from PASM or return to the SPIN code.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Composite NTSC sprite driver: Forum
NTSC & PAL driver templates: Forum
OnePinTVText driver: ObEx Forum