PIC Microcontroler LCD IO routine

Graphic LCD driver for LPH 7366-1 (used in Nokia 5110 Phone)

by Bergthaller C Iulian

Pic interface to graphic LCD module LPH 7366-1 used in Nokia 5110 Phone.

;=======LCD_Nokia nse1,nse3,nsm1 / Version 1.0====================21/12/02==
;	cod LPH7366-1 / driver PCD8544
;	rb6,rb7     sclock,sdata
;	ra0,ra1,ra2,ra3	d/C,Reset,Vccmd,SCE
;     internal clock
;     standard crystal 4.000 MHz XT - 1us pe instructiune/pe aproape
;	Program realizat de Ing. Bergthaller Iulian-Alexandru 
;------------------------------------------------------------
	list	p=16f84A;f=inhx8m
_CP_OFF	equ	H'3FFF'	      ;code protect off
_PWRTE_ON	equ	H'3FFF' 		;Power on timer on
_WDT_OFF	equ	H'3FFB'		;watch dog timer off
_XT_OSC		equ	H'3FFD'	;crystal oscillator
	__CONFIG       _CP_OFF & _PWRTE_ON & _WDT_OFF & _XT_OSC
;------------------------------------------------------------
;      cpu init
porta	      equ	05
portb	      equ	06
count1	equ	0C
count2	equ	0D
count3	equ	0E
afisaj	equ	0F
#DEFINE sclk	portb,6
#DEFINE sdta	portb,7
#DEFINE dorc	porta,0
#DEFINE rset	porta,1
#DEFINE tens	porta,2
#DEFINE enab	porta,3
;------------------------------------------------------------
;      bit init
w	equ	0
;------------------------------------------------------------
	org	0
;
;------------------------------------------------------------
init   
	movlw   0
	tris    portb ; set portb as output
      movwf   portb ; all ouput low
	movlw   0
	tris    porta ; set portb as output
      movwf   porta ; all ouput low
start	call pause
	bsf	dorc
	bsf	enab
	bsf	tens ;activare tensiune
	call lcres	;resetare cca. 250ms
	movlw 21H	;set extins 
	movwf afisaj
	call	lccmd
	movlw .197	;Vop 
	movwf afisaj
	call	lccmd
	movlw 13H	;bias
	movwf afisaj
	call	lccmd
	movlw 20H	;afisare orizontala
	movwf afisaj
	call	lccmd
	movlw 09H	;mod control all on 
	movwf afisaj
	call	cbild	;resetare DDRAM
	call	lccmd
	call	pause
	movlw 08H	;mod control blank 
	movwf afisaj
	call	lccmd
	call	pause
	movlw 0CH	;mod control normal 
	movwf afisaj
	call	lccmd
	movlw 40H	;x ini 
	movwf afisaj
	call	lccmd
	movlw 80H	;y ini
	movwf afisaj
	call	lccmd
adata	movlw 1FH	;date
	movwf afisaj
	call	lcdta
	movlw 05H	;date
	movwf afisaj
	call	lcdta
	movlw 07H	;date
	movwf afisaj
	call	lcdta
	goto adata
lcdta	bsf	dorc
	bcf	enab ;activare chip si start date
	call	varsa
	bsf	enab
	retlw	00
lccmd	bcf	dorc
	bcf	enab ;activare chip si start date
	call	varsa
	bsf	enab
	retlw	00
lcres	bcf	rset ;resetare
	call	pause
	bsf	rset ;dezactivare reset
	retlw	00
varsa	bcf	sclk
	btfsc afisaj,7	;bit0(MSB)
	bsf	sdta
	btfss afisaj,7
	bcf	sdta
	call halta
	bsf	sclk
	call halta
	bcf	sclk
	btfsc afisaj,6	;bit1
	bsf	sdta
	btfss afisaj,6
	bcf	sdta
	call halta
	bsf	sclk
	call halta
	bcf	sclk
	btfsc afisaj,5	;bit2
	bsf	sdta
	btfss afisaj,5
	bcf	sdta
	call halta
	bsf	sclk
	call halta
	bcf	sclk
	btfsc afisaj,4	;bit3
	bsf	sdta
	btfss afisaj,4
	bcf	sdta
	call halta
	bsf	sclk
	call halta
	bcf	sclk
	btfsc afisaj,3	;bit4
	bsf	sdta
	btfss afisaj,3
	bcf	sdta
	call halta
	bsf	sclk
	call halta
	bcf	sclk
	btfsc afisaj,2	;bit5
	bsf	sdta
	btfss afisaj,2
	bcf	sdta
	call halta
	bsf	sclk
	call halta
	bcf	sclk
	btfsc afisaj,1	;bit6
	bsf	sdta
	btfss afisaj,1
	bcf	sdta
	call halta
	bsf	sclk
	call halta
	bcf	sclk
	btfsc afisaj,0	;bit7(LSB)
	bsf	sdta
	btfss afisaj,0
	bcf	sdta
	call halta
	bsf	sclk
	call halta
	bcf	sclk
	retlw	00
cbild	bcf	sdta
	movlw   .6
	movwf   count3
c3	movlw   .84
	movwf   count1
c1	movlw   .8  
	movwf   count2
	bsf	dorc
	bcf	enab 
c2	bcf	sclk
	nop
	nop
	bsf	sclk
	decfsz  count2	
	goto 	c2
	bsf	enab 		
	decfsz  count1	
	goto 	c1		
	decfsz  count3    
	goto  c3          
	retlw 	00
pause	movlw   .7
	movwf   count3
d3	movlw   .50
	movwf   count1
d1	movlw   .250	  
	movwf   count2
d2	decfsz  count2	
	goto 	d2		
	decfsz  count1	
	goto 	d1		
	decfsz  count3    
	goto  d3          
	retlw 	00
halta	movlw   20H	
	movwf   count1
g1	movlw   40H
	movwf   count2 
g2	decfsz  count2	
	goto 	g2		
	decfsz  count1	
	goto 	g1		
	retlw	00
;------------------------------------------------------------
	end
;============================================================ 

LPH 7366 controled power supply

LPH 7366 interfacing with PIC16F84

Warning: Front view!

LPH 7366 Pins

      pin1     V+
      pin2     Sclk
      pin3     Sda
      pin4     DorC
      pin5     Cs
      pin6     Osc (32768Hz external clock)
      pin7     Gnd
      pin8     Vout(DC/DC voltage converter)
      pin9     Reset

See also:

Questions:

Comments: