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.

Interrupt-Driven Keypress for 8051

Status
Not open for further replies.

qbcs

Newbie level 4
Joined
Apr 14, 2008
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,333
keypress interrupt

Hi All,

I have developed an 8051-based controller. The controller has a number of peripherals. One of them is a set of 7 keys. Upon pressing a key, certain function(s) would be performed. The keypress routine is hoped to be interrupt-driven rather than standard scan key. When I have tried to make use of the available routines, such as KeyRead_Int.asm by J. Flanagan (**broken link removed**) and Buttons.asm by Dave Fletcher (**broken link removed**), I have failed to coordinate the main program with the interrupt service routine. When I have tried to test my program using 8051 simulator, everything seems good. When hardware is used, not all keypresses could be recognized. Most of successive key press were ignored. For example, pressing Down for the first time has no problem, but pressing it again yields no response.
Would you kindly try to take a look at my test programs, using the above routines, and help to fix the problem thanking you in advance.

Thanks
 

8051 missing interrupts

Can you add the complete hardware schematic?
 
  • Like
Reactions: swayzee

    swayzee

    Points: 2
    Helpful Answer Positive Rating
8052 key debounce

Thanks for your kind attention. It would be my pleasure to send the relevant schematic diagram.

Thanks again
 

8051 interrupt circuit

Dispense with the extra hardware and read the keys from a timer interrupt. This will also give you a debounce delay and simplify your circuit. 1ms will be a suitable time.
 

8051 level sensitive interrupt

Hi Davidgrm,
Thanks for your comment. The keys would be rarely used. These are designed to be used for initial setting and for checking, if required, for long intervals. Therefore, it would not be wise to use them in the timer interrupt.
Thanks again.
 

interrupt driven programming 8051

It is a bad idea to use a level-sensitive interrupt, but that's not the main problem.

The interrupt does not sense the button release. So, if you press the same button again, the pattern on P0 seen inside the interrupt won't change, so it behaves as if you would hold the button down without releasing it.

JW


PS. Why don't you come to the 8052.com Forum to discuss the issue with a group of people devoted to 8052?
 

I think problems are due to hardware.
Port P0, pins 32 to 39, need pull-up resistors (10k or less).
Resistor RX 100k and diodes CE1 .. CE7 must be eliminated (replace RX 100k with a short). In addition, you should replace chips 7430, 74LS04 and 74LS138 by lower consumption chips.
 

Port P0 has pull-up resistors of 10k. Resistor RX and diodes CR1 to CR7 are not currently used. However, these could be eliminated. Unfortunately, the schematic diagram does not reflect minor details.
Low power consumption chips would be used for 7430, 74LS04 and 74LS138.
Edge sensitive interrupt is also set.
The main problem is, in simple words, in the ISR. The ISR is intended to get pressed key and return the corresponding bit to the main program. Debounce and pressing for a long interval should be avoided and/or solved by the routine. The used subroutines could be found easily on one of the important sites of 8051 (www.8052.com). I still hope that one could go directly to the ISR, to check what could be missing there, or what could be missing in my main code to make use of the routine. An alternative ISR that would do the job could be accepted.
Thanks.
 

qbcs said:
Edge sensitive interrupt is also set.
No, it is not.

qbcs said:
The main problem is, in simple words, in the ISR.
Yes, I said so above.

qbcs said:
I still hope that one could go directly to the ISR, to check what could be missing there, or what could be missing in my main code to make use of the routine.

I said above: button release sensing is missing. Try visualize, WHAT happens when the button is released, and WHAT do you expect to happen.

Please read carefully the comment to the code you downloaded from 8052.com; note, how should that routine be used.

qbcs said:
An alternative ISR that would do the job could be accepted.
Ooooh, that would be too easy for you, and nobody would gain from that. Better, let's discuss it, and you will learn by experience.

Again, you better come with this matter to 8052.com's forum, you will receive more answers there.

JW
 

Hi,
WEK, infact he will be able to go back to his main program only after the button is released because of level sensing. Also I find the initial values of storage registers are not defined as 0X0ff. I would have rather preferred a timer based key scanning, same timer interrupt used for other processes, connect the LEDs to the same port as the switches, use a 4bit LCD interface and throw off all other peripheral ICs except the MAX232 and ADC (Just a loud thinking.).

Regards,
Laktronics
 

Hi,
WEK, thanks for your valuable comments. I have mentioned that: "Edge sensitive interrupt is also set" in the updated version of my code.
Kindly, notice again that I have mentioned more than once that the ISR is taken from the resources of 8052.com!!! I still hope that one could check again that routine as could be found there. I'll try to join 8052 forum. Thanks again.
LAKTRONICS, thanks for your comments. I hope that you could discuss the issue of storage registers. I have noticed no change in this issue.
Timer based key scanning would not be preferred because of the fact that the keys would be used ONLY for two occasions: (1) to set the initial setup of the parameters and (2) to review the current status of the system. The two occasions could not be used for a long period. That is the main reason behind using this routine with the external interrupt. I would try to take into consideration your suggestions. Thanks again.
 

qbcs said:
I have mentioned that: "Edge sensitive interrupt is also set" in the updated version of my code.
Great. And where can we see that? It's quite hard to provide help on something we can't see... :-|

qbcs said:
Kindly, notice again that I have mentioned more than once that the ISR is taken from the resources of 8052.com!!! I still hope that one could check again that routine as could be found there.
Assuming you are talking about **broken link removed**, it says explicitly in the comment, "The subroutine was designed to be called from the main loop of a real time application." and "It is called during every pass through the main loop". If used as such, it will work as expected.

JW
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top