You are required to build a controller for a simple security system. The control
ID: 2246275 • Letter: Y
Question
You are required to build a controller for a simple security system. The controller contains the following components: 1) 3x4 keypad (0….9, *,#) 2) PPI to interface the keypad 3) 8254 timer (to generate delay and the alarm signal ) 4) Sensors on the door to generate interrupts 5) 8259 interrupt controller When the user press ‘*’ the user then have to enter 4 digit code , if the code is correct then the user have 5 seconds to exit the house (if the door is still open after that the alarm will go on) . If the door is open and the system is active a hardware interrupt will be generated, and the interrupt will cause the 8254 timer to generate a low frequency square wave to a speaker to generate the alarm. Then the user have 5 seconds to press ‘#’ and enter the 4 digit code if the code is correct the system will be turned off otherwise the frequency of the alarm will get higher. What you should do 1. Deliver a schematic as an image file or PDF showing how all the components are interconnected. 2. Write the assembly code that achieves the desired functionality. i need Assembly code plz :/
Explanation / Answer
i have the code so far
RS EQU P2.7
RW EQU P2.6
E EQU P2.5
SEL EQU 41H
ORG 000H
CLR P2.0
MOV TMOD,#00100001B
MOV TH1,#253D
MOV SCON,#50H
SETB TR1
ACALL LCD_INIT
MOV DPTR,#TEXT1
ACALL LCD_OUT
ACALL LINE2
MOV DPTR,#TEXT2
ACALL LCD_OUT
MAIN:ACALL LCD_INIT
MOV DPTR,#TEXT1
ACALL LCD_OUT
ACALL LINE2
MOV DPTR,#TEXT2
CLR P2.0
ACALL LCD_OUT
ACALL DELAY1
ACALL DELAY1
ACALL READ_KEYPRESS
ACALL LINE1
MOV DPTR,#CHKMSG
ACALL LCD_OUT
ACALL DELAY1
ACALL CHECK_PASSWORD
SJMP MAIN
LCD_INIT: MOV DPTR,#INIT_COMMANDS
SETB SEL
ACALL LCD_OUT
CLR SEL
RET
LCD_OUT: CLR A
MOVC A,@A+DPTR
JZ EXIT
INC DPTR
JB SEL,CMD
ACALL DATA_WRITE
SJMP LCD_OUT
CMD: ACALL CMD_WRITE
SJMP LCD_OUT
EXIT: RET
LINE2:MOV A,#0C0H
ACALL CMD_WRITE
RET
LINE1: MOV A,#80H
ACALL CMD_WRITE
RET
CLRSCR: MOV A,#01H
ACALL CMD_WRITE
RET
CMD_WRITE: MOV P0,A
CLR RS
CLR RW
SETB E
CLR E
ACALL DELAY
RET
DATA_WRITE:MOV P0,A
SETB RS
CLR RW
SETB E
CLR E
ACALL DELAY
RET
DELAY: CLR E
CLR RS
SETB RW
MOV P0,#0FFh
SETB E
MOV A,P0
JB ACC.7,DELAY
CLR E
CLR RW
RET
DELAY1:MOV R3,#46D
BACK: MOV TH0,#00000000B
MOV TL0,#00000000B
SETB TR0
HERE1: JNB TF0,HERE1
CLR TR0
CLR TF0
DJNZ R3,BACK
RET
DELAY2: MOV R3,#250D
BACK2: MOV TH0,#0FCH
MOV TL0,#018H
SETB TR0
HERE2: JNB TF0,HERE2
CLR TR0
CLR TF0
DJNZ R3,BACK2
RET
READ_KEYPRESS: ACALL CLRSCR
ACALL LINE1
MOV DPTR,#IPMSG
ACALL LCD_OUT
ACALL LINE2
MOV R0,#5D
MOV R1,#160D
ROTATE:ACALL KEY_SCAN
MOV @R1,A
ACALL DATA_WRITE
ACALL DELAY2
INC R1
DJNZ R0,ROTATE
RET
CHECK_PASSWORD:MOV R0,#5D
MOV R1,#160D
MOV DPTR,#PASSW
RPT:CLR A
MOVC A,@A+DPTR
XRL A,@R1
JNZ FAIL
INC R1
INC DPTR
DJNZ R0,RPT
ACALL CLRSCR
ACALL LINE1
MOV DPTR,#TEXT_S1
ACALL LCD_OUT
ACALL LINE2
ACALL DELAY1
SETB P2.0
MOV DPTR,#TEXT_S2
ACALL LCD_OUT
ACALL DELAY1
SJMP GOBACK
FAIL:ACALL CLRSCR
ACALL LINE1
MOV DPTR,#TEXT_F1
ACALL LCD_OUT
ACALL DELAY1
ACALL LINE2
MOV DPTR,#TEXT_F2
ACALL LCD_OUT
ACALL DELAY1
GOBACK:RET
KEY_SCAN:MOV P3,#11111111B
CLR P3.0
JB P3.4, NEXT1
MOV A,#49D
RET
NEXT1:JB P3.5,NEXT2
MOV A,#50D
RET
NEXT2: JB P3.6,NEXT3
MOV A,#51D
RET
NEXT3: JB P3.7,NEXT4
MOV A,#65D
RET
NEXT4:SETB P3.0
CLR P3.1
JB P3.4, NEXT5
MOV A,#52D
RET
NEXT5:JB P3.5,NEXT6
MOV A,#53D
RET
NEXT6: JB P3.6,NEXT7
MOV A,#54D
RET
NEXT7: JB P3.7,NEXT8
MOV A,#66D
RET
NEXT8:SETB P3.1
CLR P3.2
JB P3.4, NEXT9
MOV A,#55D
RET
NEXT9:JB P3.5,NEXT10
MOV A,#56D
RET
NEXT10: JB P3.6,NEXT11
MOV A,#57D
RET
NEXT11: JB P3.7,NEXT12
MOV A,#67D
RET
NEXT12:SETB P3.2
CLR P3.3
JB P3.4, NEXT13
MOV A,#42D
RET
NEXT13:JB P3.5,NEXT14
MOV A,#48D
RET
NEXT14: JB P3.6,NEXT15
MOV A,#35D
RET
NEXT15: JB P3.7,NEXT16
MOV A,#68D
RET
NEXT16:LJMP KEY_SCAN
INIT_COMMANDS: DB 0CH,01H,06H,80H,3CH,0
TEXT1: DB "PASSWORD BASED",0
TEXT2: DB "SECURITY SYSTEM",0
IPMSG: DB "INPUT 5 DIGITS",0
CHKMSG: DB "CHECKING PASSWORD",0
TEXT_S1: DB "ACCESS - GRANTED",0
TEXT_S2: DB "DOOR OPENED",0
TEXT_F1: DB "WRONG PASSWORD",0
TEXT_F2: DB "ACCESS DENIED",0
PASSW: DB 49D,50D,51D,52D,53D,0
END
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.