Yesterday I received a SMD 20m2 which I superglued to the back of one of my miniature 16x2 LCD screens, along with pin headers, programming resistors & 0.1uf cap:
It works great in terms of being able to display characters on the screen from content already within the Picaxe, the problem is when I try to use it as a serial-to-LCD backpack, erroneous characters appear and it doesn't always pick up on the serial data being sent to it. The 's' in the display in the above picture should not be there.
This is the code I'm using, which is an adaption from the code on this page http://www.jrhackett.net/LCD16.shtml
When I hook in a commercially made LCD screen with serial backpack it doesn't have any glitches so I know the serial stream is ok. How can I make the Picaxe more robust and not miss any incoming data? I tried running at 4800baud but still get erroneous characters sometimes appearing.
It works great in terms of being able to display characters on the screen from content already within the Picaxe, the problem is when I try to use it as a serial-to-LCD backpack, erroneous characters appear and it doesn't always pick up on the serial data being sent to it. The 's' in the display in the above picture should not be there.
This is the code I'm using, which is an adaption from the code on this page http://www.jrhackett.net/LCD16.shtml
Code:
#picaxe 20m2
#no_data
#terminal off
' 20m2 serial-to-LCD backpack
symbol cmd = 0 ' LCD command datatype
symbol txt = 1 ' LCD ASCII text datatype
symbol LCDenable = c.4 ' LCD LCDenable pin
symbol Datatype = pinc.5 ' LCD register select signal pin
symbol SerialSource = c.7 ' serial input pin
setfreq m32
symbol baud=N9600_32
dirsb=255 ' set portb to output
output c.4,c.5 ' set control of LCD lines to output
'initialise LCD
pinsb=56:pulsout LCDenable,1 ' 8 bit 2 line LCD
pause 20 ' allow setting to take effect
pinsb=12:pulsout LCDenable,1 ' cursor off
pause 20 ' allow setting to take effect
pinsb=1:pulsout LCDenable,1 ' clear screen
pause 20 ' allow setting to take effect
do
bptr=28
serin SerialSource,baud,@bptrinc
serin [200],SerialSource, baud, @bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc
@bptr=0
bptr=28
do until @bptr=0
pinsb=@bptrinc
select case pinsb
case 0 to 31
Datatype=cmd
case 128 to 207
Datatype=cmd
else
Datatype=txt
endselect
pulsout LCDenable,1
loop
loop