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

keypad to LCD help

hi, i have been writing an assembly code for 89c51,which allows me to send data to lcd by keypad. But the lcd only showing me the initialize step and, no matter how i hit the keypad button,it wont show me any result.the keypad that i am using 4x4 matrix keypad. i really need someone's help and i appreciate it very much.

org 0000h               //initial lcd
mov a,#38h            
acall comnwrt

mov a,#01h
acall comnwrt 

mov a,#02h 
acall comnwrt 

mov a,#0fh
acall comnwrt 

	mov p2,#0ffh; input port 
k1:  	mov p0,#0; output port 
 	mov a,p2
	anl a,#00001111B
        cjne a,#00001111B,k1
k2:   
        mov a, p2
        anl a,#00001111B
        cjne a,#00001111B,over
        sjmp k2
over: 
 	mov a,p2
        anl a,#00001111B
	cjne a,#00001111B, over1
	sjmp k2
over1: 	mov p0,#11111110B
        mov a,p2
	anl a,#00001111B
	cjne a,#00001111B,row_0

        mov p0,#11111101B
        mov a,p2
	anl a,#00001111B
	cjne a,#00001111B,row_1
	
	mov p0,#11111011B        
        mov a,p2
	anl a,#00001111B
	cjne a,#00001111B,row_2

	mov p0,#11110111B
        mov a,p2
	anl a,#00001111B
	cjne a,#00001111B,row_3

row_0:	mov dptr,#kcode0
        sjmp find

row_1:	mov dptr,#kcode1
        sjmp find

row_2:	mov dptr,#kcode2
        sjmp find

row_3:	mov dptr,#kcode3
        

find:	rrc a
	jnc match 
	inc dptr
	sjmp find

match:	clr a
	movc a, @a+dptr
        acall datawrt 
	ljmp k1



	org 300h
kcode0: db	'0','1','2','3'
kcode1: db	'4','5','6','7'
kcode2: db	'8','9','A','B'
kcode3:	db	'C','D','E','F'


comnwrt: mov p1,a  //send command
	 acall delay1
	 clr p3.7  //connect to rs(lcd) 
         acall delay1  
	 setb p3.6 //connect to e(lcd)
         acall delay5
	 clr p3.6
         acall delay1
         ret

delay1: mov r3,#50
here2: mov r4,#255
here: djnz r4,here
      djnz r3,here2
ret

delay5:mov r3,#250
here3: mov r4,#255
here1: djnz r4,here1
      djnz r3,here3
ret

 delay10:mov r3,#255
       
  here4: mov r4,#255
  here5: djnz r4,here5
         djnz r3,here4
ret

datawrt: mov p1,a //send data to lcd 
	 acall delay1
	 setb p3.7
         acall delay1  
	 setb p3.6
         acall delay1
	 clr p3.6
         acall delay10
         ret

end

0