Interfacing PIC18f87J90 with graphical LCD

Thread Starter

RG23

Joined Dec 6, 2010
304
I am using EA DIP122J-5NLA graphical LCD

I used the following initializsation subroutine.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Start LCD initialization
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
initLCD:
call delay_nop

incfsz count339,1
goto $-2


call delay_nop

incfsz count340,1
goto $-2

movlw 0xAE ; Display OFF
movwf PORTD
call SND_CMD

call delay_nop
movlw 0xAE ; Display OFF
movwf PORTD
call SND_CMD1

call delay_nop

movlw 0x1D ; column address
movwf PORTD; (40h to 80h)
CALL SND_CMD

call delay_nop
movlw 0x1D ; column address
movwf PORTD; (40h to 80h)
CALL SND_CMD1

call delay_nop

movlw 0xB8 ;;;;;page address
movwf PORTD
CALL SND_CMD

call delay_nop
movlw 0xB8 ;;;;;page address
movwf PORTD
CALL SND_CMD1

;call delay_nop



;call delay_nop

movlw 0xC0 ;;;;;;line address
movwf PORTD
call SND_CMD

call delay_nop
movlw 0xC0 ;;;;;;line address
movwf PORTD
call SND_CMD1

call delay_nop

movlw 0xA0 ;;ADC:::0: CW output
movwf PORTD
call SND_CMD

call delay_nop
movlw 0xA0 ;;ADC:::0: CW output
movwf PORTD
call SND_CMD1

call delay_nop
movlw 0xA4 ;;;;;;; Static Drive: Normal Drivin
movwf PORTD
call SND_CMD

call delay_nop
movlw 0xA4 ;;;;;;; Static Drive: Normal Drivin
movwf PORTD
call SND_CMD1


call delay_nop
movlw 0xA9 ;;;;;;;;;;; LCD duty cycle: 1/32
movwf PORTD
call SND_CMD
call delay_nop
movlw 0xA9 ;;;;;;;;;;; LCD duty cycle: 1/32
movwf PORTD
call SND_CMD1
call delay_nop

movlw 0xE0 ;;Read-Modify-Write ON
movwf PORTD
call SND_CMD
call delay_nop
movlw 0xE0 ;;Read-Modify-Write ON
movwf PORTD
call SND_CMD1
call delay_nop
movlw 0xAF ; Display ON
movwf PORTD
call SND_CMD

call delay_nop
movlw 0xAF ; Display ON
movwf PORTD
call SND_CMD1
return

where delay_nop is 1ms delay subroutine

When I am writng some data to the LCD the data displays, stays for some time and then disappears
I am not clear with that

I am calling subroutine iLCD_5 in the main part of the program

Table5:
ADDWF PCL,1
retlw 0x0F ; __####__
retlw 0x0F ; __####__
retlw 0x0F ; __####__
retlw 0x0F ; __####__
retlw 0x0F ; __####__
retlw 0x0F ; __####__
retlw 0x0F ; __####__
retlw 0x0F ; __####__

iLCD_5:
movlw d'8'
movwf count341
movlw 0xEE ;;Read-Modify-Write OFF
movwf PORTD
call SND_CMD

;call delay_nop
movlw 0xE0 ;;Read-Modify-Write ON
movwf PORTD
call SND_CMD
;call delay_nop
movlw 0xEE ;;Read-Modify-Write OFF
movwf PORTD
call SND_CMD
movlw 0x00 ; column address
movwf byte_pos
movwf PORTD; (40h to 80h)
CALL SND_CMD
;movlw 0xBB ; page address
;movwf PORTD; (40h to 80h)
;CALL SND_CMD
movlw 0xC0 ; line address
;movwf byte_pos1
movwf PORTD; (40h to 80h)
CALL SND_CMD
goto iLCD_51

iLCD_51:
;decf count341,1
;movf count341,0
;movwf count342
;movwf count343

movlw 0xB8 ; page address
movwf PORTD; (40h to 80h)
CALL SND_CMD

;movlw 0x01
;movwf PCLATH
decf count341,0
call Table5
movwf PORTD
call SND_DTA

incf byte_pos,1
movf byte_pos,0
sublw h'3C'
btfss CARRY
goto iLCD_52

decfsz count341,1
goto iLCD_51
return

iLCD_52:
movlw 0xEE ;;Read-Modify-Write OFF
movwf PORTD
call SND_CMD1

movlw 0xB8 ; page address
movwf PORTD; (40h to 80h)
CALL SND_CMD1

movlw 0x00 ; column address
movwf PORTD; (40h to 80h)
CALL SND_CMD1

movlw 0xC0 ; line address
movwf PORTD; (40h to 80h)
CALL SND_CMD1

;decfsz count341,1
goto iLCD_53

iLCD_54:
;movlw 0x01
;movwf PCLATH
decf count341,0
call Table5
movwf PORTD
call SND_DTA1

iLCD_53:
decfsz count341,1
goto iLCD_54
return

If anyone has an idea please let me know

Thanks

 

ErnieM

Joined Apr 24, 2011
8,377
<gulp> Driving a graphical LCD using assembly language?

I've done it using C and that was hard enough. You can get a free C compiler from Microchip for that (and any) PIC.
 

Thread Starter

RG23

Joined Dec 6, 2010
304
I tried the same subroutines with PIC16f887 and the data displays continuously on graphical LCD

When I connected the display to PIC18f87J90, the data displays correctly but after some time it disappears and the display becomes blank

I couldn't figure out the problem yet


If anyone has an idea please let me know

Thanks
 
Top