microcontroller123
Junior Member level 1
hi.. i have interfaced the 4x3 keypad and 16x2 LCD with 8051 micro-controller..
its working properly but the problem is that i need the data to be written on the LCD digit by digit... but in my case i am getting over write on the previous digit by the new one.. here is my code.. kindly help me its the part of my FYP..
Thanks
but its not working properly and the LCD isn't showing any data due to the presence of the instruction djnz r5,again
its working properly but the problem is that i need the data to be written on the LCD digit by digit... but in my case i am getting over write on the previous digit by the new one.. here is my code.. kindly help me its the part of my FYP..
Thanks
Code:
org 0h
;keypad --> port1
;LCD --> port2
;RS --> p0.0
;R/W --> p0.1
;E --> p0.2
main:
mov r5,#2d
again:
mov p1,#00000111b
mov a,p1
anl a,#00000111b
cjne a,#00000111b,again
again1:
acall delay
mov a,p1
anl a,#00000111b
cjne a,#00000111b,check
sjmp again1
check:
mov a,p1
anl a,#00000111b
cjne a,#00000111b,check1
sjmp again1
check1:
mov p1,#11110111b
mov a,p1
anl a,#11110111b
cjne a,#11110111b,row0
mov p1,#11101111b
mov a,p1
anl a,#11101111b
cjne a,#11101111b,row1
mov p1,#11011111b
mov a,p1
anl a,#11011111b
cjne a,#11011111b,row2
mov p1,#10111111b
mov a,p1
anl a,#10111111b
cjne a,#10111111b,row3
ljmp again1
row0:
mov dptr,#code0
sjmp find
row1:
mov dptr,#code1
sjmp find
row2:
mov dptr,#code2
sjmp find
row3:
mov dptr,#code3
sjmp find
find:
rrc a
jnc match
inc dptr
sjmp find
match:
clr a
movc a,@a+dptr
mov r2,a
/// here the pointer stuck on "acall display_start" and dont go for djnz
acall display_start
//using djnz to take input twice and display two digits on the LCD
// r5 is loaded with the value two as mentioned above.. mov r5,#2d
djnz r5,again
delay:
mov r0,#72
label:
mov r1,#255
label1:
djnz r1,label1
djnz r0,label
ret
display_start:
mov a,#38h
acall command
mov a,#0eh
acall command
mov a,#01h
acall command
mov a,#06h
acall command
mov a,#86h
acall command
mov a,r2
acall display
ret
command: acall ready
mov p2,a
clr p0.0
clr p0.1
setb p0.2
clr p0.2
ret
display: acall ready
mov p2,a
setb p0.0
clr p0.1
setb p0.2
acall delay1
clr p0.2
ret
ready: setb p2.7
clr p0.0
setb p0.1
back: clr p0.2
acall delay1
setb p0.2
jb p2.7,back
ret
delay1: mov r3,#50
here:
mov r4,#255
here2:
djnz r4,here2
djnz r3,here
ret
org 300h
code0: db "1","2","3"
code1: db "4","5","6"
code2: db "7","8","9"
code3: db 2Ah,"0",23h
end
but its not working properly and the LCD isn't showing any data due to the presence of the instruction djnz r5,again
Last edited by a moderator: