Shop OBEX P1 Docs P2 Docs Learn Events
Debug Screen — Parallax Forums

Debug Screen

NewzedNewzed Posts: 2,503
edited 2005-02-23 15:33 in BASIC Stamp
I have a program that writes to an EEPROM.· Immediately before I write to EEPROM, the program goes to another bank to get the time so I can time-stamp each packet that is written to EEPROM.· This works fine with one exception -· each time the program returns with the time, the debug screen is cleared and I can only see the last packet entered.· Is there any way to avoid this "automatic" CLSing of the debug screen?

Here is the portion of the code in question:

main:
com = 2················ 'go get time - returns to cont1
RUN 2
cont1:
HIGH grn
PAUSE 200
v1 = v1 + 1
v2 = v2 + 1

Thanks

Sid

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-02-22 21:32
    Sid,

    · First of all I think you are going to need more of the code to see what's going on.· There's no DEBUG statement in the sample you provided to see where that is even happening...

    ·· Second...Your code is not going to work as listed.· When you use RUN in a program, it does not return to the statement following the RUN command.· You get back to that bank via a RUN from the target bank, and that starts program execution at the beginning.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --==<{Chris}>==--
  • NewzedNewzed Posts: 2,503
    edited 2005-02-22 21:43
    Chris, I use flags when going between banks.· The flags take me directly to the specified lael in the target program.· For instance, at the very beginning of my program, I wrote:

    init:
    HIGH cs
    HIGH reset
    IF com = 1 THEN start
    IF com = 2 THEN atdata
    IF com = 3 THEN cont3

    I wrote later in the program:

    com = 2················ 'go get time - returns to cont1
    RUN 2

    The program jumps to bank 2 and bank 2 says:

    IF com = 1 THEN set1
    IF com = 2 THEN readit1
    IF com = 3 THEN timeit

    and then readit1 says:

    GOSUB getclk
    com = 3
    RUN 0

    whcih takes me directly to cont1 to continue the program.

    About the debug statements - I didn't feel they were necessary.· If I disable the "go get time" statements, all packets appear on the screen like always.· Only when the "go get time" statements is active does the screen CLS each time it displays a new packet.

    Sid
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-02-22 22:20
    Sid,

    · Flags, huh?· Clever...Still the DEBUG statement is apparently what's causing your problem, so seeing the DEBUG statements themselves would seem to be the logical place to look.· The only thing I can think of without seeing them is that some value you are sending to the DEBUG screen isn't what you expect it to be, and the value is say an ASCII 12, which would clear the screen.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --==<{Chris}>==--
  • NewzedNewzed Posts: 2,503
    edited 2005-02-22 22:38
    Chir, I could post the whole code if you like, but remember, if I disable the jump to get the time, debug functions normally.· Even with the get time jump, debug displays correctly, except that it clears the screen before printing the next packet.· I don't think it will help but the code is attached.· You will note tht the clockA is a .bs2 file, but the directive has been changed.· All files run on my BS2P24.



    Sid
  • NewzedNewzed Posts: 2,503
    edited 2005-02-22 23:37
    I couldn't solve the problem so I worked around it.· Copied the "Getclk" routine from bank 2 into bank 0, disabled the jump to bank 2, and inserted

    GOSUB getclk

    Now everything works fine.· I would still like an answer to the CLSing problem if anybody has one.

    Sid
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-02-22 23:37
    If you're jumping between banks it's safer to pass a message via the Scratchpad. You can also simplify this bit of code:

    IF com = 1 THEN set1
    IF com = 2 THEN readit1
    IF com = 3 THEN timeit

    to:

    BRANCH (com - 1), [noparse][[/noparse]Set1, ReadIt1, TimeIt]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2005-02-23 00:33
    Hi Sid,

    Here are the first few statements in your clock slot:

    Init:  DirA = %0011
      'OutA= %0111      ' Rst and Clk low
    
     DEBUG CLS
    ' -----[noparse][[/noparse] Main Code ]-------------------------------------------------------
    IF com = 1 THEN set1
    IF com = 2 THEN readit1
    IF com = 3 THEN timeit
    ' ...snip
    
    



    Could your mysterious clearing of the screen have anything to do with the DEBUG CLS statement on line 4?




    Newzed said...
    I have a program that writes to an EEPROM. Immediately before I write to EEPROM, the program goes to another bank to get the time so I can time-stamp each packet that is written to EEPROM. This works fine with one exception - each time the program returns with the time, the debug screen is cleared and I can only see the last packet entered. Is there any way to avoid this "automatic" CLSing of the debug screen?


    Here is the portion of the code in question:



    main:
    com = 2 'go get time - returns to cont1
    RUN 2


    cont1:
    HIGH grn
    PAUSE 200
    v1 = v1 + 1
    v2 = v2 + 1



    Thanks



    Sid
    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • NewzedNewzed Posts: 2,503
    edited 2005-02-23 00:40
    Good catch, Tracy -· I missed that one.· I'll put the program back like it was and check it out.· I will let you know.

    Sid
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-02-23 01:57
    Ha!· See?· That's exactly why I asked you to put the entire code up!· Extra eyes can sometimes spot things you may overlook when working with the same code over and over.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --==<{Chris}>==--
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-02-23 02:46
    Sid,
    ·· As long as I already looked at that one segment of code, I will point out one more thing, although it's probably insignificant.
    Start:
    DEBUG CLS
    tMode = T24Hr      'for 12 hr tMode = T12hr
    DEBUG "Enter S to set clock, R to read time", CR
    DEBUGIN com
    IF com = "S" OR com = "s" THEN set1
    IF com = "R" OR com = "r" THEN readit
    set1:
    DEBUG CLS
    DEBUG "Enter Date", CR
    <trimmed>
    


    In this segment of code you are getting input from the DEBUGIN statement.· There is no trap for characters other than those you are testing for.· If the user inputs, for example, J, the set1 routine will still be executed.

    In fact, you could just test for the "R" or "r" and anything else would execute the set1 routine, saving you a few bytes testing for the "S" or "s".· Just an observation.· I noticed it while looking for the rogue CLS statement...



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --==<{Chris}>==--
  • NewzedNewzed Posts: 2,503
    edited 2005-02-23 13:20
    Tracy, that was the problem.· Chris called it a rogue CLS - how true!
    Removed it and now everything works great.

    Chris, I'll add the trap in the clock slot.· This was the first pass at the new program so I have a bit of tidying up to do.

    Jon, on the BRANCH statement, I had that in at one time, then deleted it because one of the COM statements was deleted and the sequence was
    1-3-4.· Will the BRANCH statement still work or will BRANCH be looking for
    COM = 2.

    Thanks to all - this somewhat ambitious project is about ready to fly.

    Sid
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-02-23 15:33
    You need to match the number of targets for BRANCH, if not contiguous you can "fix" with LOOKDOWN:

    LOOKDOWN com, [noparse][[/noparse]1, 3, 4], com
    BRANCH com, [noparse][[/noparse]Set1, ReadIt1, TimeIt]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
Sign In or Register to comment.