Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics 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.

can anyone pls post a simple LCD code for me

Status
Not open for further replies.

kaarthic

Newbie level 5
Joined
May 24, 2007
Messages
10
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,345
simplelcd

plz, can anyone pls post a simple LCD code for me?
I just need to know how to show a word in a 2x16 LCD.
I'm using Microchip PIC16F877A at the same time i want get signal via RF modul

Preferably PIC C language!

I try the routine provided by them but still doesnt work.



Thanks for help
 

Here is some code.

Change the processor type to 16F876A.
The code uses 4-bit data bus, on bits 7:4 of port C. Enable and RS lines are also on port C. The /WR pin should be tied to GND, since this code never reads anything from the LCD, it just writes to it.

It should print Hello on the first line and Friend! on the second line.
Let me know if you have problems.
 

You may look at my beginners project.
**broken link removed**

The code is written for MCC18, but you can probably modify it.
 

hi iam sending you code for lcd program using c8051f005 ic using silicon laboratories
----------------------------------------------------------------------------------------------

$include (c8051f000.inc)

rw equ P1.3
rs equ P1.4
io_clk equ P1.6
enb equ P1.7
position equ r1


org 0000h
clr ea ;disable watch dog timer
mov wdtcn,#0deh
mov wdtcn,#0adh
setb ea

mov xbr0,#07h ;setting crossbar register
mov xbr1,#00h
mov xbr2,#40h

mov PRT0CF,#36h ;configuring ports
mov PRT1CF,#0ffh
mov PRT2CF,#23h
mov PRT3CF,#00h

clr rs
clr rw
clr enb
setb io_clk

mov oscxcn,#67h ;configuring ext oscillator
mov r4,#16
a2:mov r5,#255
a1:djnz r5,a1
djnz r4,a2
a3:
mov a, oscxcn
jnb acc.7, a3
mov oscicn,#08h ;disable internal oscillator
orl oscicn, #80h




mov r3,#15 ;delay for 15ms
call delay ;initialise lcd for 2 lines
mov a,#38h
call comnwrt

mov r3,#5 ;delay for 5ms
call delay ;initialise lcd for 2 lines
mov a,#38h
call comnwrt

mov r3,#1 ;delay for 1ms
call delay ;initialise lcd for 2 lines
mov a,#38h
call comnwrt


mov a,#08h; ;display off
call comnwrt

mov a,#01h; ;clear display
call comnwrt


mov a,#06h;
call comnwrt

mov a,#02h; ; return home
call comnwrt


mov a,#0eh; ;display on cursor on
call comnwrt


mov r1,#2;
call set_cursor



; mov a,#44h ;send 'd' to lcd
;call datawrt

; mov a,#14h; ;shift cursor right
;call comnwrt


mov dptr,#lcd_mesg
call display_msg

jmp $


comnwrt:call check_busy
clr rs
clr rw
mov P3,a
setb enb
nop
clr enb
nop
ret

datawrt:call check_busy
setb rs
clr rw
mov P3,a
setb enb
nop
clr enb
nop
ret




display_msg:

again:clr a
movc a,@a+dptr
cjne a,#'$',ds_1
ret
ds_1:
call datawrt
mov r3,#200 ;delay for 200ms
call delay
inc position
mov a,r1;
cjne a,#39,z
mov r1,#0
z:call set_cursor
inc dptr
jmp again


check_busy: push acc
mov r3, #01
call delay
mov PRT3CF,#0ffh
mov P3, #00
clr rs
setb rw
busy_loop :setb enb
nop
mov a, P3
clr enb
jb acc.7,busy_loop
clr rs
clr rw
mov PRT3CF,#00h
pop acc
ret

set_cursor:mov a,#20
subb a,r1
jz n2
jc n2

n1:mov a,r1
add a,#80h
call comnwrt
ret
n2:mov a,r1
add a,#0ach
call comnwrt
ret






delay:
x1:mov r4,#16
x2:mov r5,#255
x3:djnz r5,x3
djnz r4,x2
djnz r3,x1
ret

lcd_mesg : db 'LCD INTERFACING IS COMPLETED' ,'$'

end
 

i have posted 4 wire code for hd44780 in sdcc and keil check it
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top