Shop OBEX P1 Docs P2 Docs Learn Events
Why won't this program work? — Parallax Forums

Why won't this program work?

RichardFRichardF Posts: 168
edited 2007-06-02 01:14 in Propeller 1
This works:
Pub start
·dira[noparse][[/noparse]23]~~
·led_on
Pri led_on
·repeat
· outa[noparse][[/noparse]23]~~

This doesn't!
Var
·long stack0[noparse][[/noparse]20]
Pub start
·dira[noparse][[/noparse]23]~~
·cognew(led_on, @stack0)
Pri led_on
·repeat
· outa[noparse][[/noparse]23]~~

Please help me solve this most basic problem.
·

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-06-01 18:19
    Each cog has its own DIR and OUT register set. You are setting DIR in one cog, but setting OUT in another cog where the DIR register is still set to zeroes. Move the dira[noparse][[/noparse]23]~~ into led_on and it should work. Note that you don't need to have the outa[noparse][[/noparse]23]~~ within the repeat loop. You can just have
    pri led_on
       dira[noparse][[/noparse]23]~~
       outa[noparse][[/noparse]23]~~
       repeat
    
    


    If you leave out the repeat, the newly started cog routine (led_on) exits immediately, stopping it.
    The initial cog (with the start stuff in it) stops itself immediately after the COGNEW is executed.
  • RichardFRichardF Posts: 168
    edited 2007-06-01 18:48
    Mike,

    ·I honestly studied the manual and never picked up on each cog having its' own dira and outa registers, but... with a little thought, it is obvious it has to be that way! Thanks for the help.

    Richard
  • BeanBean Posts: 8,129
    edited 2007-06-01 18:52
    Richard,
    That bit me in the butt a couple times too. So don't feel bad.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    “The United States is a nation of laws -· poorly written and randomly enforced.” - Frank Zappa

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.hittconsulting.com
    ·
  • Graham StablerGraham Stabler Posts: 2,507
    edited 2007-06-02 01:14
    I think its fairly early on in the manual when you don't think you need to read too hard [noparse]:)[/noparse]

    Page 26, I/O pins

    I got bitten today [noparse]:)[/noparse]

    Graham
Sign In or Register to comment.