0% found this document useful (0 votes)
36 views11 pages

Mini Project Final

This document defines constants and subroutines for initializing and controlling I/O ports and interrupts to display a welcome message and seven-segment digits on an LCD screen. It scans keyboard input, handles interrupts from sensors, and displays "GATE OPENED" when a key is pressed.
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)
36 views11 pages

Mini Project Final

This document defines constants and subroutines for initializing and controlling I/O ports and interrupts to display a welcome message and seven-segment digits on an LCD screen. It scans keyboard input, handles interrupts from sensors, and displays "GATE OPENED" when a key is pressed.
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/ 11

SYSTEM_PORT_A: EQU 10H

SYSTEM_PORT_B: EQU 11H


SYSTEM_PORT_C: EQU 12H
SYSPORTCTRL: EQU 13H

ORG 802CH ; RST 5.5


JMP ISR_5_5
ORG 8034H ; RST 6.5
JMP ISR_6_5

ORG 8100h
LXI SP, 0F000H
MVI A, 10010000B ;PORT A - INPUT; B,C - OUTPUT
OUT SYSPORTCTRL

;===== INITIALIZED LCD =====

MVI E, 07H ;initialize LCD


RST 1
CALL dlyz1

MVI E, 09H ;clear LCD


RST 1
CALL dlyz1
CALL dlyz1

;----Welcome screen----
WELCOME:
LXI H, 0500H ;1st row
MVI E, 0AH
RST 1
LXI H, DATA1 ;"WELCOME >.<"
MVI E, 0BH
RST 1

LXI H, 0002H ;3rd row


MVI E, 0AH
RST 1
LXI H, DATA2 ;press any button to
MVI E, 0BH
RST 1

LXI H, 0003H ;4th row


MVI E, 0AH
RST 1
LXI H, DATA3 ;" enter."
MVI E, 0BH
RST 1

MAIN: CALL SCAN

1
LDA KEY ; Load newly pressed key data
CPI 0FFH ; check if no key is pressed
JZ WELCOME ; if no key, do not update key data, use
last last key instead
JNZ OPENGATE ; if new key is pressed, update last key
pressed data.

;===== Subroutine of Parking slot Sensor (Interrupt)=====

START: MVIA, 00001100B ; set mask 0000 1100


; 0--not use b6-b7 ->00 is
for SOD/SOE - not relevant
; 0--not use b5 ->n/c
; 0--diable b4 ->1 R7.5
is ENABLE R7.5
; 1--must b3 ->1 Mask
setting enabled
; 1--masked 7.5 b2 ->0 M7.5 is
enabled
; 0--enable 6.5 b1 ->1 M6.5 is
Masked
; 0--enable 5.5 b0 ->0 M5.5 is
enabled
SIM ;Set interrupt masking
EI ;Enable interrupt

LOOPHERE:
MVI A,0fH ;1111 led all lights up
OUT 0
CALL DLY
CMA
OUT 0
CALL DLY ;led blinking
call sev
JMP LOOPHERE
RET

DLY: MVI C,0A0H

INL: MVI B,0FFH


DLY1: DCR B
JNZ DLY1
DCR C
JNZ INL
RET

ISR_5_5:
MVI E, 05H
R5: MVI A, 07H ;0111
OUT 0
CALL DLY

2
MVI A, 0
OUT 0
CALL DLY
DCR E
JNZ R5
EI
RET

ISR_6_5: MVI E, 06H


R6: MVI A,03H
OUT 0
CALL DLY
MVI A, 0
OUT 0
CALL DLY
DCR E
JNZ R6
EI
RET

;======= LCD TO DISPLEY GATE OPENED ===========

OPENGATE:
MVI E, 09H ;clear LCD
RST 1
CALL dlyz1
CALL dlyz1

LXI H, 0500H ;1st row


MVI E, 0AH
RST 1
LXI H, DATA4 ;"GATE OPENED"
MVI E, 0BH
RST 1

LXI H, 0002H ;2nd row


MVI E, 0AH
RST 1
LXI H, DATA5 ;"THANK YOU VISIT"
MVI E, 0BH
RST 1

LXI H, 0003H ;4th row


MVI E, 0AH
RST 1
LXI H, DATA6 ;"HUAZAI PARKING"
MVI E, 0BH
RST 1
CALL START
CALL dlyz2
CALL dlyz2

3
dlyz1:
LXI D, 0FF01H

RST 1
RET
dlyz2:
LXI H, 10FAH
MVI E,01H
RST 1
RET

SEV:
MVI A,0
STA DIGIT
MVI A,0
STA DIGIT+1
MVI A,0
STA DIGIT+2
MVI A,0
STA DIGIT+3
MVI A,0
STA DIGIT+4
MVI A,0
STA DIGIT+5

