This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

lcd PROBLEM

hi all i am a bit stuck in a problem .

i am using a LAMPEX 24200(HD44780 clone) lcd and trying to interface it with AT89C51 . my problem is i am not able to understand where my problem lies , it seems to me after many hardware tests that it is ok , but software is also ok (as per me )then why is my lcd not functioning .the lcd is ok (tested it )

the code is :



cseg at 000h



DB0 EQU P2.0

DB1 EQU P2.1

DB2 EQU P2.2

DB3 EQU P2.3

DB4 EQU P2.4

DB5 EQU P2.5

DB6 EQU P2.6

DB7 EQU P2.7

RS EQU P3.2

RW EQU P3.3

EN EQU P3.4

DATA_BUS EQU P2

; FUNTION_SET EQU #38h

org 000h



mov R2,#200

timer: mov R3,#100 ; thats a delay of more than 20 mSeconds

djnz R3,$

dec R2

cjne R2,#0,timer



jmp LCD_INIT ;KSCAN







;

;**************************************************************************************

;

; LCD INITIALIZATION

;

;**************************************************************************************



LCD_INIT: setb EN ; Enabling the LCD for Access

clr RS ; Setting it for Instruction transfer mode

clr RW ; Setting it as ins. write mode

mov DATA_BUS,#38h ; Sending the instruction "Function set" specifying DL=1(8 Bits),N=1(2 Line),F=0(5x7 Dots)

nop

nop

nop

clr EN ; Start the transfer

call timer0





setb EN ; Enabling the LCD for Access

clr RS ; Setting it for Instruction transfer mode

clr RW ; Setting it as ins. write mode

mov DATA_BUS,#38h ; Sending the instruction "Function set" specifying DL=1(8 Bits),N=1(2 Line),F=0(5x7 Dots)

nop

nop

nop

clr EN ; Start the transfer

call timer0



setb EN ; Enabling the LCD for Access

clr RS ; Setting it for Instruction transfer mode

clr RW ; Setting it as ins. write mode

mov DATA_BUS,#38h ; Sending the instruction "Function set" specifying DL=1(8 Bits),N=1(2 Line),F=0(5x7 Dots)

nop

nop

nop

clr EN ; Start the transfer

;call LCD_WAIT

call timer0



setb EN ; Enabling the LCD for Access

clr RS ; Setting it for Instruction transfer mode

clr RW ; Setting it as ins. write mode

mov DATA_BUS,#38h ; Sending the instruction "Function set" specifying DL=1(8 Bits),N=1(2 Line),F=0(5x7 Dots)

nop

nop

nop

clr EN ; Start the transfer

;call LCD_WAIT

call timer0



setb EN ;

clr RS ; Instruction Mode

clr RW ;

mov DATA_BUS,#0Fh ; Sending the instruction set 00001111 = 0Fh -> 1DCB -> D= Dislpay On,C= Cursor On,B= Blinking Cursor On .

nop

nop

nop

clr EN ;

;call LCD_WAIT

call timer0





setb EN

clr RS

clr RW

mov DATA_BUS,#1h ; Sending the instruction set 00000001 = 01h -> To clear the Display

nop

nop

nop

clr EN ;

;call LCD_WAIT

call timer0



setb EN

clr RS

clr RW

mov DATA_BUS,#2h ; Sending the instruction set 00000010 = 02h -> To return the cursor to the home position

nop

nop

nop

clr EN ;

;call LCD_WAIT

call timer0



setb EN

clr RS

clr RW

mov DATA_BUS,#6h ; Sets the entry mode i.e the cursor always increments

nop

nop

nop

clr EN ;

;call LCD_WAIT

call timer0



setb EN

clr RS

clr RW

mov DATA_BUS,#14h ; Sets the shift mode to 0 i.e cursor move ,R/L to right shift .

nop

nop

nop

clr EN ;

;call LCD_WAIT

call timer0



setb EN

clr RS

clr RW

mov DATA_BUS,#80h ; sets the DDRAM address to 00H

nop

nop

nop

clr EN ;

;call LCD_WAIT

call timer0

;**************************************************************************************

; Initialization Over

;**************************************************************************************

call LCD_CLEAR



call LCD_WRITE



jmp $



LCD_WAIT:

call timer0

Ret

setb EN ;

clr RS ;

setb RW ;

mov DATA_BUS,0FFh;

nop

nop

nop

clr EN ;

JB DB7,LCD_WAIT

clr EN;

clr RW;

ret





LCD_CLEAR: setb EN

clr RS

clr RW

mov DATA_BUS,#1

nop

nop

nop

clr EN

call LCD_WAIT

ret



LCD_WRITE: setb EN

setb RS

clr RW

mov A,#'B'

mov DATA_BUS,A

nop

nop

nop

clr EN

call LCD_WAIT



setb EN

setb RS

clr RW

mov A,#'O'

mov DATA_BUS,A



nop

nop

nop

clr EN

call LCD_WAIT



setb EN

setb RS

clr RW

mov A,#'U'

mov DATA_BUS,A



nop

nop

nop

clr EN

call LCD_WAIT



ret









timer0: mov R2,#50

timer1: mov R3,#100 ; thats a delay of more than 5 mSeconds

djnz R3,$

dec R2

cjne R2,#0,timer1

ret





end



dejan can you help !!



with regards

som

0