Shop OBEX P1 Docs P2 Docs Learn Events
Coginit Command is stoping program? — Parallax Forums

Coginit Command is stoping program?

krazyideaskrazyideas Posts: 119
edited 2008-12-15 18:12 in Propeller 1
Hello

I have a coginit command that is either stoping my program or is not allowing the program to pass it.

I know this because if I take it out it works just fine except I never load that cog.

It's the frist coginit in my program, I'm sure that the second one will have the same problem, but I don't know because my program doesn't get that far.

Comments

  • PhilldapillPhilldapill Posts: 1,283
    edited 2008-12-13 17:39
    Eck. This is kind of hard to follow. You can do alot of cleanup and make the program flow better. One thing that catches my eye are these sort of lines:

    if ina[noparse][[/noparse]27] == 0 and ina[noparse][[/noparse]26] == 1 and ina[noparse][[/noparse]25] == 1 and ina[noparse][[/noparse]24] == 0 and ina[noparse][[/noparse]23] == 0 and ina[noparse][[/noparse]22] == 0 'key q

    That can be simplified to:
    'define all your keys here
    Key_q := %000110

    if(ina[noparse][[/noparse]22..27] == Key_q)
    ...
    if...
    etc.

    As for the cog problem... I don't see DegreeMark defined anywhere... Am I missing it?
  • PhilldapillPhilldapill Posts: 1,283
    edited 2008-12-13 17:41
    By the way, your TVDisplay function starts a new cog, only to start a new cog again when you call the term.start command... Why not just call TVDisplay instead of starting a cog with it?
  • krazyideaskrazyideas Posts: 119
    edited 2008-12-13 17:47
    Thanks I will see what I can do

    But I bet I will be back later with another question

    Thanks lots
  • Mike GreenMike Green Posts: 23,101
    edited 2008-12-13 18:25
    It's a good idea in general to avoid using COGINIT and use COGNEW instead unless there is some very specific reason why you want to use a specific cog for the new process. It's much more likely that you will make a mistake and reuse a running cog needed for something else than somehow need to use a specific idle cog for something.
  • krazyideaskrazyideas Posts: 119
    edited 2008-12-13 18:49
    Hello

    Well I think what I might be doing wrong is like Mike said calling the wrong cog.
    How do you retrive the cogid from cognew?? it says in the manule (if I am understanding it right) that it returns that value.

    The reason that I want to use COGINIT is becasue I have two small programs that run in a cog (and 6 sets of these 2 programs that each run in there own cog but I'm just working on one small bit at a time, besides the 6 cogs are nearly identacal so if I can get one to work right the others should be easy),·· And I want to switch between the programs from the first one (ReadFireTime1)· to the second one (ExicuteFireTime1) and back again depening on if a pin is high or low

    That is why I am useing COGINIT.·
    If I can still use Cognew I would be ok with that, but I don't think that I can becasue in the final product all 8 cogs are running programs and then I just want to switch or change the program that these 6 (just one for now) cogs are running.· Switching From ReadFireTime1 to ExicuteFireTime1 in one cog and switch from ReadFireTime2 to ExicuteFireTime2 ect...............·· up to 6 and then back again if I want. (depending on a pin being high or low)
    And ReadFireTime# and ExicuteFireTime#· both run continualy until I tell them (with that pin) to load and run the other.

    The COGINIT command is still stoping my program.

    And Thanks Philldapill that advice made my program look WAY better

    Thought would be great
    Thanks
  • Andrew E MileskiAndrew E Mileski Posts: 77
    edited 2008-12-15 18:12
    krazyideas said...

    How do you retrive the cogid from cognew?? it says in the manule (if I am understanding it right) that it returns that value.
    Returns: The ID of the newly started cog (0-7) if successful, or -1 otherwise.

    cog := cognew( ... )
    if (cog + 1)
       CogStartedOkay
    
    
Sign In or Register to comment.