Vous êtes sur la page 1sur 3

Microcontroller Lab

Expt No. 7
1.

VI Sem. B.Tech. Biomedical Engineering

Keyboard and Display programs

Read the key code of the key pressed and display the code in the data field of the
display.
START:

LCALL RDKBD
MOV 60h, A
MOV F0h, #00h
LCALL UPDDT
LJMP START

; read the keyboard


; copy the code read into input location of UPDDT
; No dot
; display the code in the data field
; read another key

Except RESET key, read and note the key codes of all key.

2.

Display HELLO in trainer display.


START:

CLR D5h
MOV DPTR, # 8050
LCALL OUTPUT
LJMP START

; select program memory ( flag F0=0)


; starting location of codes
; output codes
; display continuously

Keep data (Seven Segment codes) from 8050 to 8056 program memory as follows:

Memory location
8050
8051
8052
8053
8054
8055
8056

Character
E
L
L
O
b (blank)
b (blank)
H

Code (HEX)
97
83
83
F3
00
00
67

Format of Seven Segment:


Bit
Segment

3.

B7 B6 B5
d
c
b

B4
a

B3
dp

B2
g

B1
f

B0
e

Input a single digit decimal number through the key board and display its square
value in the data field of the display.
START:

LOOP:

LCALL RDKBD
MOV F0h, A
MOV R0, A
XRL A, R0
ADD A, F0h

; read the decimal digit into A


; value to be added
; count in R0 for repeated addition
; clear A
; successive decimal addition
1

Department of Biomedical Engineering, Manipal Institute of Technology, Manipal 576 104

Microcontroller Lab

VI Sem. B.Tech. Biomedical Engineering

DA A
DJNZ R0, LOOP
MOV 60h, A
LCALL UPDDT
LCALL DELAY
LJMP START

; display square value in the data field


; delay of 1 sec
; find square of another number

Display SPICE UP for 1 sec and blank for 2 sec.

4.

START:

CLR D5h
MOV DPTR, # 8050h
LCALL OUTPUT
LCALL DELAY
CLR D5h
MOV DPTR, # 8060h
LCALL OUTPUT
LCALL DELAY
LCALL DELAY
LJMP 0003h

; select program memory


; address of characters
; output characters
; 1 sec delay
; select program memory
; Blank codes
; display blank
; for 2 sec.
; return to monitor program

Memory tables:
SPICE UP
Memory
Character
location
8050
P
8051
I
8052
C
8053
E
8054
U
8055
P
8056
S

5.

Code (HEX)
37
60
93
97
E3
37
D6

Blank
Memory
location
8060
8061
8062
8063
8064
8065
8066

Character
b (blank)
b (blank)
b (blank)
b (blank)
b (blank)
b (blank)
b (blank)

Code (HEX)
00
00
00
00
00
00
00

Flash HELP in the address field for 1 sec (1 sec HELP and blank for 1 sec).

START:

CLR D5h
; select program memory
MOV DPTR, #8050h ; display HELP for 1 sec
LCALL OUTPUT
LCALL DELAY
MOV DPTR, #8060 ; display blank for 1 sec
LCALL OUTPUT
LCALL DELAY
LJMP START
; repeat

2
Department of Biomedical Engineering, Manipal Institute of Technology, Manipal 576 104

Microcontroller Lab

Memory tables:
SPICE UP
Memory
Character
location
8050
E
8051
L
8052
P
8053
b (blank)
8054
b (blank)
8055
b (blank)
8056
H

VI Sem. B.Tech. Biomedical Engineering

Code (HEX)
97
83
37
00
00
00
67

Blank
Memory
location
8060
8061
8062
8063
8064
8065
8066

Character
b (blank)
b (blank)
b (blank)
b (blank)
b (blank)
b (blank)
b (blank)

Code (HEX)
00
00
00
00
00
00
00

EXERCISES
1. Input two 2-digit HEX numbers from the keyboard. Display each number in the data
field and when NEXT key is pressed display their product in the address field of the
display.
2. Input a 4-digit HEX address of a memory location from the keyboard and display its
content in the data field of the display when NEXT key is pressed.
3. Write an assembly language program to flash SPICE only 10 times (display SPICE
for 2 sec and blank for 1 sec).
4. Roll SPICE continuously (a) left side (b) right side.
PRACTICE PROGRAMS
1. Input a 2-digit BCD number through the keyboard, convert BCD data into HEX, and
display HEX equivalent in the data field if C key is pressed.
2. Write a program to accept a 2 digit HEX number from the keyboard and on pressing
PREV key display its square root if it is a perfect square, else display FFFF.
3. Input a single digit number. If the number is zero, run a decimal up counter, if the
number is 1 run a decimal down counter.
4. Read two 4-digit HEX numbers from the keyboard, add them and flash the result in the
display.

3
Department of Biomedical Engineering, Manipal Institute of Technology, Manipal 576 104

Vous aimerez peut-être aussi