We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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
Hi there, did you try to display anything on that LCD? Maybe the initialization didn't work. I'd try that out first. A hint: the timing of the LCD is a bit tricky... don't do the things you do too fast... some NOPs and otehr kind of delays are pretty helpful. What kind of LCD controller is it? Take care Sven
i have sent the data to the LCD and it works fine. so i think my initialization and send data command should be fine. thanks pal
Did you take the key bounce in account? When you press or release an mechanic switch, it will usually bounce for some 10ms. That means, it will change it's state a couple of times while that periode. If you have a 4x4 key matrix, you should keep a status byte for each of your 4 columns and compare the present state of each column to that status byte. If it doesn't change for 20 or 30 ms you can consider the bouncing to be over. Then you can determin the new keys that have been pressed or released by xor-ing the present valid status with the previous valis status. Then you should set up some rules what happens when two keys have been pressed at the same time and write the algorithm for it. This way, you can determin, which key is pressed and what value you want to display. Take care Sven
thanks for ur reply. but i did the dbounce check b4 in my program and it seems to me that it doenst work too. thanks
1. Are all 8 pins of the matrix connected to port 2? 2. If so, you don't want to write an FF to port 2, but you want to set one column low and the rest high. 3. You have a jump to K2, but port 2 is not being reset to FF, which was done befor K1.
if u have got the corrected the code... can u mail me the code where whenever a key is pressed it is displayed on the LCD .... plz m in need of this program
if u have got This is a FORUM, not a place for messages to ONE person. If you want to say something to micro, e-mail him directly. Erik