Shop OBEX P1 Docs P2 Docs Learn Events
Cog not starting — Parallax Forums

Cog not starting

SolderHeadSolderHead Posts: 7
edited 2011-10-17 06:16 in Propeller 1
I'm trying to generate PWM output for a project, the cognew command I use is not returning -1, but the code in the function is not running. If I run the function inline it works 100%, but I need it running on a seperate cog. Any Ideas? It's just a standard SPIN function, I'm using this to start the cog

Cog := cognew(mainloop, @Stack)

Maybe the Stack is not big enough? long Stack[120] ...I'm relatively new to this, help would be great. Thanks.

Comments

  • MagIO2MagIO2 Posts: 2,243
    edited 2011-10-16 03:04
    It's possible to attach code to a post. If you want to know what your problem is, you should use this feature, so we can have a look at your actual code.

    Yes, any kind of problems can occur if your stack is smaller than the needed stack. So it's possible that this is the cause of your problem, but without code nobody can tell you for sure.
  • kuronekokuroneko Posts: 3,623
    edited 2011-10-16 03:10
    Sounds more like every-cog-has-its-own-dira/outa-register-set.
  • SolderHeadSolderHead Posts: 7
    edited 2011-10-16 03:12
    My entire project code is massive, and to be honest it's not the greatest code. But the part I'm struggling with is the servo code. I'm trying to just generate pwm for servos, this is not rocket science, it should be easy, the main loop should not need much stack, it's real simple, here is a snippet


    pub mainloop(dummy) | framets, pin, ts
    repeat
    framets := cnt+(clkfreq / _1uS * 20000)
    repeat pin from 0 to 7
    ts := cnt
    outa[OutputPins[pin]] := 1
    waitcnt(ts+ServoData[pin])
    outa[OutputPins[pin]] := 0
    waitcnt(framets)

    Start is as such...

    PUB Start | pin

    repeat pin from 0 to 7
    Set(pin, 1000)

    Cog := cognew(mainloop(0), @Stack)

    'mainloop

    if I un-comment mainloop it functions 100% correctly. But not when starting a new cog up.
  • SolderHeadSolderHead Posts: 7
    edited 2011-10-16 03:26
    kuroneko wrote: »
    Sounds more like every-cog-has-its-own-dira/outa-register-set.

    Brilliant, Thanks so much. That helped. Happy days...
  • 4x5n4x5n Posts: 745
    edited 2011-10-17 06:16
    I think we've all been bit on each cog having it's own dira/outa/ina register set! You don't notice the ina issue so much because the default is input.
Sign In or Register to comment.