weird behavior with small SX/B program
Candlestick
Posts: 5
I have been pulling my hair out trying to figure out what's wrong, so I hope someone with more SX experience can help me out.
I have a simple little program that I am trying to use to control a ILM-216 LCD from www.seetron.com. I am using an SX-TECH and SX_KEY to program and test.
I've attached the code in display.sxb.
The problem is at the·readKeys label. That routine should just increment i and display it. The problem is the goto readKeys statement (also tried goto @readKeys) seems to jump to the wrong place - it seems to go to Init_LCD!
It seems to just do this once then no changes on the display.
A somewhat related problem:
So I tried to debug too, and just get an error message box saying that "Debug requires at least 2 free words". I am not filling the page with data or code, so I don't know what that means and how I can fix it so I could debug.
Any help is tremendously appreciated.
Thanks for your time.
I have a simple little program that I am trying to use to control a ILM-216 LCD from www.seetron.com. I am using an SX-TECH and SX_KEY to program and test.
I've attached the code in display.sxb.
The problem is at the·readKeys label. That routine should just increment i and display it. The problem is the goto readKeys statement (also tried goto @readKeys) seems to jump to the wrong place - it seems to go to Init_LCD!
It seems to just do this once then no changes on the display.
A somewhat related problem:
So I tried to debug too, and just get an error message box saying that "Debug requires at least 2 free words". I am not filling the page with data or code, so I don't know what that means and how I can fix it so I could debug.
Any help is tremendously appreciated.
Thanks for your time.
SXB
5K
Comments
First of all are you using the latest version of SX/B ? Version 1.42.01 is the latest and can be downloaded from this forum.
Looking at your program the first thing I see is that you are missing a "PROGRAM Start" line. That might be causing the problem.
Also you should put the SEROUT command in a subroutine and call it for each character to send. The way you have takes alot of code space.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module"·available from Parallax for only $28.95 http://www.parallax.com/detail.asp?product_id=30012
"SX-Video OSD module"·available from Parallax for only·$49.95 http://www.parallax.com/detail.asp?product_id=30015
Product web site: www.sxvm.com
Available now! Cheap 4-digit LED display with driver IC·www.hc4led.com
"Sometimes it is better to remain silent and be thought a fool, than to speak and remove all doubt."
·
Thank you so much for your help, I have everything working now! I upgraded SX/B and also included the PROGRAM directive as you indicated.
If I may ask one more thing...I'm brand new to SX/B so I don't know all the tricks of the trade yet!
I see that SX/B syntax is not as complex as PBASIC in the Stamps. For example, serout always takes 3 arguments. If I have a variable that is just a count or index, how can I convert that to ASCII? For example, a variable called counter that is a number from 1-10, and I want to send the ascii code for the particular number..
Thanks again for your help..
Yeah that is one thing SX/B doesn't have "built-in" you need to do something like this:
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module"·available from Parallax for only $28.95 http://www.parallax.com/detail.asp?product_id=30012
"SX-Video OSD module"·available from Parallax for only·$49.95 http://www.parallax.com/detail.asp?product_id=30015
Product web site: www.sxvm.com
Available now! Cheap 4-digit LED display with driver IC·www.hc4led.com
"I reject your reality, and substitute my own." Mythbusters
·
I think I'm getting the hang of this now [noparse]:)[/noparse]
(grin) Naughty, Naughty.· What happened to the single entry, single exit point in functions? (something I harp on in my classes :-).· In the routine below, you can output a two or three character number to an output device.
TX_BIN3:
·· ' Use: TX_BIN3 ByteVar
·· ' -- This routine accepts a number stored in a byte variable and
·· '··· outputs a 3 digit decimal number with leading zeroes.
·· '
·· TX_BinIn = __PARAM1·········· ' register to be converted
·· TX_BinLen = 3
·· TX_BinDiv = 100
·· goto TX_BIN
TX_BIN2:
·· ' Use: TX_BIN2 ByteVar
·· ' -- This routine accepts a number stored in a byte variable and
·· '··· outputs a 2 digit decimal number·with leading zeros.
·· '
·· TX_BinIn = __PARAM1·········· ' register to be converted
·· TX_BinLen = 2
·· TX_BinDiv = 10
TX_BIN:
·· For TX_BinCnt = 1 to TX_BinLen
······ TX_temp1 = TX_BinIn / TX_BinDiv
······ TX_temp1 = TX_temp1 + 48
······ SerOut Sio,Baud,TX_temp1
······ TX_BinIn = TX_BinIn // TX_BinDiv
······ TX_BinDiv = TX_BinDiv / 10
·· Next
·· RETURN
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
John J. Couture
San Diego Miramar College
· Sorry, I don't follow you. The code I posted isn't even a function ?
· Are you referring to using EXIT ?
· My routine is much more optimized. Code space wise, data space wise, and execution time wise.
·
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module"·available from Parallax for only $28.95 http://www.parallax.com/detail.asp?product_id=30012
"SX-Video OSD module"·available from Parallax for only·$49.95 http://www.parallax.com/detail.asp?product_id=30015
Product web site: www.sxvm.com
Available now! Cheap 4-digit LED display with driver IC·www.hc4led.com
"I reject your reality, and substitute my own." Mythbusters
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
John J. Couture
San Diego Miramar College
EXIT does NOT exit a function. It EXITs out of a DO...LOOP or FOR...NEXT loop.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module"·available from Parallax for only $28.95 http://www.parallax.com/detail.asp?product_id=30012
"SX-Video OSD module"·available from Parallax for only·$49.95 http://www.parallax.com/detail.asp?product_id=30015
Product web site: www.sxvm.com
Available now! Cheap 4-digit LED display with driver IC·www.hc4led.com
"I reject your reality, and substitute my own." Mythbusters
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
John J. Couture
San Diego Miramar College