How to interface a Ericsson GH337, GH688, CH388 lcd with a PIC16F84A microcontroller


Ericsson GH337 lcd interface

Ericsson GH688, CH388 lcd interface


Download code.

Source code file for Ericsson GH337, GH688, CH388 lcd interface:
;=====i2c lcd test for Ericsson GH337 / Version 1.2======10/11/03==
;	iic lcd driver: PCF2105 compatible
;	ra0,ra1     sdata,sclock
;	rb0 to rb7	led outputs
;	negative voltage invertor: TC682
;	internal clock
;	standard crystal 4.000 MHz XT - 1us pe instructiune
;	www.module.ro 
;------------------------------------------------------------
	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	0x2C	; 4 lines (line 0 not conected)
	call	act
	movlw	0x0F	; lcd on
	call	act
	movlw	0x06	; direction 
	call	act
	movlw	0x01	; clears entire display 
	call	act
	movlw	0x02	; address=0
	call	act
	movlw	0xC0	; linia3
	call	act
	call	iicp	; i2c stop 
;***************************************************
;* Lcd data subroutine                             *
;***************************************************	
	call	iict
	movlw	0x74
	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	0x06	; 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 November, 2003
© Copyright 2003 Bergthaller Iulian-Alexandru