Help me! Problem: Using 89C51 to control LCD

Help me! Problem: Using 89C51 to control LCD

Hi!
I have a LCD two line, 20 character per line which name is TC2002A (made in China).
I using 89C51 microcontroler to control it.

And my program to load to 89C51 is writen follow:

; WRITE THE TEXT "HELLO WORLD" TO LCD PROGRAM
; I CONNECT THE PORT P2 OF 89C51 TO DATA BUS OF LCD
; WHERE P2.0, .. P2.7 AND DB0, .. DB7 CONNECT TOGETHER RESPECTIVELY

; AND THESE LINES CONTROL I CONNECT RS TO P3.0; RW TO P3.1; EN TO P3.2

RS BIT P3.0
RW BIT P3.1
EN BIT P3.2

DATA EQU P2
MESS: DB 'HELLO WORLD',0

ORG 0H
AJMP MAIN

SEND_STRING:
; TRANSMIT STRING WHICH POINTED TO BY DPTR.
; STRING MAY BE ANY OF LENGTH, BUT MUST BE MULL-TERMINATED.
SEND:
CLR A
MOVC A, @A+DPTR ; GET CHARACTER
JZ BREAK ; CHECK FOR TERMINATOR

ACALL WRITE_TEXT ; SEND CHARACTER TO LCD
INC DPTR ; POINT TO NEXT CHARACTER
AJMP SEND
BREAK
RET

WAIT_LCD:
SETB EN
CLR RS ; IT'S A COMMAND
SETB RW ; IT'S READ COMMAND
MOV DATA, #0FFH
MOV A,DATA ; READ THE RETURN VALUE
JB ACC.7,WAIT_LCD ; IF BIT 7 HIGH, LCD STILL BUSY
CLR EN ; FINISH THE COMMAND
CLR RW ; TURN OFF RW FOR FUTURE COMMAND
RET

INIT_LCD:
SETB EN
CLR RS ; IT'S A COMMAND
MOV DATA,#06H ; ENTRY MODE SET
CLR EN
LCALL WAIT_LCD
SETB EN
CLR RS
MOV DATA,#0EH ; TURN LCD ON AND THE CURSOR ON (DISPLAY ON/OFF CONTROL)
CLR EN
LCALL WAIT_LCD
SETB EN ; START LCD COMMAND
CLR RS ; IT'S A COMMAND
MOV DATA,#38H ; FUNCTION SET (8 BIT TWO LINE)
CLR EN
LCALL WAIT_LCD

SETB EN ; START LCD COMMAND
CLR RS ; IT'S A COMMAND
MOV DATA,#38H ; FUNCTION SET (8 BIT TWO LINE)
CLR EN
LCALL WAIT_LCD

SETB EN ; START LCD COMMAND
CLR RS ; IT'S A COMMAND
MOV DATA,#80H ; SET DISP RAM ADDR
SETB EN
LCALL WAIT_LCD
RET

CLEAR_LCD:
SETB EN ; START LCD COMMAND
CLR RS ; IT'S A COMMAND
MOV DATA,#01H
CLR EN
LCALL WAIT_LCD
RET

ADD_DDRAM_SET:
SETB EN ; START LCD COMMAND
CLR RS ; IT'S A COMMAND
MOV DATA,#80H
CLR EN
LCALL WAIT_LCD
RET

CURSOR_HOME:
SETB EN
CLR RS ; IT'S A COMMAND
MOV DATA,#02H
CLR EN
LCALL WAIT_LCD
RET

WRITE_TEXT:
SETB EN
SETB RS
MOV DATA,A
CLR EN
LCALL WAIT_LCD
RET

MAIN:
MOV SP,#5FH
CLR RW
LCALL INIT_LCD
LCALL CLEAR_LCD
LCALL ADD_DDRAM_SET
LCALL CURSOR_HOME
MOV DPTR, #MESS
ACALL SEND_STRING
AJMP $
END

; THE END OF PROGRAM

when i build and load the hex file into 89c51 and then turn of the power to run it. I see nothings in lcd, except the character which have ascii is 11111111B in the second line.
What wrongs?
Some once could help me.

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

While this questionis outside the scope of topicscovered by Intel Developer Services, Intel does offer technicalsupport for MCS 51 Microcontrollers at this URL:
http://developer.intel.com/design/support/faq/microcontrollers/support_disclaimer.htm

We hope this is helpful.

Regards,

Lexi S.

IntelSoftware NetworkSupport

http://www.intel.com/software

Contact us

Message Edited by intel.software.network.support on 12-07-2005 03:33 PM

Leave a Comment

Please sign in to add a comment. Not a member? Join today