declaresev:

MVI A,16;display numeric 4 on dig 3


LXI H,SEVSEGDATA
MVI D,0
MOV E,A
DAD D
MOV A,M
STA DIGIT+5 ;0+3

MVI A,01h ;display numeric 4 on dig 3


LXI H,SEVSEGDATA
MVI D,0
MOV E,A
DAD D
MOV A,M
STA DIGIT+4 ;0+3

MVI A,17;display numeric b on dig 2


LXI H,SEVSEGDATA
MVI D,0
MOV E,A
DAD D
MOV A,M
STA DIGIT+2 ;0+2

4
MVI A,0ah ;display numeric a on dig 1
LXI H,SEVSEGDATA
MVI D,0
MOV E,A
DAD D
MOV A,M
STA DIGIT+1 ;0+1

MVI A,0cH ;display numeric b on dig 0


LXI H,SEVSEGDATA
MVI D,0
MOV E,A
DAD D
MOV A,M
STA DIGIT
again:
CALL DISPSEVSEG
jmp again
JMP declaresev

DISPSEVSEG:
MVI C,00H ; DIG0
MOV A,C
ORI 0F0H
OUT SYSTEM_PORT_C
LDA DIGIT;0
OUT SYSTEM_PORT_B
CALL DLY2
MVI A,0
OUT SYSTEM_PORT_B
;CALL DLY

MVI C,01H ;DIG1


MOV A,C
ORI 0F0H
OUT SYSTEM_PORT_C
LDA DIGIT+1;1
OUT SYSTEM_PORT_B
CALL DLY2
MVI A,0
OUT SYSTEM_PORT_B
;CALL DLY

MVI C,02H ;DIG2


MOV A,C
ORI 0F0H
OUT SYSTEM_PORT_C
LDA DIGIT+2;2
OUT SYSTEM_PORT_B
CALL DLY2
MVI A,0
OUT SYSTEM_PORT_B

5
;CALL DLY

MVI C,04H ;DIG3


MOV A,C
ORI 0F0H
OUT SYSTEM_PORT_C
LDA DIGIT+4;3
OUT SYSTEM_PORT_B
CALL DLY2
MVI A,0
OUT SYSTEM_PORT_B
;CALL DLY

MVI C,05H ;DIG3


MOV A,C
ORI 0F0H
OUT SYSTEM_PORT_C
LDA DIGIT+5;3
OUT SYSTEM_PORT_B
CALL DLY2
MVI A,0
OUT SYSTEM_PORT_B
;CALL DLY
RET

DLY2: MVI D,01H


LOOPO: MVI E,0ffh
LOOPD: DCR E
JNZ LOOPD
DCR D
JNZ LOOPO
RET
RET
;
*****************************************************************
****
; subroutine scan keyboard and display *
; input: hl pointer to buffer *
; exit: KEY = scan code *
; -1 no key pressed *
;
*****************************************************************
****
SCAN:
PUSH h ; save mem pointer hl
PUSH B ; save reg air bc...
PUSH D ; save reg pair de ..d reg was used for time
; OUT loop counter(25 loop)
;
*****************************************************************

6
***
;scan process initialization *
;
*****************************************************************
***
MVI C,6 ; for 6-digit LED
MVI E,0 ; digit scan code appears at 4-to-10 decoder
MVI D,0 ; key position
MVI A,0FFH ; put -1 to key
STA KEY ; key = -1
scan1:
MOV A,E ; set A to zero to start with digit 1
ORI 0f0h ; high nibble must be 1111
OUT SYSTEM_PORT_C ; active digit first
MVI B,1
;****************************************************
wait1: ; delay for transition process
DCR B ;
JNZ wait1
;****************************************************
IN SYSTEM_PORT_A ; read input port to check if
;any key is pressed
;
*****************************************************************
****
; analyse the 8 bit data read from port a; all bits are pulled
high initially, *
; therefore bit=0 mean a key is pressed *
;
*****************************************************************
****
MVI B,8 ; check all 8-row
shift_key:
RAR ; rotate right through carry
JC next_key ; if carry = 1 then no key pressed
PUSH psw ; save accumulator and flag
;register into stack
MOV A,D ; copy position counter d to accum.
STA KEY ; save key position and then
; continue to check the rest of bits
POP psw ; restore accumulator and flag register
next_key:
inr D ; next key position (Increment key count)
DCR B ; until 8-bit was shifted
JNZ shift_key
; end of the 8 bit checking
MVI A,0 ; clear a
inr E ; next digit scan code(0,1,2,3,4,5)...
; 4/5 may not used
DCR C ; next column(0-5)
JNZ scan1 ; check keys in the next column
;finish scannig all keys

