-
Notifications
You must be signed in to change notification settings - Fork 0
/
P3.ASM
100 lines (97 loc) · 1.85 KB
/
P3.ASM
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include P16F628A.INC
;RB7=AUTO-FALANTE,RB5 E RB6=LED,RB4=RELÉ,RB3=Lâmpada,RB2= interruptor 2
;RB1=INTERRUPTOR 1 ,RB0=INTERRUPTOR 3
SALVAW EQU 20H
SALVAS EQU 21H
FREQ EQU 22H
DL0 EQU 23H
DL1 EQU 24H
DL2 EQU 25H
ORG 000H
GOTO INICIO
ORG 004H
MOVWF SALVAW
SWAPF STATUS,W
MOVWF SALVAS
BTFSS INTCON,INTF
GOTO INTTMR
GOTO INTEXT
INTTMR:
MOVFW FREQ
MOVWF TMR0
MOVLW B'10000000'
XORWF PORTB
MOVF SALVAW,W
SWAPF SALVAS,W
MOVWF STATUS
RETFIE
INICIO:
BSF STATUS,RP0
MOVLW B'00000111'
MOVWF TRISB
MOVLW B'10010000'
MOVWF INTCON
MOVLW B'10010001'
MOVWF OPTION_REG
BCF STATUS,RP0
BCF PORTB,3
BCF PORTB,4
BSF PORTB,5
BSF PORTB,6
N:
BTFSC PORTB,2
GOTO N
BSF PORTB,3
BSF PORTB,4
T:
BTFSC PORTB,1
GOTO T
BSF INTCON,T0IE
LOOP2:
BCF PORTB,5
BSF PORTB,6
MOVLW .3
MOVWF FREQ
CALL DELAY
BSF PORTB,5
BCF PORTB,6
MOVLW .43
MOVWF FREQ
CALL DELAY
GOTO LOOP2
INTEXT:
BCF PORTB,3
BCF PORTB,4
BSF PORTB,5
BSF PORTB,6
BCF PORTB,7
BCF INTCON,INTF
GOTO REC
REC:
BCF INTCON,T0IE
SWAPF SALVAS,W
MOVWF STATUS
MOVF SALVAW,W
GOTO P
P:
BSF INTCON,GIE
GOTO N
DELAY:
MOVLW .2
MOVWF DL2
LOOP_250MS:
MOVLW .250
MOVWF DL1
LOOP_1MS:
MOVLW .200
MOVWF DL0
LOOP:
NOP
DECFSZ DL0,F
GOTO LOOP
DECFSZ DL1,F
GOTO LOOP_1MS
DECFSZ DL2,F
GOTO LOOP_250MS
RETURN
END