AlarmeBeta - IFSUL - Sistemas Microprocessados 1

preview_player
Показать описание
Update 1.1:

ORG 0000h

LedMain EQU P1.3
LedSirene EQU P1.4
LedSensor1 EQU P1.5
LedSensor2 EQU P1.6
LedSensor3 EQU P1.7
LedStarter EQU P1.0
COD0 EQU P2.0
COD1 EQU P2.1
Cod2 EQU P2.2
ONOFF EQU P2.3
Sensor1 EQU P2.5
Sensor2 EQU P2.6
Sensor3 EQU P2.7
PWD0 EQU 20H
PWD1 EQU 21H
PWD2 EQU 22H

inicializacao:

LCALL reseta
LCALL adapt
CLR ledStarter
CLR ledsirene
batata: LCALL mostrasensores
t2: LCALL testedesliga
JB ONOFF, batata
t4: CLR LedMain
SETB ledsirene
t1: LCALL testesensores
JB ONOFF, t2
JNB ONOFF, t1
SJMP T1

testesensores:

JNB sensor1, ligaled1
Y: JNB sensor2, ligaled2
Y1: JNB sensor3, ligaled3

RET

ligaled1: CLR LEDSENSOR1
CLR ledsirene
SJMP Y

ligaled2: CLR LEDSENSOR2
CLR ledsirene
SJMP Y1

ligaled3: CLR LEDSENSOR3
CLR ledsirene

testedesliga:
L2: JB P2.4, mostrasensores2
JNB ONOFF, fim0
JNB COD0, zero0
JB COD0, um0
K: CJNE A,PWD0,fim
JNB COD1, zero1
JB COD1, um1
H: CJNE A,PWD1,fim
JNB COD2, zero2
JB COD2, um2
N: CJNE A,PWD2,fim
SETB ledsirene
SETB LedMain
JB ONOFF, mostrasensores
SJMP t4

RET

fim0:
SJMP t4

fim:
CLR ledsirene
SJMP testedesliga

um0: MOV A, #1
SJMP K
zero0: MOV A, #0
SJMP K

um1: MOV A, #1
SJMP H
zero1: MOV A, #0
SJMP H

um2: MOV A, #1
SJMP N
zero2: MOV A, #0
SJMP N

mostrasensores:

MOV C, SENSOR1
MOV LEDSENSOR1, C
MOV C, SENSOR2
MOV LEDSENSOR2, C
MOV C, SENSOR3
MOV LEDSENSOR3, C
SJMP L2

RET

mostrasensores2:

MOV C, SENSOR1
MOV LEDSENSOR1, C
MOV C, SENSOR2
MOV LEDSENSOR2, C
MOV C, SENSOR3
MOV LEDSENSOR3, C
SJMP L2

;Escolha do código de desativação
;de acordo com as chaves inicialmente
adapt:

JNB COD0, PW00
MOV PWD0, #1
SJMP NDE
PW00: MOV PWD0, #0
NDE: JNB COD1, PW10
MOV PWD1, #1
SJMP RDE
PW10: MOV PWD1, #0
RDE: JNB COD2, PW20
MOV PWD2, #1
RET
PW20: MOV PWD2, #0
RET

;Um tanto redundante
reseta:
MOV PWD0,#00
MOV PWD1,#00
MOV PWD2, #00
RET

END

;Beta 1.1
;ASS: Ricardinho do Barulh
Рекомендации по теме