1  |   list      p=16f628A           ; list directive to define processor
  | 
2  |   #include <p16F628A.inc>       ; processor specific variable definitions
  | 
3  | 
  | 
4  |   errorlevel  -302              ; suppress message 302 from list file
  | 
5  | 
  | 
6  |   __CONFIG   _CP_OFF  & _LVP_OFF & _BOREN_OFF & _MCLRE_ON & _WDT_OFF & _PWRTE_ON & _INTOSC_OSC_NOCLKOUT 
  | 
7  | ;& _DATA_CP_OFF
  | 
8  | ; '__CONFIG' directive is used to embed configuration word within .asm file.
  | 
9  | ; The lables following the directive are located in the respective .inc file.
  | 
10  | ; See data sheet for additional information on configuration word settings.
  | 
11  | 
  | 
12  | 
  | 
13  | 
  | 
14  | 
  | 
15  | ;***** VARIABLE DEFINITIONS
  | 
16  | w_temp        EQU     0x7E        ; variable used for context saving 
  | 
17  | status_temp   EQU     0x7F        ; variable used for context saving
  | 
18  | loops       Equ     0x22            ; Zähler für Warteschleife 
  | 
19  | loops2      Equ     0x23            ; Zähler für Warteschleife  
  | 
20  | 
  | 
21  | 
  | 
22  | 
  | 
23  | 
  | 
24  | ;**********************************************************************
  | 
25  |   ORG     0x000             ; processor reset vector
  | 
26  |   goto    main              ; go to beginning of program
  | 
27  |   
  | 
28  | 
  | 
29  |   ORG     0x004             ; interrupt vector location
  | 
30  |   movwf   w_temp            ; save off current W register contents
  | 
31  |   movf  STATUS,w          ; move status register into W register
  | 
32  |   movwf  status_temp       ; save off contents of STATUS register
  | 
33  | 
  | 
34  | ; isr code can go here or be located as a call subroutine elsewhere
  | 
35  |   BTFSS PORTB,1
  | 
36  |   GOTO LEDEIN
  | 
37  |   BTFSC PORTB,1
  | 
38  |   GOTO LEDAUS
  | 
39  | 
  | 
40  |   LEDEIN
  | 
41  |   BSF PORTB,1
  | 
42  |   CALL Wait
  | 
43  |   GOTO OUT
  | 
44  | 
  | 
45  |   LEDAUS
  | 
46  |   BCF PORTB,1
  | 
47  |   CALL Wait
  | 
48  | 
  | 
49  | OUT
  | 
50  |   bcf    INTCON, INTF       ; RB0-Interrupt-Flag löschen 
  | 
51  |   movf    status_temp,w     ; retrieve copy of STATUS register
  | 
52  |   movwf  STATUS            ; restore pre-isr STATUS register contents
  | 
53  |   swapf   w_temp,f
  | 
54  |   swapf   w_temp,w          ; restore pre-isr W register contents
  | 
55  |   retfie                    ; return from interrupt
  | 
56  | 
  | 
57  | 
  | 
58  | main
  | 
59  | 
  | 
60  | ; remaining code goes here
  | 
61  | 
  | 
62  |         bsf     STATUS, RP0     ; auf Bank 1 umschalten
  | 
63  |         movlw   B'00000001'     ; PortB alle output
  | 
64  |         movwf   TRISB
  | 
65  |         bcf     STATUS, RP0     ; auf Bank 0 schalten
  | 
66  |         clrf    PORTB           ; alle LEDs ausschalten
  | 
67  | 
  | 
68  | 
  | 
69  | ; RB0-Interrupt einstellen
  | 
70  |         bsf    STATUS, RP0        ; auf Bank 1 umschalten
  | 
71  |         bsf    OPTION_REG, INTEDG ; 0-1-Flanke an RB0
  | 
72  |         bcf    STATUS, RP0        ; auf Bank 0 zurückschalten
  | 
