Must've been the screwdriver . . .
Quote:
Originally Posted by Darrel Taylor
Hi Joe,
Glad you got it working!
That must have been a really old one.
It doesn't look familiar at all.
Hmmmmm, it must have been the screwdriver . . .
JS
Much simpler for newbie like me
That code with interupts and all is pretty hot, but going back to the very first question all he wanted to do was emulate a serial LCD, ie PIC is doing nothing else. I knocked this up yesterday and it works, and doesn't miss anything, very simple - like me! Go on eat me alive!
A back space key tells pic next char is a command - see commands in the select case area
A double back space makes it spit out a pangram back at you.
DEFINE LCD_DREG PORTC 'DATA PORT
DEFINE LCD_DBIT 4 'STARTING BIT (0 OR 4)
DEFINE LCD_RSREG PORTC 'REGISTER SELECT PORT
DEFINE LCD_RSBIT 1 'REGISTER SELECT BIT
DEFINE LCD_RWREG PORTC 'READ/WRITE SELECT PORT
DEFINE LCD_RWBIT 2 'READ/WRITE SELECT BIT
DEFINE LCD_EREG PORTC 'ENABLE PORT
DEFINE LCD_EBIT 0 'ENABLE BIT
DEFINE LCD_BITS 4 'BUS SIZE (4 OR 8)
DEFINE LCD_LINES 2 'LINES IN DIPLAY
DEFINE LCD_COMMANDUS 2000 'CMD DELAY TIME IN uS
DEFINE LCD_DATAUS 50 'Data DELAY TIME IN uS
define Osc 4
'************************************************* ***********
ADCON1 = 7 'disable A/d work digital
TRISB = %00000000 'unused port b set to o/p
TRISA = %00000000 ' PortA outputs
TRISC = %00000000 ' PortC outputs
OPTION_REG.7 = 0 ' Enable PORTB pull-ups
'T2400 con 16780 '2400bd, driven, inverted, no parity
T2400 con 396 '2400bd, driven, true, no parity
'will need to use rs232 inverter
comsout var PORTA.0
comsin var PORTA.1
datarray var byte[1] 'incoming array on rs232
'************************************************* ***********
start:
Pause 500 ' Wait for LCD to startup
Lcdout $FE, $0C 'turn cursor off
Lcdout $fe, 1 ' Clear LCD screen
Lcdout $fe, 2 ' go home
Lcdout "GPL PIC System"
Lcdout $FE, $C0 'move cursor to begin of line 2
Lcdout "Serial in at ",DEC T2400
Pause 1000 ' Wait 1 second
Lcdout $fe, 1 ' Clear LCD screen
'************************************************* ***********
main: while 1 'forever loop
serin2 comsin, T2400, [ datarray[0]] 'get a char
if datarray[0] = 8 then 'next byte is a LCD command after BS received
serin2 comsin, T2400, [ datarray[0]]
select case datarray[0]
case 48 '0 = Clear LCD screen
Lcdout $fe, 1
case 49 '1 = move cursor to begin of line 1
Lcdout $fe, 2
case 50 '2 = move cursor to begin of line 2
Lcdout $fe, $C0
case 51 '3 = move cursor to begin of line 3
Lcdout $fe, $94
case 52 '4 = move cursor to begin of line 4
Lcdout $fe, $D4
case 8 'BS again so transmit a pangram
gosub send
case else 'do nothing
end select
else
Lcdout str datarray\1 'show 1 char to LCd
endif
wend
send: serout2 comsout,T2400,["How quickly daft jumping zebras vex",13,10]
return
'************************************************* ***********
END
'************************************************* ***********
Now Why Would Anybody Do That ?
Quote:
Originally Posted by websmith
Go on eat me alive!
THERE ALWAYS MULTIPLE WAYS OF DOING ANYTHING. There is nothing wrong with brewing an alternative, I will study your code and learn something from it, therefore I am grateful for your post. Thank You, JS