7
;key position has been saved to key buffer
POP D
POP B
POP h
RET
;
*****************************************************************
***
; convert position key to internal key code 0-F for data entry *
; and 10-19H for function keys *
; entry: A = scan code *
; exit : A = internal code *
;
*****************************************************************
***
get_key_code:
CPI 2 ; the saved key position is 2
JNZ code1 ; not 2 check next position
MVI A,0 ; 2 is for key '0', return value 0
RET

code1:
CPI 0ah ; the saved key position is 0AH
JNZ code2 ; not 0AH check next position
MVI A,1 ; 0AH is for key '1', return value 1
RET
code2:
CPI 12h ;2
JNZ code3
MVI A,2
RET
code3:
CPI 1ah ;3
JNZ code4
MVI A,3
RET
code4:
CPI 3 ;4
JNZ code5
MVI A,4
RET
code5:
CPI 0bh ;5
JNZ code6
MVI A,5
RET
code6:
CPI 13h ;6
JNZ code7
MVI A,6
RET
code7:

8
CPI 1bh ;7
JNZ code8
MVI A,7
RET
code8:
CPI 4 ;8
JNZ code9
MVI A,8
RET
code9:
CPI 0ch ;9
JNZ code10
MVI A,9
RET
code10:
CPI 14h ;A
JNZ code11
MVI A,0ah
RET
code11:
CPI 1ch ;B
JNZ code12
MVI A,0bh
RET
code12: CPI 5 ;C
JNZ code13
MVI A,0ch
RET
code13:
CPI 0dh ;D
JNZ code14
MVI A,0dh
RET
code14:
CPI 15h ;E
JNZ code15
MVI A,0eh
RET
code15:
CPI 1dh ;F
JNZ code16
MVI A,0fh
RET
code16:
CPI 10h ; Function key 0
JNZ code17
MVI A,10h
RET
code17:
CPI 18h ; Function key 1
JNZ code18
MVI A,11h

9
RET
code18:
CPI 1 ; Function key 2
JNZ code19
MVI A,12h
RET
code19:
CPI 0 ; Function key 3
JNZ code20
MVI A,13h
RET
code20:
CPI 8 ; Function key 4
JNZ code21
MVI A,14h
RET
code21:
CPI 9 ; Function key 5
JNZ code22
MVI A,15h
RET
code22:
CPI 11h ; Function key 6
JNZ code23
MVI A,16h
RET
code23:
CPI 19h ; Function key 7
JNZ code24
MVI A,17h
RET
code24:
CPI 2eh ; Function key 8
JNZ code25
MVI A,18h
RET
code25:
CPI 2fh ; Function key 9
JNZ code26
MVI A,19h
RET
code26:
CPI 0eeh
MVI A,14h
RET

code27:
MVI A,0ffh
RET
;
*****************************************************************
**

10
HLT
;
*****************************************************************
***
; delay routine
;
*****************************************************************
***
;
*****************************************************************
***
;ALLOCATE DATA SECTOR
ORG 0e000h
KEY:
DFS 1 ; key position storage
LASTKEY:
DFS 1 ; last key storage
;
*****************************************************************
****
;LCD display data *
;
*****************************************************************
****
count: DS 1
DATA1: DFB 57H,45H,4CH,43H,4FH,4DH,45H,3EH,2EH,3CH,00H
;WELCOME >.<
DATA2: DFB
50H,52H,45H,53H,53H,20H,41H,4EH,59H,20H,42H,55H,54H,54H,4FH,4EH,2
0H,54H,4FH,00H ;press any button to
DATA3: DFB 45H,4EH,54H,45H,52H,2EH,00H ;enter.
DATA4: DFB 47H, 41H, 54H, 45H, 20H, 4FH, 50H, 45H, 4EH, 45H,
44H, 21H ,00H; ;GATE OPENED!
DATA5: DFB
54H,48H,41H,4EH,4BH,20H,59H,4FH,55H,20H,56H,49H,53H,49H,54H,00H ;
THANK YOU VISIT
DATA6: DFB
48H,55H,41H,5AH,41H,49H,20H,50H,41H,52H,4BH,49H,4EH,47H,00H; ;HU
AZAI PERKING
SEVSEGDATA:
dfB 00111111B,00000110B,01011011B,01001111B,
DFB 01100110B,01101101B,01111101B,00000111B,
DFB 01111111B,01101111B,01110111B,01111100B,
DFB 00111001B,00011110B,01111001B,01110001B,
DFB 00110111B,00110011B;n;r
DIGIT: DFS 4
;
*****************************************************************
****

11

You might also like