Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problem with lcd interface

Status
Not open for further replies.

ssamanth777

Newbie level 4
Joined
May 12, 2011
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,326
I had been trying to interface an LCD with 89v51rd2 , i am able to flash the HEX file into it but the LCD is not even initializing
I believe the hardware connections are all proper. please HELP

LCD-(8) data pins,(1) rs,(1) en,(1) R/W

I also tried the codings for 8-bit and 4-bit data it didnt work
 

nandhu015

Advanced Member level 5
Joined
Feb 11, 2006
Messages
1,965
Helped
300
Reputation
600
Reaction score
224
Trophy points
1,353
Location
India
Activity points
9,837
Post your code and clear circuit diagram, then we can get it solved
 

ssamanth777

Newbie level 4
Joined
May 12, 2011
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,326
code i had used for lcd interface

org 0000h
sjmp start

org 0045h
start:rs equ p3.0
en equ p3.1
mov p1,#00h

mov dptr,#command
acall command_write

sjmp $

command_write:
clr rs
h6: clr a
movc a,@a+dptr
jz h4
acall swapp
inc dptr
sjmp h6
h4: ret

swapp:
mov p1,a
acall enable
acall delay
clr rs

ret

enable:
setb en
acall delay
clr en
acall delay
ret

delay:
mov r5,#25h
here1: mov r4,#3fh
here2: djnz r4,here2
djnz r5, here1
ret





;-----------------------------------------
; Commands & Data
;-----------------------------------------

command: db 38h,0EH,10H,80H,00h
 

ckshivaram

Advanced Member level 5
Joined
Apr 21, 2008
Messages
5,070
Helped
2,149
Reputation
4,304
Reaction score
2,089
Trophy points
1,393
Location
villingen (Germany) / Bangalore
Activity points
30,097
Re: code i had used for lcd interface

first of all the commands should be 38,01,06,0f and 80H....

if lcd is initialised then it will blink the cursor on the 1st line...
 

ssamanth777

Newbie level 4
Joined
May 12, 2011
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,326
Re: code i had used for lcd interface

Ok , i am going to try now

---------- Post added at 04:49 ---------- Previous post was at 04:43 ----------

It is still not responding i am not able to find a cursor on the LCD
 

tahir4awan

Full Member level 4
Joined
Nov 29, 2010
Messages
202
Helped
16
Reputation
32
Reaction score
16
Trophy points
1,308
Location
Germany
Activity points
3,032
Re: code i had used for lcd interface

I think you should use C compiler. I don't find any reason for using assembly language from beginner to intermediate user. Assembly language is used by professional where less code space and fast instruction execution is required. I don't think these are our requirements. In C compiler it is very easy to interface any hardware with microcontroller. I personally prefer MikroC Compiler.Just try it.
 

tahir4awan

Full Member level 4
Joined
Nov 29, 2010
Messages
202
Helped
16
Reputation
32
Reaction score
16
Trophy points
1,308
Location
Germany
Activity points
3,032
There are two types of LCD 4bit and 8bit. If you are using 4bit LCD then you require 4 data lines and RS and EN pins. R/W pin is not used. I don't know what compiler you are using but I prefer to use MikroC compiler and PIC microcontrollers. It is very easy to program in MikroC and interface and you find much examples on the internet.
 

nandhu015

Advanced Member level 5
Joined
Feb 11, 2006
Messages
1,965
Helped
300
Reputation
600
Reaction score
224
Trophy points
1,353
Location
India
Activity points
9,837
ssamanth777

Dont start a new thread for answering the old thread.

THREADS MERGED.
 

dayanpad

Advanced Member level 4
Joined
Mar 23, 2009
Messages
114
Helped
17
Reputation
34
Reaction score
17
Trophy points
1,298
Location
Colombo
Activity points
1,921
Re: code i had used for lcd interface

I think you will helpful to understand LCD initialization
this is part of my program use in commercial purpose
Change DELAY as you wish
thanks go ahead



status equ 0x03
fsr equ 0x04
porta equ 0x05
portb equ 0x06
portc equ 0x07
portd equ 0x08
trisa equ 0x85
trisb equ 0x86
trisc equ 0x87
trisd equ 0x88

lcd_counter equ 0x20
delay_value equ 0x21
dly_count_lsb equ 0x22
dly_count_msb equ 0x23
delay_counter equ 0x24

#define E portd,7
#define RS portc,2

