Shop OBEX P1 Docs P2 Docs Learn Events
weird behavior with small SX/B program — Parallax Forums

weird behavior with small SX/B program

CandlestickCandlestick Posts: 5
edited 2006-03-31 04:02 in General Discussion
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.

Comments

  • BeanBean Posts: 8,129
    edited 2006-03-29 23:07
    Candlestick,
    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."
    ·
  • CandlestickCandlestick Posts: 5
    edited 2006-03-30 00:02
    Hi Bean,

    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..
  • BeanBean Posts: 8,129
    edited 2006-03-30 12:18
    Candlestick,
    Yeah that is one thing SX/B doesn't have "built-in" you need to do something like this:

    ' Do hundreds digit
    char = "0"
    DO 
      IF value < 100 THEN EXIT
      value = value - 100
      INC char
    LOOP
    SendChar char ' Calls a subroutine to send the character
    
    ' Do tens digit
    char = "0"
    DO 
      IF value < 10 THEN EXIT
      value = value - 10
      INC char
    LOOP
    SendChar char ' Calls a subroutine to send the character
    
    ' Do units digit
    char = "0" + value
    SendChar char ' Calls a subroutine to send the character
    
    


    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
    ·
  • CandlestickCandlestick Posts: 5
    edited 2006-03-30 14:13
    Thanks again for your help Bean!
    I think I'm getting the hang of this now [noparse]:)[/noparse]
  • John CoutureJohn Couture Posts: 370
    edited 2006-03-30 22:27
    Bean,

    (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
  • BeanBean Posts: 8,129
    edited 2006-03-31 00:08
    john couture said...
    Bean,

    (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.
    John,
    · 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 CoutureJohn Couture Posts: 370
    edited 2006-03-31 03:13
    Yea, I'm just teasing you. It it isn't a function, then why use EXIT?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    John J. Couture

    San Diego Miramar College
  • BeanBean Posts: 8,129
    edited 2006-03-31 03:15
    John,
    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 CoutureJohn Couture Posts: 370
    edited 2006-03-31 04:02
    Oops! You're right of course. I guess I'm asleep at the switch.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    John J. Couture

    San Diego Miramar College
Sign In or Register to comment.