Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Can someone please explain the "readKey" subroutine in this code

Status
Not open for further replies.

VortX

New Member
I haven't learnt the coding part of keypad integration in 8051 yet, but I'm aware of the working and theory behind the integration. I'd really appreciate it if someone explains the readKey subroutine in the attached file. Thanks in advance.


- Kat
 

Attachments

  • myCalculator.asm
    6.7 KB · Views: 274
'readKey' is a subroutine that reads a keyboard.
The type of keyboard is unspecified, with no program comments and no schematic to give clues to its operation.
More information is needed.
 
'readKey' is a subroutine that reads a keyboard.
The type of keyboard is unspecified, with no program comments and no schematic to give clues to its operation.
More information is needed.
Here's the commented code with the schematic. Sorry for not including these before.
 

Attachments

  • myCalculator.asm
    18.8 KB · Views: 264
  • CalculatorV2.0_Sch.png
    CalculatorV2.0_Sch.png
    85.9 KB · Views: 302
I think I understand how the subroutine works now. K1 checks for key is released from previous input and moves on to K2 if the key is released. K2 detects key input by checking if any of the columns are Low and moves on to the next loop OVER, which checks for any debounce. If there is a Low value in any of the column after the 20ms time delay, it moves on to the next loop and hence signifies that there is no debounce or else moves back to K2 to detect an input again. The OVER1 loop identifies the row by grounding each row one after the other and checking for a low output in the columns. After finding the row, finding the column is as easy as checking if the Carry Bit is low for any of the row buttons. I may be wrong, and if I am please correct me.

This presentation helped me understad the working of the keypad: https://nptel.ac.in/content/storage2/courses/106108100/pdf/Teacher_Slides/mod3/M3L7.pdf

Hope this helps.
- Kat
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top