Shop OBEX P1 Docs P2 Docs Learn Events
Starting a COG with PASM — Parallax Forums

Starting a COG with PASM

dr hydradr hydra Posts: 212
edited 2011-10-03 16:33 in Propeller 1
Does anyone have an example where they have started a new COG in PASM replacing SPIN in COG zero...so that all eight COGS could/would being running PASM.

Comments

  • MagIO2MagIO2 Posts: 2,243
    edited 2011-10-03 12:28
    What exactly is the problem?
    It's well described in the propeller manual. COGINIT is your friend.
    Create a long variable where you clear the "NEW"-bit, set the COG bits to 000, set the address of the PAR register and the address where to find the code in HUB RAM. Then call COGINIT where the address of this long is given.
  • kuronekokuroneko Posts: 3,623
    edited 2011-10-03 16:33
    If cog N is running SPIN you might as well re-start it with coginit(cogid, @pasm, parameter). If that's not an option then yes, you'd have to construct a parameter for the coginit instruction and go from there.
    coginit target
    
    target          long    (p[COLOR="silver"]{& $FFFC}[/COLOR]) << 16 | (a[COLOR="silver"]{& $FFFC}[/COLOR]) << 2 | %0000
    
    Parameter (p) and address (a) can only have 14 relevant bits und must be 4n aligned (the & $FFFC is optional). If you go down this route you may want to construct target dynamically. The expression above is what you'd have to do.

    Just thinking out loud here, have you considered that your program may be started in a cog different from #0? In this case you'd run into trouble with hardwiring cog 0 as being (re)started last. Letting the main cog restart itself would avoid that issue.
Sign In or Register to comment.