Serial LCD timing problem
Joss
Posts: 32
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
' {$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
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!!!!
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
Determine the bit period (bits 0 - 11)
Now we know, BSP2px baudrate for 19K2, 188.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Why didn't I think of THAT!!!!