Shop OBEX P1 Docs P2 Docs Learn Events
Does SX/B have a STAMP-Style DEBUG and DEBUGIN? - Page 2 — Parallax Forums

Does SX/B have a STAMP-Style DEBUG and DEBUGIN?

2»

Comments

  • NewzedNewzed Posts: 2,503
    edited 2005-05-16 15:15
    I tried that, Bean.

    Under Subroutines/Jump Table I wrote:

    sendit:
    serout so, baud, char
    return

    Then I subsituted 'gosub sendit' for 'serout'.· When I tried to compile I got an error "Address 380 not within lower half of memory page".· I didn't know how to resolve that so I went back to my original version.· I am using a modified template where all of the pages and their addresses are deleted.· I'm just writing to one long page.

    Sid
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-05-16 15:24
    That is happening because the code for your sendit is ending up in the upper half of the code page. If you place the subroutine within your code to ensure it is in the lower half of the code page you should be good.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • NewzedNewzed Posts: 2,503
    edited 2005-05-16 16:12
    Paul, I tried that.· I moved the sendit routine to the bottom of my page, changed serout to gosub sendit, and I get a complilation error "Address 1838 not within lower half of memory page".· So I went back to Square 1.

    Sid
  • NewzedNewzed Posts: 2,503
    edited 2005-05-16 16:20
    Paul and Bean, I might add that the placement of the sendit routine does not cause an error.· Only when I change serout to gosub do I get the error.

    Sid
  • BeanBean Posts: 8,129
    edited 2005-05-16 16:48
    Sid,
    You have to declare the subroutine. Look at the template in the help file.
    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "SX-Video Display Module" Available Now.

    www.sxvm.com

    "It's not getting what you want, it's wanting what you've got."
    ·
  • NewzedNewzed Posts: 2,503
    edited 2005-05-16 17:20
    Bean, I looked at the template.· It has a bunch of headings, but no examples.· So.................

    I copied and pasted the Help sample tempate to Templates under a new name.

    Under Subroutine Declarations would I write:

    sendit = sub

    and under Subroutines put the actual sendit routine

    and in my main program write gosub sendit.

    Am I even close?

    Sid
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-05-16 17:38
    No, Sid, you're way off.· Have a look at the Example Projects·(particularly the Serial LCD Controller) in·the help file.·

    Let's say you want to delare a subroutine to transmit a byte (on a known port and at a known rate), and you *may* want to send that same character several times.· You would declare your subroutine (above main code), like this:

    TXBYTE······· SUB······· 1, 2

    This tells the compiler that there will be a subroutine that REQUIRES one parameter, but could take two.· After the main section of code, you could write the subroutine like this:

    TXBYTE:
    · temp1 = __PARAM1
    · IF __PARAMCNT = 1 THEN
    ··· temp2 = 1
    · ELSE
    ··· temp2 = __PARAM2
    · ENDIF
    · DO WHILE (temp2 > 0)
    ··· SEROUT Sio, Baud, temp1
    ··· DEC temp2
    · LOOP
    · RETURN

    Now, in the body of your program you could send a single asterisk like this:

    · TXBYTE "*"

    And if you wanted to send 16 spaces:

    · TXBYTE " ", 16


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA


    Post Edited (Jon Williams) : 5/16/2005 5:43:06 PM GMT
  • NewzedNewzed Posts: 2,503
    edited 2005-05-16 17:54
    Jon, you have such patience.· Let's see if I understand.

    TXBYTE······· SUB······· 1, 2

    Understood

    This tells the compiler that there will be a subroutine that REQUIRES one parameter, but could take two.· After the main section of code, you could write the subroutine like this:

    TXBYTE:
    · temp1 = __PARAM1
    · IF __PARAMCNT = 1 THEN
    ··· temp2 = 1
    · ELSE
    ··· temp2 = __PARAM2
    · ENDIF
    · DO WHILE (temp2 > 0)
    ··· SEROUT Sio, Baud, temp1
    ··· DEC temp2
    · LOOP
    · RETURN

    OK so far.

    Now, in the body of your program you could send a single asterisk like this:

    · TXBYTE "*"

    Since I always want to send char, would I write TXBYTE char?
    Does temp1 = char?


    Am I getting close?

    Sid
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-05-16 17:57
    If the character you want to send is stored in a variable called "char" then yes, you would do this:

    · TXBYTE char

    ... and if you want it sent five times:

    · TXBYTE char, 5

    ... and if you want it sent the number of times stored in a variable called "idx" then you'd do this:

    · TXBYTE char, idx

    I think that about covers every possibility.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • NewzedNewzed Posts: 2,503
    edited 2005-05-16 19:05
    Jon, I wrote TXBYTE· sub· 1,2 above the main program, the wrote this little program to test it out:

    Main:····
    PUT Line1, "Plug tester in"
    ··········
    For ix = 0 to 13
    get Line1(ix), char
    TXByte char, ix
    next


    '
    ' Subroutine Code
    '
    TXBYTE:
    · temp1 = __PARAM1
    · IF __PARAMCNT = 1 THEN
    ··· temp2 = 1
    · ELSE
    ··· temp2 = __PARAM2
    · ENDIF
    · DO WHILE (temp2 > 0)·· 'ERROR:· Invalid number of parameters
    SEROUT So, Baud, temp1
    ··· DEC temp2
    · LOOP
    · RETURN

    I received the indicated error.

    Since ix is 0 to ?, should DO WHILE be changed to:

    DO WHILE(temp2=>0)

    Sid
  • NewzedNewzed Posts: 2,503
    edited 2005-05-16 19:08
    I edited my post.· Should have said:

    DO WHILE(temp2=>0)

    Sid
  • NewzedNewzed Posts: 2,503
    edited 2005-05-16 19:22
    Jon, I changed the TXBYTE routine to read:

    TXBYTE:
    · temp1 = __PARAM1
    · IF __PARAMCNT = 1 THEN
    ··· temp2 = 1
    · ELSE
    ··· temp2 = __PARAM2
    · ENDIF
    · if temp2 => 0 then
    ··· SEROUT So, Baud, temp1
    ··· DEC temp2
    · endif
    RETURN

    I haven't ran it yet, so I don't know if it works or not.· Does it look right?

    Sid
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-05-16 19:38
    The version you sent will work, but will only ever send one character -- you defeated the repeats function.· If you don't need that, then just do this:

    TXBYTE······· SUB······· 1

    ... then:

    TXBYTE:
    · temp1 = __PARAM1
    · SEROUT Sio, Baud, temp1
    · RETURN

    By declaring the subroutine with sub, the compiler will flag any parameter errors so you don't have to check do the test as we did for repeats.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • NewzedNewzed Posts: 2,503
    edited 2005-05-16 23:42
    Well, now...............

    With the help I got from Jon, I got the program down to 1496 bytes.· So I started crunching and modifying and crunching some more, giving up a few "cosmetic" presentations in the process.· My debug screen now displays:

    Insert tester in Port RB
    Press any key when ready

    0 = 118 035·· OK
    1 = 118 035·· OK
    2 = 116 035·· OK
    3 = 116 036·· OK
    4 = 118 035·· OK
    5 = 119 036·· OK
    6 = 118 036·· OK
    7 = 118 036·· OK

    Total bytes used - 2002.· If Gunther is watching, it took 45 seconds to program. Now I can do Ports B and C in two programs, and that is very workable.

    Thanks again to all who helped.· Now maybe I'll try something else.

    Incidentally, Hyperterminal responds better to the program that the Stamp debug screen.· The debug screen·doesn't seem to be fast· enough.· It missed the "Insert tester" line and the 0 in the first data line.· Maybe I'll·precede those routines with a·little pause and see what happens.· And with Hyper, I could capture the data to an Excel terminal and make a permanent record of it [noparse]:)[/noparse]

    Now it's time for chicken wings and potato saladyeah.gif

    Sid
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-05-16 23:56
    You could put PAUSE into a subroutine to save more space.· Here's the way I usually do it:

    DELAY··· SUB··· 1, 2

    Here's the subroutine:

    ' Use: DELAY milliseconds { x multiplier }
    '
    DELAY:
    · temp1 = __PARAM1
    · IF __PARAMCNT = 1 THEN
    ··· temp2 = 1
    · ELSE
    ··· temp2 = __PARAM2
    · ENDIF
    · IF temp1 > 0 THEN
    ··· IF temp2 > 0 THEN
    ····· PAUSE temp1 * temp2
    ··· ENDIF
    · ENDIF
    · RETURN

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-05-16 23:59
    The BASIC Stamp DEBUG Terminal window does a bunch special character processing that Hyperterminal does not, hence the speed difference you noticed.· Enjoy your wings (sounds good ... I may have to go get some) and salad.
    Newzed said...

    <snip>

    Incidentally, Hyperterminal responds better to the program that the Stamp debug screen.· The debug screen·doesn't seem to be fast· enough.· It missed the "Insert tester" line and the 0 in the first data line.· Maybe I'll·precede those routines with a·little pause and see what happens.· And with Hyper, I could capture the data to an Excel terminal and make a permanent record of it [noparse]:)[/noparse]

    Now it's time for chicken wings and potato saladyeah.gif

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • T&amp;E EngineerT&amp;E Engineer Posts: 1,396
    edited 2008-07-24 23:32
    I have been having a very difficult time trying to connect to Hyperterminal. I downloaded 2 programs (1 called PuTTY and the other is Hyperterminal Private Edition 6.3) as I have Vista which no longer carries Hyperterminal.

    I can connect pins 2 and 3 and turn echo on to get the "double characters" but I can't get any interaction with the SX chips.

    I tried the 22K resistor method as well as making my own Max232 circuit (as listed in the professional development board schematics) and also tried using the same Max232 circuit as built into the professional development board. I have tried JonnyMac's DEBUG.sxb program with no luck. I'm very sure everything is wired correctly. I have tried it at T38400, N38400, T1200 and N1200 speeds with nothing happening on Hyperterminal. Any ideas what to do? I have also tried using with and without a 4 MHz resonator too. What is supposed to happen when DEBUG.sxb is run?

    Thanks for your help.

  • JonnyMacJonnyMac Posts: 9,216
    edited 2008-07-25 00:55
    That's really old code, and since it has my name on it I've updated it. I've also attached a screen shot from HyperTerminal so you can see what you'll get. You can trust that this code works; any troubles are on your end.

    Notes:
    -- "Shotgunning" is really no way to troubleshoot a problem. It has been well-documented that SERIN and SEROUT _require_ the use of a stable oscillator
    (the internal oscillator will not work)
    -- In my HyperTerminal setup I disable local echo, disable the addition of line feeds, and set flow-control to none.
    861 x 574 - 166K
  • T&amp;E EngineerT&amp;E Engineer Posts: 1,396
    edited 2008-07-25 01:15
    Thanks JonnyMac. I got your new program to work under the built in RS-232 DCE on the professional development board but not by the 22K resistor version posted earlier in this post.

    Thanks again!
  • JonnyMacJonnyMac Posts: 9,216
    edited 2008-07-25 01:47
    That's because the MAX232 inverts the output; if you're using a direct connection (through 22K) you must change the Baud to N38400.
  • T&amp;E EngineerT&amp;E Engineer Posts: 1,396
    edited 2008-07-25 02:00
    That did it!

    ' Baud··CON·"T38400"· ' Use with MAX232
    Baud··CON···· "N38400"· ' Use with 22K resistor method

    Thanks again!
Sign In or Register to comment.