Shop OBEX P1 Docs P2 Docs Learn Events
BS2e Programming — Parallax Forums

BS2e Programming

hmlittle59hmlittle59 Posts: 404
edited 2008-11-12 03:49 in BASIC Stamp
Hello to all,

Ok call me slow, I have printed out Jon Williams instructions from Nuts & Volts column #71, and I've read and re-read on how to do it and it's not clicking in my head. I know the overall concept, but I'm drawing a blank on what to do when it comes to the actual programming. I'm trying to learn by using the DS1302 Demo code, what part/parts would I move over with variables and what would stay. I want to put the clock programming routine in the 2nd bank, when it needs to be set just move over set it and move back. Can all the variables be in the 2nd bank also? I need more examples or this one explained at a THIRD Graders level so the light in my head will come on.

Any help Please.

1) Start from 1st bank
2) Move DS1302 Demo Code to 2nd bank(I think this is a separate file) and the first has both
3) jump to that bank and prg. the DS1302 Chip
4) return to 1st bank
5) is there an additional 26 var.

I have both BS2 and BS2e

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I HAVE LEARN SO MUCH...BUT STILL KNOW SO LITTLE!!!

hmlittle59

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-11-10 06:16
    #5: There is only one set of variables (26 bytes). The same variables are present no matter which slot is executing. That's why it's important to declare the same variables in each slot's program if they are to be shared. It is ok to declare the shared variables first and follow them with the variables that are local to the particular slot involved.

    Remember that, when control is transferred back to slot #0, it's with a RUN statement which starts the "main program" over from the beginning, but without clearing the variables. The "main program" remembers where it came from by checking a shared variable for a non-zero value (starting the program with a reset or power on clears all the variables to zero).

    Post Edited (Mike Green) : 11/10/2008 6:21:49 AM GMT
  • hmlittle59hmlittle59 Posts: 404
    edited 2008-11-10 07:22
    thanks Mike,

    From bank 0 then....(RUN 1) will switch me to the other bank were my clock setting routine resides. Then starting from the top clear/set all variables and execute the DS1302 Demo code from that same bank. then return to bank 0(RUN 0) with var. intack. You said the "main program" remembers where it came from by chk a shared variable. What is a "shared variable", where is it? Do I bother with it at all? You said the "main program" starts over from the "TOP" without changing any variables correct? (not like a GOSUB).

    thanks Mike

    hope this makes sense, its 1:20 am here in TEXAS, after this question, bed time

    thanks again

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I HAVE LEARN SO MUCH...BUT STILL KNOW SO LITTLE!!!

    hmlittle59
  • hmlittle59hmlittle59 Posts: 404
    edited 2008-11-11 05:19
    Mike,

    If I have 2 routines that need(use) the same "SUB-Routine" in Bank 0 and then move one(1) of those routines to the next Bank 1, can I move an "EXACT" copy of that "SUB-Routine" to Bank 1 with out any clash of any kind?

    Hope this is clear.

    thanks

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I HAVE LEARN SO MUCH...BUT STILL KNOW SO LITTLE!!!

    hmlittle59
  • Carl HayesCarl Hayes Posts: 841
    edited 2008-11-11 13:41
    Yes, it is often necessary to have absolutely identical subroutines in different slots.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    · -- Carl, nn5i
  • hmlittle59hmlittle59 Posts: 404
    edited 2008-11-11 13:47
    Thanks Carl H.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I HAVE LEARN SO MUCH...BUT STILL KNOW SO LITTLE!!!

    hmlittle59
  • Carl HayesCarl Hayes Posts: 841
    edited 2008-11-12 03:49
    Here's an example from my current project.··Slot 4 sets the clock (in subroutine RTCsetRTC),· in this case a DS1307.·· It's all working.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    · -- Carl, nn5i
Sign In or Register to comment.