Shop OBEX P1 Docs P2 Docs Learn Events
Serial LCD timing problem — Parallax Forums

Serial LCD timing problem

JossJoss Posts: 32
edited 2007-05-12 16:26 in BASIC Stamp
Using this simple program from the Seral LCD documentation (backlit version, part number 27977) and the proper $STAMP declaration:

' {$STAMP BS2px}
' {$PBASIC 2.5}

TxPin CON 0
Baud19200 CON 32

HIGH TxPin
SEROUT TxPin, Baud19200, [noparse][[/noparse]"Hello, this text will wrap!"]

the program runs fine on the BS2 using the BOE, but will not run on the BS2px24 using the pro demo board (prints a few garbage characters).

I send the same data to Hyperterminal while using the BS2px24 and it comes out clean as well.

I also tested the demo program for the SX28 and it uses the LCD just fine.

I'm befuddled as can be. I suspect the CON is wrong, but playing with the value has yielded nothing. I've googled and searched these forums with no luck.

I'd appreciate any light someone could throw my direction.

Regards,

Joss

Comments

  • WynandWynand Posts: 39
    edited 2007-05-12 11:55
    I think that it should read : TxPin PIN 0
    At least, that is what they use in the demo program that I have......
    What you could also try is to label it just Tx instead of TxPin, maybe it is a conflick of reserved words???? I may be wrong. Try the following code... And tell me whether it works.


    ' {$STAMP BS2}
    ' {$PBASIC 2.5}

    TX PIN 0 ' serial output to LCD

    #SELECT $STAMP
    #CASE BS2, BS2E, BS2PE
    T2400 CON 396
    T9600 CON 84
    T19K2 CON 32
    #CASE BS2SX, BS2P
    T2400 CON 1021
    T9600 CON 240
    T19K2 CON 110
    #ENDSELECT

    LcdBaud CON T19K2

    LcdBLoff CON $12 ' backlight off
    LcdOn1 CON $16 ' LCD on; cursor off, blink off
    LcdCls CON $0C ' clear LCD (use PAUSE 5 after)

    Main:
    HIGH TX
    PAUSE 100
    SEROUT TX, LcdBaud, [noparse][[/noparse]LcdBLoff, LcdOn1, LcdCls] 'setup lcd with the above constants
    PAUSE 250
    SEROUT TX, LcdBaud, [noparse][[/noparse]"Hello, this text wil wrap"]
    END

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Why didn't I think of THAT!!!!
  • Mike GreenMike Green Posts: 23,101
    edited 2007-05-12 13:44
    If you'll look in the PBasic supplement for the BS2px (www.parallax.com/dl/docs/prod/stamps/BASICStamp2px.pdf) or the most recent version of the PBasic manual, both downloadable from the Parallax website, you'll see that the BS2px has unique values for many of the timing constants. In particular, the Baudmode constant for 9600/8-bit/true/no-parity is 396. Wynand has the right idea, but there needs to be another CASE for the BS2px.
  • WynandWynand Posts: 39
    edited 2007-05-12 14:14
    I am goin to try and work out the constant for serout for 19K2 for a BS2px.

    1.) (bits 0-11) INT(2500000/19200)=130 (trow away the number after decimal point) - 20 = 110
    2.) (bit 13) 8-bit/no parity = 110 + 0 = 110
    3.) (bit 14) Inverted = 110 + 16384 = 16494 else if Non-Inverted = 110+0 = 110
    4.) (bit 15) Driven output = 16494+0 = 16494(inverted) or if above then = 110 +0 = 110(Non-Inverted)

    To clarify, 8bit/no parity/true = 110
    8bit/no parity/inverted· = 16494


    #CASE BS2PX
    T19K2 CON 16494 (or 110)
    I tried to reverse engineer the constants that Mike gave the link to, and then I get an answer of 188. So, try 188(for good luck),·110 and 16494, other than that I don't know.

    Please try and tell me if my math was correct or just way wrong, please......

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Why didn't I think of THAT!!!!

    Post Edited (Wynand) : 5/12/2007 2:32:50 PM GMT
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2007-05-12 16:16
    The help file gives this equation for 8/n/true

    Determine the bit period (bits 0 - 11)
    • BS2, BS2e, and BS2pe = INT(1,000,000
  • WynandWynand Posts: 39
    edited 2007-05-12 16:26
    Thanks Jeff, I wasn't sure that I got the equation right.
    Now we know, BSP2px baudrate for 19K2, 188.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Why didn't I think of THAT!!!!
Sign In or Register to comment.