Shop OBEX P1 Docs P2 Docs Learn Events
something wrong with "coginit" command — Parallax Forums

something wrong with "coginit" command

ispearispear Posts: 20
edited 2011-03-26 08:34 in Propeller 1
I have attached the code. I am trying to launch 2 cogs to start the following tasks. The pub ledinit works great, the pub lcdinit does not work at all.

inithelp.spin

What am i doing wrong?

thanks for the help,

-Isaac

Comments

  • Andrey DemenevAndrey Demenev Posts: 377
    edited 2011-03-25 21:44
    With first coginit, you terminate current program (that runs at cog 0) and launch a new one, so second coginit has no chance to be executed
  • jazzedjazzed Posts: 11,803
    edited 2011-03-25 21:58
    Use cognew instead of coginit.
  • StefanL38StefanL38 Posts: 2,292
    edited 2011-03-26 00:33
    to explain a bit more about what jazzed recommended "Use cognew instead of coginit"

    the only difference between cognew and coginit ist that you the user determine the number of the cog. All other details stay the same.
    If you look through all the objects in the object-exchange - the easy and the high sophisticated ones you will allways find the command cognew.
    Almost never coginit.

    As long as you always use cognew the propeller-chip itself takes care of finding a free cog.
    As soon as you use only a single coginit you the programmer take over the full responsability of starting and stopping for all eight cogs!!!
    Regardless if you use coginit or cognew for the rest of the cogs.

    Coginit disturbs the automatic of the chip-hardware. If very experienced coders avoid using coginit whenever they can why should you use it?
    It is almost black and white: Coginit causes a lot of trouble. Cognew just works without thinking about details.

    All 8 cogs are completely identical. If you don't believe write a testprogram that starts cogs by cognew and stops them again thousands of times and see it working flawlessly.

    best regards

    Stefan
  • ispearispear Posts: 20
    edited 2011-03-26 08:34
    Stefan, Jazzed and Denenev,

    Thank you for the advice. I am just getting started with the propeller platform so I really appreciate all your help.
    It worked just like you said.

    jazzed,
    your explanation made perfect sense. thanks

    -Isaac
Sign In or Register to comment.