PDA

View Full Version : PIC controlled serial LCD



NavMicroSystems
- 2nd March 2004, 23:10
Does anyone have some PBP-code
to Display data from a serial port on a character LCD? (HD44780)

Ideally it would support control codes similar to the ones available with the PBP LCDOUT statement (i.e. CLEAR Display, move Cursor, etc.)

CocaColaKid
- 3rd March 2004, 03:32
Include "Modedefs.bas"

i con 254 ' Control command byte
clr con 1 ' Clear the display

rcvbyte var byte ' First byte received

trisa = 0 ' Set porta to output
trisb = 0 ' Set portb to output

pause 500 ' Wait for LCD to start

lcdout i,clr ' Issue LCD command + clear screen

start:
serin2 portb.1,16780,[rcvbyte]
if rcvbyte = 254 then lcdcmd
lcdout rcvbyte
goto start

lcdcmd:
serin2 portb.1,16780,[rcvbyte]
lcdout i,rcvbyte
goto start
end

NavMicroSystems
- 3rd March 2004, 18:56
@ CocaColaKid

Thanks for your reply !

This code is almost the same as what I have tried before I started the thread.
I'm receiving the bytes at 4800 Baud (Mode $BC)

It works fine for just receiving characters (no control bytes) and displaying them bytewise.

If a control code like $FE,1 (clear display) is received and data is received right after the control bytes the display is cleared but the next 1 or 2 characters to be displayed get lost.

The CLEAR command takes too much time for the display to handle characters send right after the command.

btw. you don't need to include modedefs.bas if you are not using modes defined there.

regards

CocaColaKid
- 3rd March 2004, 19:04
Hmm, when I use this code I don't seem to drop any characters. That might be because of the lower baud rate though.