0% found this document useful (0 votes)
20 views7 pages

Experiment 9

Uploaded by

dharshanbv4dgm
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views7 pages

Experiment 9

Uploaded by

dharshanbv4dgm
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

NAME: B V DHARSHAN

REG NO: 21BMH1212


SLOT: L29+L30

MICROPROCESSORS AND MICROCONTROLLERS


EXPT 9
Keypad Interface Programming of 8051
Aim:
To implement and execute basic programs to perform move operations in 8051
Microcontroller using Keil Software.
Software Required:
Keil Software (µ vision5)
Procedure:
1. Create a Project (.uvproj) by selecting “Project -> New μvision Project”
2. Save your project in D: drive with your register number as a file name
3. Select device for target as “Atmel -> AT89C51ED2”
4. Select “No” for adding STARTUP.A51 file to project
5. Create a asm file by right click on “Source Group 1) and select “Add
items toSource group 1”
6. Then select “asm file” option and give name for the asm file and save
7. Write the asm program on the editor and save it.
8. To verify errors in the program first select “Translate” option
9. If any error correct the error and save it before performing Translate option
again
10.If no error then click on “Build” icon to generate supported files
11.To run and verify your program first get into debug mode by selecting
“start/stopdebugging session” icon.
12. To run and verify your program select run icon or press
F5(Shows final output after executing entire program)
13. To perform step by step execution of the program select “step” icon or
F11(shows output for every instruction execution)
14. Analyse registers and memory locations to verify the correctness of the
program
Program-1 (Keypad Interface)
Code:
ORG 000H
SJMP
START
ORG
0030H
START: MOV
P0,#0FFHACALL
LCD_INITIALIZE
K1: MOV
P1,#0
MOV
A,P0
ANL A,#00001111B
CJNE
A,#00001111B,K1
K2: ACALL
DELAY
MOV A,P0
ANL A,#00001111B
CJNE
A,#00001111B,OVER
SJMP K2

OVER: ACALL DELAY


MOV A,P0
ANL A,#00001111B
CJNE
A,#00001111B,OVER1
SJMP K2
OVER1: MOV
P1,#1111110B
MOV A,P0
ANL A,#00001111B
CJNE
A,#00001111B,ROW_0
MOV P1,#11111101B
MOV A,P0
ANL A,#00001111B
CJNE
A,#00001111B,ROW_1
MOV P1,#11111011B
MOV
A,P0 ANL A,#00001111B
CJNE
A,#00001111B,ROW_2
MOV P1,#11110111B
MOV A,P0
ANL A,#00001111B
C E A,#00001111B,ROW_3
J LJMP K2
N
ROW_0: MOV DPTR, #KCODE0
SJMP FIND
ROW_1: MOV DPTR, #KCODE1
SJMP FIND
ROW_2: MOV DPTR, #KCODE2
SJMP FIND

ROW_3: MOV DPTR, #KCODE3


FIND: RRC
A JNC
MATCH
INC DPTR
SJMP
FIND
MATCH: CLR A
MOVC
A,@A+DPTR
ACALL
LCD_DATA
LJMP K1
LCD_INITIALIZE: MOV
A,#38HACALL
LCD_COMMAND
MOV A,#0EH
ACALL
LCD_COMMAND
MOV A,#01H
ACALL
LCD_COMMAND
MOV A,#06H
ACALL
LCD_COMMAND
MOV A,#80H
ACALL
LCD_COMMAND
RET
LCD_COMMAND:MOV
P2,ACLR P3.7
CLR P3.6
SETB P3.5
ACALL
DELAYCLR
P3.5
RET
LCD_DATA: MOV
P2,ASETB P3.7
CLR P3.6
SETB P3.5
ACALL
DELAYCLR
P3.5
RET
DELAY: MOV R4,#40
REPEAT: MOV
R5,#230 REPEATT:DJNZ
R5,REPEATT DJNZ
R4,REPEAT
RET
ORG 300H
KCODE3: DB 'C','D','E','F';ROW 3
KCODE2: DB '8','9','A','B';ROW 2
KCODE1: DB '4','5','6','7';ROW 1
KCODE0: DB '0' , '1' , '2','3';ROW
0END
Output:

Result:

This assembly code for the 8051 microcontroller initializes an LCD display and
continuously scans a keypad matrix. When a key press is detected, it retrieves the
corresponding character from a lookup table and displays it on the LCD. The
program utilizes subroutines for LCD initialization, sending commands and data to
the LCD, and implementing delays.

You might also like