Where to store the HUB(s) PropBasic

dennodenno Posts: 101
edited October 8 in Propeller 1 Vote Up0Vote Down
Bean, good morning, just wondering if it makes a difference where to put the HUB declaration for address location. In the beginning, along with the CONSTANTS, before the "PROGRAM start", or can the HUB(s) go in the individual COG(s), along with the VAR(s) in the individual COG(s)? Does it make any difference?

Another question, can a program in a certain COG, within a DO/LOOP get "lost", and the rest of the DO/LOOP past that picitular line of code not...well not go any further? I can SEROUT 30, baud2 a "before" and an "after", when that picitular line is NOT commented out, and I will get the "before", but not the "after". If I comment out that line, I will get the "LOOPING", with the words "before and after" on the screen. I just found it interesting, as the program does load into the FLIP successfully..

DennO

Comments

  • 4 Comments sorted by Date Added Votes
  • Mod Edit: Added PropBasic to heading to get exposure.
    Infernal Machine
  • You should be able to declare HUB variables anytime before the "PROGRAM Start" line.

    I usually declare things in this order:
    CON
    PIN
    HUB
    TASK
    VAR
    SUB/FUNC

    PROGRAM Start
    program code
    END

    SUBs/Func code

    TASK code


    As for the DO...LOOP, there must be kind of error that is preventing the loop from exiting.
    Can you post the code in that DO...LOOP ?

    Bean
  • Bean, thank you, once again. I might be doing the SUB/FUNC thing wrong. I see from your templete above, that I should be naming the SUB/FUNC before PROGRAM start, which I do. But then I see that I should put the SUBs/Func code after the "END" but before any TASK code, is that right? I have in one TASK that I have, 3 calls to the same SUB, that works, INSIDE that TASK/ENDTASK. However, if I put a 4th SUB call inside that very same TASK/ENDTASK with a different name, I get the error message that "SUBS/FUNCTIONS cannot be nested". Is that why I get that error, because all SUB(s) to be called have to be outside of the TASK? Meaning I can call a SUB that is outside a TASK, from any other TASK? If so that is pretty cool....

    If a VAR is used inside a TASK, doesn't that VAR have to be declared inside that TASK, and the same for PIN. Or can the PIN and all VAR(s) for any TASK be declared outside the TASK, and before the PROGRAM start?

    As far as the DO/LOOP program freeze, I have not been able to duplacate the error...must have been something I just did not see, or perhaps, it is the fact that it has finally stopped raining up here in Michigan...LOL

    DennO
  • PINs are global. VARs must be declared inside the TASK code.

    Bean
Sign In or Register to comment.