How to interface a Ericsson A1018, T18s, T20, T28, T29 lcd with a PIC16F84A microcontroller


Ericsson A1018, T20, T28, T29 lcd interface schematic


The assembler code for Ericsson A1018, T18s, T20, T28, T29 lcd interface it is available for download.
;=====i2c lcd test for Ericsson A1018 / Version 1.0======29/06/03==
;	iic lcd driver: cheap version of PCF8558
;	ra0,ra1     sdata,sclock
;	rb0 to rb7	led outputs
;	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
count4	equ	10
count5	equ	11
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	; por time
;***************************************************
;* Lcd init commands                               *
;***************************************************
	call	iict	; i2c start
	movlw	0x70	; device write address (71h for read)
	call	act	; i2c send subroutine
	movlw	0x0D	; all on
	call	act
	call	cbild	; clear lcd
	call	iicp	; i2c stop
;***************************************************
;* Lcd data                                        *
;***************************************************
	call	iict	; i2c start
	movlw	0x70	; device write address (71h for read)
	call	act	; i2c send subroutine
	movlw	0x49	; line 2
	call	act
	movlw	0x27	; x offset
	call	act
	movlw	0x1F	;P
	call	act
	movlw	0x05
	call	act
	movlw	0x07
	call	act
	movlw	0x00
	call	act
	movlw	0x1F	;H
	call	act
	movlw	0x04
	call	act
	movlw	0x1F
	call	act
	movlw	0x00
	call	act
	movlw	0x1F	;I
	call	act
	movlw	0x00
	call	act
	movlw	0x1F	;L
	call	act
	movlw	0x10
	call	act
	movlw	0x10
	call	act
	movlw	0x00
	call	act
	movlw	0x1F	;I
	call	act
	movlw	0x00
	call	act
	movlw	0x1F	;P
	call	act
	movlw	0x05
	call	act
	movlw	0x07
	call	act
	movlw	0x00
	call	act
	movlw	0x12	;S
	call	act
	movlw	0x15
	call	act
	movlw	0x09
	call	act
	movlw	0x00
	call	act
	call	iicp	; i2c stop
homa	goto	homa
;***************************************************
cbild	movlw	0x05
	movwf	count5
	bcf	sdta	
linee	movlw	0x65
	movwf	count4
wdh	movlw	0x08
	movwf	count3
wbit	bcf	sclk
	call	pause
	bsf	sclk
	call	pause
	bcf	sclk
	decfsz	count3,f
	goto	wbit
	call	ackp
	decfsz	count4,f	
	goto 	wdh 	
	decfsz	count5,f
	goto 	linee
	retlw	00 
;***************************************************
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	status,rp0  ;switch to bank 1
	movlw	0xFF	; porta set to input
	movwf	trisa
	bcf	status,rp0  ;switch back to bank 0
	bsf	sclk	; one clock step for acknowledge (no read data)
	call	pause
	bcf	sclk
	bsf	status,rp0  ;switch to bank 1
	movlw	0	; porta set to output
	movwf	trisa
	bcf	status,rp0  ;switch back to bank 0
	movwf	porta
	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	0x10
	movwf	count1
d1	decfsz	count1,f	
	goto 	d1		
 	retlw	00
;***************************************************
halta	movlw	0x02	; cca. 585ms delay
	movwf	count3
r3	movlw	0x7F
	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