73  | 
  | 
74  |         bsf    INTCON, INTE       ; RB0-interrupt erlauben
  | 
75  |         bsf    INTCON, GIE        ; Interrupt generell erlauben
  | 
76  | 
  | 
77  | Start
  | 
78  |   BTFSC PORTA,1
  | 
79  |   GOTO Gruen
  | 
80  |   CALL Wait
  | 
81  |   GOTO Start
  | 
82  | 
  | 
83  | Gruen
  | 
84  |   BSF PORTB,2
  | 
85  |   CALL Wait
  | 
86  |   BTFSC PORTA,1
  | 
87  |   GOTO Tuerkis
  | 
88  |   GOTO Gruen
  | 
89  | 
  | 
90  | Tuerkis
  | 
91  |   BSF PORTB,3
  | 
92  |   CALL Wait 
  | 
93  |   BTFSC PORTA,1
  | 
94  |   GOTO Blau
  | 
95  |   GOTO Tuerkis
  | 
96  | 
  | 
97  | Blau
  | 
98  |   BCF PORTB,2
  | 
99  |   CALL Wait
  | 
100  |   BTFSC PORTA,1
  | 
101  |   GOTO Lila
  | 
102  |   GOTO Blau
  | 
103  | 
  | 
104  | Lila
  | 
105  |   BSF PORTB,4
  | 
106  |   CALL Wait
  | 
107  |   BTFSC PORTA,1
  | 
108  |   GOTO Rot
  | 
109  |   GOTO Lila
  | 
110  | 
  | 
111  | Rot
  | 
112  |   BCF PORTB,3
  | 
113  |   CALL Wait
  | 
114  |   BTFSC PORTA,1
  | 
115  |   GOTO Gelb
  | 
116  |   GOTO Rot
  | 
117  | 
  | 
118  | Gelb
  | 
119  |   BSF PORTB,2
  | 
120  |   CALL Wait
  | 
121  |   BTFSC PORTA,1
  | 
122  |   GOTO Weiss
  | 
123  |   GOTO Gelb
  | 
124  | 
  | 
125  | Weiss
  | 
126  |   BSF PORTB,3
  | 
127  |   CALL Wait
  | 
128  |   BTFSC PORTA,1
  | 
129  |   GOTO Schwarz
  | 
130  |   GOTO Weiss
  | 
131  | 
  | 
132  | Schwarz
  | 
133  |   BCF PORTB,2
  | 
134  |   BCF  PORTB,3
  | 
135  |   BCF PORTB,4
  | 
136  |   CALL Wait
  | 
137  |   GOTO Start
  | 
138  | 
  | 
139  | ; Warteschleife 250 ms
  | 
140  | 
  | 
141  | Wait
  | 
142  |         movlw   D'250'          ; 250 ms Pause
  | 
143  |         movwf   loops 
  | 
144  | 
  | 
145  | Wai
  | 
146  |         movlw   .110           ; Zeitkonstante für 1ms
  | 
147  |         movwf   loops2
  | 
148  | Wai2    nop                    ; 
  | 
149  |         nop
  | 
150  |         nop
  | 
151  |         nop
  | 
152  |         nop
  | 
153  |         nop
  | 
154  |         decfsz  loops2, F      ; 1 ms vorbei?
  | 
155  |         goto    Wai2           ; nein, noch nicht
  | 
156  |                                ;
  | 
157  |         decfsz  loops, F       ; 250 ms vorbei?
  | 
158  |         goto    Wai            ; nein, noch nicht
  | 
159  |         retlw   0              ; das Warten hat ein Ende 
  | 
160  | 
  | 
161  | ; initialize eeprom locations
  | 
162  | 
  | 
163  |   ORG  0x2100
  | 
164  |   DE  0x00, 0x01, 0x02, 0x03
  | 
165  | 
  | 
166  | 
  | 
167  |   END                       ; directive 'end of program'
  |