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.
friends, I am working in an LCD keypad module for an industrial controller using AT89S52 processor. Developemnt platform is KEIL IDE. I have done the coding and right now i am doing testing of coded modules. For this i am using in built simulator of keil. here i am experiencing some problems. I real case all the pins are pulled up so when ever key stroke occcur the corresponding pin will be GNDed. once the key is released i goes back to high again. How this situation cud be simulated in keil. I wrote a debugging function to give external I/P to port pin to signify key strokes. that func is activated on pressing a button. But i have to presss another button to bring port back to norm state. by this time the program would have taken many keystrokes. So i want somthg which will bring port pins back to norm state once keypins are read by simulator. this kinda situation wont arise if you use an in circuit debuger. Thank you Nitin S
But i have to presss another button to bring port back to norm state. by this time the program would have taken many keystrokes What if, in the real world, the user holds the button for a while? - (s)he will, I guarantee it. Erik
"I wrote a debugging function to give external I/P to port pin to signify key strokes." So you need to modify that function to simulate pressing and releasing the key? Have you looked at Signal Functions? As Erik said, you need to ensure that you don't have a real-world problem if the user does hold the key down for "too long!"
Yes that is what i want. Pressing and releasing the key. The case where the user keeps the key pressed for a long time will be taken as multiple press and releases . I will just see if i can do with signal function. Thank you eric and Andy
I wrote a signal function to reset the PORT0 once the has been read . It is look like signal void upkey() { while(1) { if(temp ==1) { exec("PORT0 = 0xFF") ; twatch(10) ; } } } Temp is set to 1 in 8051 code when a port has been read and readg is not 0xFF ie normal state where key is not pressed. But some reason or other i am not getg desired response
I'm not too sure what your signal function is supposed to do, but I think the following is what you really want.
signal void press_key (char k) { PORT1 &= ~(1<<k); /* Clear P1.k */ swatch (0.5); /* Wait .5 sec */ PORT1 |= (1<<k); /* Set P1.k */ swatch (0.5); /* Wait .5 sec */ }
define button "Key 1", "press_key(0)" define button "Key 2", "press_key(1)" define button "Key 3", "press_key(2)"
Thank you Jon this was what i was loking for.