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 some 1 get me the code for this please ..really need it

Status
Not open for further replies.

ozikid

New Member
This program is designed to help you understand keypad programming using T89C51AC2
; Your task is to write a subroutine for the public section of the keypad library and insert the 16 scan codes.
;
; Part A Use your keypad to work out the 16 scan codes and insert them in the SCode ROM table below in binary.
;
; Part B Write the decode routine that converts a keypad scan code into its table offset value. This is done
; by searching for the matching scan code in the SCode array. The routine returns this index in ACC
;
; Test you program in the LCD-KeyPad simulator for a number of different scan code values
;/*----------------------------------------------------------------------------------------------------------


dseg At 21h
stack: ds 1 ; reserve stack space

cseg
;/*--------------------------------------------------------------------------------------
Main:
mov sp,#stack ; Set up stack area
M1:
acall process ; display any key pressed - ACC holds the result
sjmp M1 ; do it all again
ret

;/*--------------------------------------------------------------------------------------
process:

mov a,#10111101b ; TEST value - *** change this for testing ***
acall decode ; Decode key
ret


;########################################################################################
; Key Pad Subroutine Library for EMU750
;########################################################################################
;LCD Constants
;~~~~~~~~~~~
ALL_ON equ 0F0h ; turns on all rows, also iused to compare
ROW0 equ 0FEh ; used to initialize first row
ROW4 equ 0EFh ; used to check for last row
CODE_CNT equ 16 ; number of scan codes

KP_PORT equ P0 ;port 0 8 bits

;*****************************************************************************************
; Public Subroutines - called from main section of code
;*****************************************************************************************




; *** leave this area empty





;*****************************************************************************************
; Private Subroutines - Not used in an application
;*****************************************************************************************

;/*--------------------------------------------------------------------------------------
;TASK: Converts a keypad scan code into an array index value between 0 and 15
;@param: ACC - has the scan code to be converted
;@return: ACC - holds the array index related to the scan code
;/*--------------------------------------------------------------------------------------
Decode:


; Your code here - You must preserve all registers used except ACC



ret



; *** SAMPLE Scan Codes ONLY - Change these k-pad scan codes to the correct ones

SCode: db 11101011b, 01110111b, 01111011b, 01111101b
db 10110111b, 10111011b, 10111101b, 11010111b
db 11011011b, 11011101b, 01111110b, 10111110b
db 11011110b, 11101110b, 11100111b, 11101101b
; db 11111111b

;#########################################################################################


end
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top