org 0x000
goto main
main clrwdt
call sys_init
call init_lcd
goto main
-----------------------------------------------------------------------------------
init_lcd bsf E
call lcd_init_delay
bcf E

movlw 0x38
call send_lcd
call delay ; LCD initialize
movlw 0x38
call send_lcd
call delay
movlw 0x38
call send_lcd
call delay
movlw 0x38
call send_lcd
call delay

movlw 0x01
call send_lcd
call delay
movlw 0x06
call send_lcd
call delay
bcf E
return
-----------------------------------------------------------------------------
send_lcd bsf E
movwf portb
bcf E
return

delay movlw .3
movwf dly_count_lsb

dly_loop decfsz dly_count_lsb
goto dly_loop
return

sys_init bsf status,5
movlw b'01111011'
movwf trisc
movlw b'00000000'
movwf trisb
movlw b'00000000'
movwf trisd
bcf status,5
clrf lcd_counter
return

end
 
Last edited:

dharampal

Newbie level 3
Joined
Aug 30, 2010
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,299
;here is asm code for 8bit lcd interfacing & i use compiler asm 51
p0 data 80h
p1 data 90h
p2 data 0a0h
p3 data 0b0h


ORG 0000h
mov a,#38h
acall comnwrt
acall delay
mov a,#0Ch
acall comnwrt
acall delay
mov a,#01h
acall comnwrt
acall delay
mov a,#06h
acall comnwrt

acall delay
mov a,#84h
acall comnwrt ;1st line 4th character
acall delay
mov a,#'W'
acall datawrt



mov dptr,#abc
again:
acall delay
mov a,#0c4h
acall comnwrt
clr a
movc a,@a+dptr
acall delay
mov p0,a
acall datawrt

acall delay
inc dptr
CJNE A,#6h,again
sjmp again1

abc: db '12345',6h

again1: sjmp again1
datawrt:
mov p0,a
setb p1.0
clr p1.1
setb p1.2
acall delay
clr p1.2
ret
comnwrt:
mov p0,a
clr p1.0
clr p1.1
setb p1.2
acall delay
clr p1.2
RET



delay:
mov R4,#0fFh
here1: mov r3,#0ffh
here: djnz R3,here
djnz R4,here1
ret

end
 

ssamanth777

Newbie level 4
Joined
May 12, 2011
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,326
I am just a student and i dont know embedded C as its not yet been in the curriculum (to dayanpad)

---------- Post added at 08:22 ---------- Previous post was at 08:20 ----------

the code which i had posted ,is it correct?
 
Last edited:

ckshivaram

Advanced Member level 5
Joined
Apr 21, 2008
Messages
5,070
Helped
2,149
Reputation
4,304
Reaction score
2,089
Trophy points
1,393
Location
villingen (Germany) / Bangalore
Activity points
30,097
the program syntax you have used for commands are not correct... when you use DPTR the command is movc and not mov..

other wise the logc is correct....

---------- Post added at 13:11 ---------- Previous post was at 13:11 ----------

refer 8052.com - The Online 8051/8052 Microcontroller Resource - 8052.com for tutorials and code samples for all interface.........
 

ssamanth777

Newbie level 4
Joined
May 12, 2011
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,326
check this code

org 0000h
sjmp start

org 0045h
start:rs equ p3.0
en equ p3.1
mov p1,#00h

mov dptr,#command
acall command_write

sjmp $

command_write:
clr rs
h6: clr a
movc a,@a+dptr
jz h4
acall swapp
inc dptr
sjmp h6
h4: ret

swapp:
mov p1,a
acall enable
acall delay
clr rs

ret

enable:
setb en
acall delay
clr en
acall delay
ret

delay:
mov r5,#25h
here1: mov r4,#3fh
here2: djnz r4,here2
djnz r5, here1
ret





;-----------------------------------------
; Commands & Data
;-----------------------------------------

command: db 38h,01H,06H,0FH,80H
 

dayanpad

Advanced Member level 4
Joined
Mar 23, 2009
Messages
114
Helped
17
Reputation
34
Reaction score
17
Trophy points
1,298
Location
Colombo
Activity points
1,921
I am just a student and i dont know embedded C as its not yet been in the curriculum (to dayanpad)

---------- Post added at 08:22 ---------- Previous post was at 08:20 ----------

the code which i had posted ,is it correct?

Dear ssamanth777,

first you use Software simulator
in the software simulate it will take some time to blink the cursor
Can I have your hardware design
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top