Shop OBEX P1 Docs P2 Docs Learn Events
PUB does notload to COG — Parallax Forums

PUB does notload to COG

nicolad76nicolad76 Posts: 164
edited 2010-10-26 05:56 in Propeller 1
Hi,
I have been using COGS forever but always loading PASM.
Today I do not really need PASM (lucky day!!!) so all my routines are in SPIN.
I checked the manual on how to execute SPIN to a cog but I could not get it to work.
What am I doing wrong?
The original file is in attachment.

Pub Main | cN , ok

Setup(11,10,10,21,20,0)

ok := (cN:=CogNew(PPark(bStopDir0,bStopDir1,bDirection,bParkDirection,bStep,lStepPerUnit),@stack))>0



Nothing happens when I use the above code. If I call the PUB
PPark(bStopDir0,bStopDir1,bDirection,bParkDirection,bStep,lStepPerUnit)
Then it get executed. This prove that the PUB itself shold not be an issue.

Thanks!!!!

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-10-25 12:58
    Don't forget that each cog has its own special function registers, including DIRA. You can't set DIRA in one cog and have OUTA in another cog produce a pin change.

    -Phil
  • Mike GreenMike Green Posts: 23,101
    edited 2010-10-25 12:59
    PPark is executing. It's just not doing what you expect.

    Each cog has its own copy of the DIRA and OUTA registers. When you execute Setup, that sets up the DIRA register in the main cog. When PPark executes, it's using a different DIRA register that's initialized to zero. You have to move the code from Setup into the beginning of PPark so the proper DIRA register gets initialized.
  • nicolad76nicolad76 Posts: 164
    edited 2010-10-25 13:02
    Phil!!!!! THANKS!!!!!!
    I moved the DIRA[] into the PUB and it works!!!!
    Fixed in les then 5 minutes!!!! This is a great FORUM!!!

    Nicola
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-10-25 13:23
    You're welcome, but Mike provided the more thorough explanation. :)

    -Phil
  • nicolad76nicolad76 Posts: 164
    edited 2010-10-26 05:56
    yhea...but when I replied I did not see that, anyway thanks to both of you. This is the proof that this Forum is a great place for beginners like me....it is nice to know that you do not need to give up bcs somebody is ready to help you!
Sign In or Register to comment.