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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/17/03 10:13
Read: times


 
#41696 - Interfacing LCD
Hi again.

I just finished my reply to Cristian and I think it is better to write this under a new subject.

What is the recommended way to connect typical LCD-display with 8052 compatible? I have pullup resistors (10k)on ports P0 and P2 and direct connections to LCD-unit.

What can possibly go wrong when I try to write into LCD? Code is very simple, it works nicely with Keil uV2, it goes nicely throught with no problem, but after flashing it into AT89S8252 it keeps rolling for seconds and keeps writing funny stuff, allmost the right but somethings missing and somthings too many times. Sometimes it works maybe once but very randomly. Maybe it is the circuit and timing matter.

I put these lines here:

DB0 EQU P0.0
DB1 EQU P0.1
DB2 EQU P0.2
DB3 EQU P0.3
DB4 EQU P0.4
DB5 EQU P0.5
DB6 EQU P0.6
DB7 EQU P0.7
EN EQU P2.7
RS EQU P2.6
RW EQU P2.5
dataport EQU P0


org 0000H ; ohjelma alkaa paikasta 0 ( = osoitteesta 0)

SETB EN
CLR RS
MOV dataport,#34h
CLR EN
LCALL WAIT_LCD



SETB EN
CLR RS
MOV dataport,#0Eh
CLR EN
LCALL WAIT_LCD


SETB EN
CLR RS
MOV dataport,#06h
CLR EN
LCALL WAIT_LCD


LCALL INIT_LCD
LCALL CLEAR_LCD
MOV A,#'J'
LCALL WRITE_TEXT
MOV A,#'U'
LCALL WRITE_TEXT
MOV A,#'S'
LCALL WRITE_TEXT
MOV A,#'T'
LCALL WRITE_TEXT
MOV A,#' '
LCALL WRITE_TEXT
MOV A,#'F'
LCALL WRITE_TEXT
MOV A,#'O'
LCALL WRITE_TEXT
MOV A,#'O'
LCALL WRITE_TEXT
MOV A,#'L'
LCALL WRITE_TEXT
MOV A,#'I'
LCALL WRITE_TEXT
MOV A,#'N'
LCALL WRITE_TEXT
MOV A,#'G'
LCALL WRITE_TEXT
MOV A,#' '
LCALL WRITE_TEXT
MOV A,#'A'
LCALL WRITE_TEXT
MOV A,#'R'
LCALL WRITE_TEXT
MOV A,#'O'
LCALL WRITE_TEXT
MOV A,#'U'
LCALL WRITE_TEXT
MOV A,#'N'
LCALL WRITE_TEXT
MOV A,#'D'
LCALL WRITE_TEXT
MOV A,#'!'
LCALL WRITE_TEXT
jmp theend



CLEAR_LCD:
SETB EN
CLR RS
MOV dataport,#01h
CLR EN
LCALL WAIT_LCD
RET


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


INIT_LCD:
SETB EN
CLR RS
MOV dataport,#34h
CLR EN
LCALL WAIT_LCD
SETB EN
CLR RS
MOV dataport,#0Eh
CLR EN
LCALL WAIT_LCD
SETB EN
CLR RS
MOV dataport,#06h
CLR EN
LCALL WAIT_LCD
RET






WAIT_LCD:

SETB EN ;Start LCD command
CLR RS ;It's a command
SETB RW ;It's a read command
MOV dataport,#07Fh ;Set all pins to FF initially
MOV ACC,dataport ;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 commands
RET

theend:
end


List of 10 messages in thread
TopicAuthorDate
Interfacing LCD            01/01/70 00:00      
   RE: Interfacing LCD            01/01/70 00:00      
   RE: Interfacing LCD            01/01/70 00:00      
      RE: Interfacing LCD            01/01/70 00:00      
         RE: Interfacing LCD            01/01/70 00:00      
            RE: Interfacing LCD            01/01/70 00:00      
   RE: Interfacing LCD            01/01/70 00:00      
      RE: Interfacing LCD            01/01/70 00:00      
   RE: Interfacing LCD            01/01/70 00:00      
      RE: Interfacing LCD            01/01/70 00:00      

Back to Subject List