Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
07/04/05 21:01
Read: times


 
#96555 - LCD producing E's
hey guys

I have a weird situation,
I've attached a Powetip PC1602 LCD to the uC. the thing works fine on the tutorial code, but when I made a complicated prog things became weird. the display shortly (half a second) produces "hello world"as it should an the produces 2 line filled with E's lik in EEEEEEEE etc
does anyone know what went wrong.
I was trying to put a line of text on any given index (eg line 1 or line 2)

here's the code

; PC-LCD operator
; X-tal op 11.0952 MHz
;-----Controller declaration------------------------

;	PORTS
;	P0	LCD Data bus
;	P1	
;	P2	Control Port
;		P2.0	LCD EN
;		P2.1	LCD R/W
;		P2.2	LCD RS
;		P2.3	230 V~ Output
;		P2.4
;		P2.5	N/A
;		P2.6	N/A
;		P2.7	N/A
;	P3	Communication port
;		P3.0	RXD
;		P3.1	TXD
;		P3.5	LED

;	REGISTERS
;	R0	
;	R1		
;	R2
;	R3
;	R4
;	R5
;	R6
;	R7

;	MEMORY
;	TIMERS
;	T1	Serial Baudrate generator	





#include 8051.H


;-------Main routine----------------------------
	.org	0000H
	ajmp	Main

	.org	0010H
Main	acall	Init	
run	aCALL	CLEAR_LCD
	acall	TXT		; call send
;	sjmp	run

	.end


;-------SUB routines--------------------------------


Init	mov	R1,	#00H	; reset car. index
	acall	INIT_LCD
	ret			; return



WAIT_LCD:
	CLR	P2.0		;Start LCD command
	CLR	P2.2		;It's a command
	SETB	P2.1		;It's a read command
	MOV	P0,	#0FFh	;Set all pins to FF initially
	SETB	P2.0		;Clock out command to LCD
	MOV	A,	P0	;Read the return value
	JB	ACC.7		,WAIT_LCD ;If bit 7 high, LCD still busy
	CLR	P2.0		;Finish the command
	CLR	P2.1		;Turn off RW for future commands
	RET

INIT_LCD:			;COPPIED FROM TUTORIAL
	CLR	P2.2
	MOV	P0,	#38h
	SETB	P2.0
	CLR	P2.0
	aCALL	WAIT_LCD
	CLR	P2.2
	MOV	P0,	#0Eh
	SETB	P2.0
	CLR	P2.0
	aCALL	WAIT_LCD
	CLR	P2.2
	MOV	P0,	#06h
	SETB	P2.0
	CLR	P2.0
	aCALL	WAIT_LCD
	RET

CLEAR_LCD:			;COPPIED FROM TUTORIAL
	CLR	P2.2
	MOV	P0,	#01h
	SETB	P2.0
	CLR	P2.0
	aCALL	WAIT_LCD
	RET

WRITE_TEXT:			;COPPIED FROM TUTORIAL
	SETB	P2.2
	MOV	P0,	A
	SETB	P2.0
	CLR	P2.0
	aCALL	WAIT_LCD
	RET

TXT	acall	MOVE_LINE
TXT2	mov	A,	R1	; caracter index
	mov	DPTR,	#STRING	; get string info
	movc	A,	@A+DPTR	; get caracter
	jnz	SND		; ckeck wether or not a caracter
	mov 	R1,	#00h
	ret
SND	acall	WRITE_TEXT
	inc	R1		; inc car. pointer
	ajmp	TXT2


MOVE_LINE
	PUSH	ACC
	CLR	P2.2
	MOV	P0,	#082h	; first line 3rd place
	SETB	P2.0
	CLR	P2.0
	LCALL	WAIT_LCD
	POP	ACC
	RET


:-------Caracter TABLE-------------------------------------
STRING

	.DB	'H','E','L','L','O',' ','W','O','R','L','D'
	.DB	00H 			;END CODE
	.END


I hope you can find what I did worng
Regards Jeroen

List of 7 messages in thread
TopicAuthorDate
LCD producing E's            01/01/70 00:00      
   running off the end ?            01/01/70 00:00      
      Where can I get that LCD?            01/01/70 00:00      
   My opinion!            01/01/70 00:00      
      tutorial working ok            01/01/70 00:00      
   Problem solved            01/01/70 00:00      
      Another!            01/01/70 00:00      

Back to Subject List