Keypad matrix with 8051 micro help

Thread Starter

CALcircuits

Joined May 5, 2009
3
I have found a sample code for an 8051 microcontroller and programming it to read a keypad matrix. I need a little help understanding the code. Here is what i found:

here is the link to the code, i am just looking at the assembly code:

http://www.8051projects.net/keypad-interfacing/8051-programming.php

And I found the instruction set here:
http://www.atmel.com/dyn/resources/prod_documents/doc0509.pdf

I am having trouble understanding what the keyval equ 30H is doing and how the rows are being read from this. Is the, pressed bit 0H, just an assigned variable.
 

AlexR

Joined Jan 16, 2008
732
The program set a variable keyval hold the key number, I would assume the 30H is the location of keyval (I'm not realy up with 8051 assembler).

It then puts a low on the first row and scans through the columns looking for a low.

Each time it fails to find a low it increments keyval.

It then put the low on the second row and repeats the process.

And so on until it either finds a low key or it comes to the end of the keys.

When it find a low it waits for the key to be released (a high) and ends, keyval will contain key number that was pressed.
 
Last edited:

Arm_n_Legs

Joined Mar 7, 2007
186
keyval equ 30H: This 30H refers to internal data memory location 30H. In this context, it is just a location to store the variable keyval.
 

rushi53

Joined May 8, 2009
21
keyval equ 30H
it means wherever keyval word occurs, replace it with 30H
this command has 2 purpose
1) it gives readability to program, by this I mean, u can understand the meaning of pins/memory used for
2) it gives quick replaciblity - this means u can replace any pins/memory very quickly

let me know if you need more explanation


--------------------------------------------
Thanks,
Rushikesh
www.projectsof8051.com
 
Top