How to interface a Ericsson GA628 lcd with a PIC16F84A microcontroller


Ericsson GA628 lcd interface


Download code.

Leds from PortB are used just for display i2c code.

Source code file for Ericsson GA628 lcd interface:
;=====i2c lcd test for Ericsson GA628 / Version 2.0======21/06/03==
;	iic lcd driver: PCF2103
;	ra0,ra1     sdata,sclock
;	rb0 to rb7	led outputs
;	internal clock
;	standard crystal 4.000 MHz XT - 1us pe instructiune
;	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
status	equ	03
porta	equ	05
portb	equ	06
count1	equ	0C
count2	equ	0D
count3	equ	0E
transo	equ	0F
trisa	equ	85
trisb	equ	86	
#DEFINE sclk	porta,1
#DEFINE sdta	porta,0
;------------------------------------------------------------
;      bit init
rp0	equ	5
w	equ	0
f	equ	1
;------------------------------------------------------------
	org	0
;
;------------------------------------------------------------
init	bsf	status,rp0  ;switch to bank 1
	movlw	0	; porta and portb set to outputs
	movwf	trisa
	movwf	trisb
	bcf	status,rp0  ;switch back to bank 0
	movlw	0
	movwf	porta
	movwf	portb	
;***************************************************
start	movlw	0xFF	; led test
	movwf	portb 
	call	pause
;***************************************************
;* Lcd init commands                               *
;***************************************************
scrie	call	iict	; i2c start
	movlw	0x74	; device write address (75h for read)
	call	act	; i2c send subroutine
	movlw	0x00	; Co,RS=0, set instruction register for multiple next command bytes  
	call	act
	movlw	0x31	; extended instruction set
	call	act
	movlw	0x02	; set screen configuration left to right 
	call	act
	movlw	0x05	; set display configuration 
	call	act
	movlw	0x08	; set icon mode, full mode, icon blink disable
	call	act
	movlw	0x30	; normal instruction set
	call	act
	movlw	0x0C	; set display on
	call	act
	movlw	0x06	; set cursor move direction
	call	act
	movlw	0x02	; set DDRAM address 0 in address counter
	call	act
	call	iicp	; i2c stop 
;***************************************************
;* Lcd icon sets off                               *
;***************************************************
	call	iict
	movlw	0x74
	call	act
	movlw	0x80	; Co=1, RS=0 just one next command byte
	call	act
	movlw	0x4C	; set CGRAM for icons
	call	act
	movlw	0x40	; Co=0, RS=1, set instruction register for multiple next data bytes  
	call	act
	movlw	0x00	; erase icons sequence
	call	act
	movlw	0x18
	call	act
	movlw	0x00
	call	act
	movlw	0x00
	call	act
	movlw	0x00
	call	act
	movlw	0x00
	call	act
	movlw	0x00
	call	act
	movlw	0x00
	call	act
	movlw	0x00
	call	act
	movlw	0x00
	call	act
	movlw	0x00
	call	act
	movlw	0x00
	call	act
	movlw	0x0F
	call	act
	movlw	0x10
	call	act
	call	iicp	; i2c stop 
;***************************************************
;* Lcd cursor subroutine                           *
;***************************************************		
	call	iict
	movlw	0x74
	call	act
	movlw	0x00
	call	act
	movlw	0x30
	call	act
	movlw	0x01	; clears entire display and sets DDRAM address to 0 in address counter
	call	act
	movlw	0x0F	; display on, cursor on, cursor blink on
	call	act
	call	iicp
;***************************************************
;* Lcd data subroutine                             *
;***************************************************	
	call	iict
	movlw	0x74
	call	act
	movlw	0x80	; Co=1, RS=0 just one next command byte
	call	act
	movlw	0x8C	; set CGRAM for characters
	call	act
	movlw	0x40	; Co=0, RS=1, set instruction register for multiple next data bytes  
	call	act
	movlw	0xC8	; H
	call	act
	movlw	0xE5	; e
	call	act
	movlw	0xEC	; l
	call	act
	movlw	0xEC	; l
	call	act
	movlw	0xEF	; o
	call	act
	movlw	0x20	;  
	call	act
	movlw	0xD7	; W
	call	act
	movlw	0xEF	; o
	call	act
	movlw	0xF2	; r
	call	act
	movlw	0xEC	; l
	call	act
	movlw	0xE4	; d
	call	act
	call	iicp
homa	goto	homa
;***************************************************
act	movwf	transo	; iic data transmission 
	call	oled	
	movlw	0x08
	movwf	count3
vbit	bcf	sclk
	call	pause
	btfsc	transo,7	
	bsf	sdta
	btfss	transo,7
	bcf	sdta
	call	pause
	bsf	sclk
	call	pause
	bcf	sclk
	call	pause
	rlf	transo,f
	decfsz	count3,f
	goto	vbit
	call	ackp
	retlw	00
;***************************************************
iicp	bcf	sdta	; stop condition module
	call	pause
	bsf	sclk
	call	pause
	bsf	sdta	; stop command
	call	pause
	bcf	sclk
	call	pause
	retlw	00
;***************************************************	
iict	bsf	sdta	; start condition module 
	bsf	sclk
	call	pause
	bcf	sdta	; start command
	call	pause
	bcf	sclk
	call	pause
	retlw	00
;***************************************************
ackp	bsf	sclk	; one clock step for acknowledge (not read)
	call	pause
	bcf	sclk
	call	pause
	retlw	00
;***************************************************
oled	call	halta	; iic data before transmission displayed on portb
	movlw	0x00
	movwf	portb 
	movf	transo,w
	movwf	portb
	call	halta
	movlw	0x00
	movwf	portb
	retlw	00
;***************************************************
pause	movlw	0x08	; cca. 6ms delay
	movwf	count1
d1	movlw	0xFF	  
	movwf	count2
d2	decfsz	count2,f	
	goto 	d2		
	decfsz	count1,f	
	goto 	d1		
 	retlw	00
;***************************************************
halta	movlw	0x03	; cca. 585ms delay
	movwf	count3
r3	movlw	0xFF
	movwf	count1
r1	movlw	0xFF	  
	movwf	count2
r2	decfsz	count2,f	
	goto 	r2		
	decfsz	count1,f	
	goto 	r1		
	decfsz	count3,f    
	goto 	r3          
	retlw	00
;------------------------------------------------------------
	end
;============================================================




Back to my home page
Last updated June, 2003
© Copyright 2003 Bergthaller Iulian-Alexandru