Hello John,
I noticed that you do a swap on
PORTB. IMHO that would not be possible.
Here is snippet of code that works
fine in several applications I have.
; Before writing tot the LCD check
if busy
; This routine returns only when LCD BUSY flag is clear
; and has
the current DD-RAM address in TEMP.
; (for 4 MC XTAL; E should be active for
min 480 nsec is less than 1 cycle)
;
CheckLCDBusy
bcf PORTA, LCD_RS_BIT ; command mode
so RS bit 0
bsf PORTA, LCD_RW_BIT ; we are going
to Read so RW bit 1
movlw
b'11111111' ; set PORTB
for input
tris
PORTB
; the quick an dirty way
Read_Busy
bsf PORTA, LCD_E_BIT ; switch
the Enable bit on
movf PORTB,
W ; read
the port with leaving a working copy in
W
movwf
TEMP
; save LCD data addresd in
TEMP
bcf PORTA, LCD_E_BIT ; switch
E-bit off
andlw
b'10000000' ; is bit 7
(busyflag set?)
skpz
; if busy flag is cleared then
skip
goto
Read_Busy ;
keep reading till
cleared
bcf PORTA, LCD_RS_BIT ; exit command
mode = clear RS
movlw
b'00000000' ; and make
PORTB
tris
PORTB
; an output port
again
bcf PORTA, LCD_RW_BIT ; reading done,
back to write
return
; with DD-RAM address in TEMP (note: BUSY Fl. cleared)
Henk Tobbe -
VK2GWK