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.
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.
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.
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
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?
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:
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]
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 salad
Sid
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ Jon Williams Applications Engineer, Parallax
Dallas, TX· USA
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?
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.
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.
Comments
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
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid
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."
·
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
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
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
· 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
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
DO WHILE(temp2=>0)
Sid
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
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
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 salad
Sid
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 Williams
Applications Engineer, Parallax
Dallas, TX· USA
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.
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.
Thanks again!
' Baud··CON·"T38400"· ' Use with MAX232
Baud··CON···· "N38400"· ' Use with 22K resistor method
Thanks again!