160 |
krcmar |
1 |
CCS PCM C Compiler, Version 4.059d, 15399 03-III-07 19:39 |
|
|
2 |
|
|
|
3 |
Filename: main.lst |
|
|
4 |
|
|
|
5 |
ROM used: 252 words (12%) |
|
|
6 |
Largest free fragment is 1796 |
|
|
7 |
RAM used: 8 (2%) at main() level |
|
|
8 |
8 (2%) worst case |
|
|
9 |
Stack: 0 locations |
|
|
10 |
|
|
|
11 |
* |
|
|
12 |
0000: MOVLW 00 |
|
|
13 |
0001: MOVWF 0A |
|
|
14 |
0002: GOTO 004 |
|
|
15 |
0003: NOP |
|
|
16 |
.................... /**** Analog to Digital Converter ****/ |
|
|
17 |
.................... #include "main.h" |
|
|
18 |
.................... #include <16F877A.h> |
|
|
19 |
.................... //////// Standard Header file for the PIC16F877A device //////////////// |
|
|
20 |
.................... #device PIC16F877A |
|
|
21 |
.................... #list |
|
|
22 |
.................... |
|
|
23 |
.................... #device adc=8 |
|
|
24 |
.................... |
|
|
25 |
.................... #FUSES NOWDT //No Watch Dog Timer |
|
|
26 |
.................... #FUSES XT //Crystal osc <= 4mhz |
|
|
27 |
.................... #FUSES NOPUT //No Power Up Timer |
|
|
28 |
.................... #FUSES NOPROTECT //Code not protected from reading |
|
|
29 |
.................... #FUSES NODEBUG //No Debug mode for ICD |
|
|
30 |
.................... #FUSES NOBROWNOUT //No brownout reset |
|
|
31 |
.................... #FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O |
|
|
32 |
.................... #FUSES NOCPD //No EE protection |
|
|
33 |
.................... #FUSES WRT_50% //Lower half of Program Memory is Write Protected |
|
|
34 |
.................... |
|
|
35 |
.................... #use delay(clock=4000000,RESTART_WDT) |
|
|
36 |
.................... #use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8) |
|
|
37 |
.................... |
|
|
38 |
.................... |
|
|
39 |
.................... |
|
|
40 |
.................... #define LED1 PIN_A2 |
|
|
41 |
.................... #define LED2 PIN_A3 // LEDky |
|
|
42 |
.................... #define LED3 PIN_A5 |
|
|
43 |
.................... #define CIDLO 8 // Port A/D prevodniku |
|
|
44 |
.................... #define TAD 8 // Doba na prevod jednoho bitu |
|
|
45 |
.................... |
|
|
46 |
.................... void main() |
|
|
47 |
.................... { |
|
|
48 |
0004: CLRF 04 |
|
|
49 |
0005: BCF 03.7 |
|
|
50 |
0006: MOVLW 1F |
|
|
51 |
0007: ANDWF 03,F |
|
|
52 |
0008: MOVLW 19 |
|
|
53 |
0009: BSF 03.5 |
|
|
54 |
000A: MOVWF 19 |
|
|
55 |
000B: MOVLW A6 |
|
|
56 |
000C: MOVWF 18 |
|
|
57 |
000D: MOVLW 90 |
|
|
58 |
000E: BCF 03.5 |
|
|
59 |
000F: MOVWF 18 |
|
|
60 |
0010: BSF 03.5 |
|
|
61 |
0011: BSF 1F.0 |
|
|
62 |
0012: BSF 1F.1 |
|
|
63 |
0013: BSF 1F.2 |
|
|
64 |
0014: BCF 1F.3 |
|
|
65 |
0015: MOVLW 07 |
|
|
66 |
0016: MOVWF 1C |
|
|
67 |
.................... int8 t; // Promenna pro nacteni hodnoty z potenciometru |
|
|
68 |
.................... |
|
|
69 |
.................... setup_adc_ports(AN0); // Povolime analogovy vstup 0 |
|
|
70 |
* |
|
|
71 |
001A: BSF 03.5 |
|
|
72 |
001B: BCF 1F.0 |
|
|
73 |
001C: BSF 1F.1 |
|
|
74 |
001D: BSF 1F.2 |
|
|
75 |
001E: BSF 1F.3 |
|
|
76 |
.................... setup_adc(ADC_CLOCK_DIV_8); // Delicka hodin pro prevodnik |
|
|
77 |
001F: BCF 1F.6 |
|
|
78 |
0020: BCF 03.5 |
|
|
79 |
0021: BSF 1F.6 |
|
|
80 |
0022: BCF 1F.7 |
|
|
81 |
0023: BSF 03.5 |
|
|
82 |
0024: BCF 1F.7 |
|
|
83 |
0025: BCF 03.5 |
|
|
84 |
0026: BSF 1F.0 |
|
|
85 |
.................... // setup_psp(PSP_DISABLED); // Tento HW ma pouze PIC16F877A |
|
|
86 |
.................... setup_spi(SPI_SS_DISABLED); |
|
|
87 |
* |
|
|
88 |
0017: MOVLW FF |
|
|
89 |
0018: BCF 03.5 |
|
|
90 |
0019: MOVWF 20 |
|
|
91 |
* |
|
|
92 |
0027: BCF 14.5 |
|
|
93 |
0028: BCF 20.5 |
|
|
94 |
0029: MOVF 20,W |
|
|
95 |
002A: BSF 03.5 |
|
|
96 |
002B: MOVWF 07 |
|
|
97 |
002C: BCF 03.5 |
|
|
98 |
002D: BSF 20.4 |
|
|
99 |
002E: MOVF 20,W |
|
|
100 |
002F: BSF 03.5 |
|
|
101 |
0030: MOVWF 07 |
|
|
102 |
0031: BCF 03.5 |
|
|
103 |
0032: BCF 20.3 |
|
|
104 |
0033: MOVF 20,W |
|
|
105 |
0034: BSF 03.5 |
|
|
106 |
0035: MOVWF 07 |
|
|
107 |
0036: MOVLW 01 |
|
|
108 |
0037: BCF 03.5 |
|
|
109 |
0038: MOVWF 14 |
|
|
110 |
0039: MOVLW 00 |
|
|
111 |
003A: BSF 03.5 |
|
|
112 |
003B: MOVWF 14 |
|
|
113 |
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); |
|
|
114 |
003C: MOVF 01,W |
|
|
115 |
003D: ANDLW C7 |
|
|
116 |
003E: IORLW 08 |
|
|
117 |
003F: MOVWF 01 |
|
|
118 |
.................... setup_timer_1(T1_DISABLED); |
|
|
119 |
0040: BCF 03.5 |
|
|
120 |
0041: CLRF 10 |
|
|
121 |
.................... setup_timer_2(T2_DISABLED,0,1); |
|
|
122 |
0042: MOVLW 00 |
|
|
123 |
0043: MOVWF 78 |
|
|
124 |
0044: MOVWF 12 |
|
|
125 |
0045: MOVLW 00 |
|
|
126 |
0046: BSF 03.5 |
|
|
127 |
0047: MOVWF 12 |
|
|
128 |
.................... setup_comparator(NC_NC_NC_NC); |
|
|
129 |
0048: MOVLW 07 |
|
|
130 |
0049: MOVWF 1C |
|
|
131 |
004A: MOVF 05,W |
|
|
132 |
004B: CLRWDT |
|
|
133 |
004C: MOVLW 02 |
|
|
134 |
004D: MOVWF 77 |
|
|
135 |
004E: DECFSZ 77,F |
|
|
136 |
004F: GOTO 04E |
|
|
137 |
0050: GOTO 051 |
|
|
138 |
0051: MOVF 1C,W |
|
|
139 |
0052: BCF 03.5 |
|
|
140 |
0053: BCF 0D.6 |
|
|
141 |
.................... setup_vref(FALSE); |
|
|
142 |
0054: BSF 03.5 |
|
|
143 |
0055: CLRF 1D |
|
|
144 |
.................... |
|
|
145 |
.................... set_adc_channel(CIDLO); // Pripojime cidlo na A/D prevodnik |
|
|
146 |
0056: MOVLW 40 |
|
|
147 |
0057: MOVWF 78 |
|
|
148 |
0058: BCF 03.5 |
|
|
149 |
0059: MOVF 1F,W |
|
|
150 |
005A: ANDLW C7 |
|
|
151 |
005B: IORWF 78,W |
|
|
152 |
005C: MOVWF 1F |
|
|
153 |
.................... delay_us(20); // Pockame na nabiti kapacit po prepnuti |
|
|
154 |
005D: CLRWDT |
|
|
155 |
005E: MOVLW 06 |
|
|
156 |
005F: MOVWF 77 |
|
|
157 |
0060: DECFSZ 77,F |
|
|
158 |
0061: GOTO 060 |
|
|
159 |
.................... //t=read_adc(); // Prvni precteni cidla |
|
|
160 |
.................... |
|
|
161 |
.................... while(TRUE){ |
|
|
162 |
.................... t=read_adc(); // Prvni precteni cidla |
|
|
163 |
0062: BSF 1F.2 |
|
|
164 |
0063: BTFSC 1F.2 |
|
|
165 |
0064: GOTO 063 |
|
|
166 |
0065: MOVF 1E,W |
|
|
167 |
0066: MOVWF 21 |
|
|
168 |
.................... |
|
|
169 |
.................... |
|
|
170 |
.................... if(t>00&&t<50){ |
|
|
171 |
0067: MOVF 21,F |
|
|
172 |
0068: BTFSC 03.2 |
|
|
173 |
0069: GOTO 073 |
|
|
174 |
006A: MOVF 21,W |
|
|
175 |
006B: SUBLW 31 |
|
|
176 |
006C: BTFSS 03.0 |
|
|
177 |
006D: GOTO 073 |
|
|
178 |
.................... output_high(LED1); |
|
|
179 |
006E: BSF 03.5 |
|
|
180 |
006F: BCF 05.2 |
|
|
181 |
0070: BCF 03.5 |
|
|
182 |
0071: BSF 05.2 |
|
|
183 |
.................... //rozsvit modrou |
|
|
184 |
.................... } |
|
|
185 |
.................... else if(t>50&&t<80){ |
|
|
186 |
0072: GOTO 0FA |
|
|
187 |
0073: MOVF 21,W |
|
|
188 |
0074: SUBLW 32 |
|
|
189 |
0075: BTFSC 03.0 |
|
|
190 |
0076: GOTO 0A4 |
|
|
191 |
0077: MOVF 21,W |
|
|
192 |
0078: SUBLW 4F |
|
|
193 |
0079: BTFSS 03.0 |
|
|
194 |
007A: GOTO 0A4 |
|
|
195 |
.................... output_high (LED1); // Zhasneme LED |
|
|
196 |
007B: BSF 03.5 |
|
|
197 |
007C: BCF 05.2 |
|
|
198 |
007D: BCF 03.5 |
|
|
199 |
007E: BSF 05.2 |
|
|
200 |
.................... delay_us(100); |
|
|
201 |
007F: CLRWDT |
|
|
202 |
0080: MOVLW 20 |
|
|
203 |
0081: MOVWF 77 |
|
|
204 |
0082: DECFSZ 77,F |
|
|
205 |
0083: GOTO 082 |
|
|
206 |
0084: GOTO 085 |
|
|
207 |
.................... output_low (LED1); // Rozsvitime LED |
|
|
208 |
0085: BSF 03.5 |
|
|
209 |
0086: BCF 05.2 |
|
|
210 |
0087: BCF 03.5 |
|
|
211 |
0088: BCF 05.2 |
|
|
212 |
.................... delay_us(100); |
|
|
213 |
0089: CLRWDT |
|
|
214 |
008A: MOVLW 20 |
|
|
215 |
008B: MOVWF 77 |
|
|
216 |
008C: DECFSZ 77,F |
|
|
217 |
008D: GOTO 08C |
|
|
218 |
008E: GOTO 08F |
|
|
219 |
.................... output_low (LED2); // Rozsvitime LED |
|
|
220 |
008F: BSF 03.5 |
|
|
221 |
0090: BCF 05.3 |
|
|
222 |
0091: BCF 03.5 |
|
|
223 |
0092: BCF 05.3 |
|
|
224 |
.................... delay_us(100); |
|
|
225 |
0093: CLRWDT |
|
|
226 |
0094: MOVLW 20 |
|
|
227 |
0095: MOVWF 77 |
|
|
228 |
0096: DECFSZ 77,F |
|
|
229 |
0097: GOTO 096 |
|
|
230 |
0098: GOTO 099 |
|
|
231 |
.................... output_high (LED2); // Zhasneme LED |
|
|
232 |
0099: BSF 03.5 |
|
|
233 |
009A: BCF 05.3 |
|
|
234 |
009B: BCF 03.5 |
|
|
235 |
009C: BSF 05.3 |
|
|
236 |
.................... delay_us(100); |
|
|
237 |
009D: CLRWDT |
|
|
238 |
009E: MOVLW 20 |
|
|
239 |
009F: MOVWF 77 |
|
|
240 |
00A0: DECFSZ 77,F |
|
|
241 |
00A1: GOTO 0A0 |
|
|
242 |
00A2: GOTO 0A3 |
|
|
243 |
.................... //rozsvit modrou+zelenou |
|
|
244 |
.................... } |
|
|
245 |
.................... else if(t>80&&t<120){ |
|
|
246 |
00A3: GOTO 0FA |
|
|
247 |
00A4: MOVF 21,W |
|
|
248 |
00A5: SUBLW 50 |
|
|
249 |
00A6: BTFSC 03.0 |
|
|
250 |
00A7: GOTO 0C1 |
|
|
251 |
00A8: MOVF 21,W |
|
|
252 |
00A9: SUBLW 77 |
|
|
253 |
00AA: BTFSS 03.0 |
|
|
254 |
00AB: GOTO 0C1 |
|
|
255 |
.................... //output_high(LED2); |
|
|
256 |
.................... //rozvit zelenou |
|
|
257 |
.................... output_low (LED2); // Rozsvitime LED |
|
|
258 |
00AC: BSF 03.5 |
|
|
259 |
00AD: BCF 05.3 |
|
|
260 |
00AE: BCF 03.5 |
|
|
261 |
00AF: BCF 05.3 |
|
|
262 |
.................... delay_us(100); |
|
|
263 |
00B0: CLRWDT |
|
|
264 |
00B1: MOVLW 20 |
|
|
265 |
00B2: MOVWF 77 |
|
|
266 |
00B3: DECFSZ 77,F |
|
|
267 |
00B4: GOTO 0B3 |
|
|
268 |
00B5: GOTO 0B6 |
|
|
269 |
.................... output_high (LED2); // Zhasneme LED |
|
|
270 |
00B6: BSF 03.5 |
|
|
271 |
00B7: BCF 05.3 |
|
|
272 |
00B8: BCF 03.5 |
|
|
273 |
00B9: BSF 05.3 |
|
|
274 |
.................... delay_us(100); |
|
|
275 |
00BA: CLRWDT |
|
|
276 |
00BB: MOVLW 20 |
|
|
277 |
00BC: MOVWF 77 |
|
|
278 |
00BD: DECFSZ 77,F |
|
|
279 |
00BE: GOTO 0BD |
|
|
280 |
00BF: GOTO 0C0 |
|
|
281 |
.................... } |
|
|
282 |
.................... else if(t>120&&t<160){ |
|
|
283 |
00C0: GOTO 0FA |
|
|
284 |
00C1: MOVF 21,W |
|
|
285 |
00C2: SUBLW 78 |
|
|
286 |
00C3: BTFSC 03.0 |
|
|
287 |
00C4: GOTO 0F2 |
|
|
288 |
00C5: MOVF 21,W |
|
|
289 |
00C6: SUBLW 9F |
|
|
290 |
00C7: BTFSS 03.0 |
|
|
291 |
00C8: GOTO 0F2 |
|
|
292 |
.................... output_high (LED3); // Zhasneme LED |
|
|
293 |
00C9: BSF 03.5 |
|
|
294 |
00CA: BCF 05.5 |
|
|
295 |
00CB: BCF 03.5 |
|
|
296 |
00CC: BSF 05.5 |
|
|
297 |
.................... delay_us(100); |
|
|
298 |
00CD: CLRWDT |
|
|
299 |
00CE: MOVLW 20 |
|
|
300 |
00CF: MOVWF 77 |
|
|
301 |
00D0: DECFSZ 77,F |
|
|
302 |
00D1: GOTO 0D0 |
|
|
303 |
00D2: GOTO 0D3 |
|
|
304 |
.................... output_low (LED3); // Rozsvitime LED |
|
|
305 |
00D3: BSF 03.5 |
|
|
306 |
00D4: BCF 05.5 |
|
|
307 |
00D5: BCF 03.5 |
|
|
308 |
00D6: BCF 05.5 |
|
|
309 |
.................... delay_us(100); |
|
|
310 |
00D7: CLRWDT |
|
|
311 |
00D8: MOVLW 20 |
|
|
312 |
00D9: MOVWF 77 |
|
|
313 |
00DA: DECFSZ 77,F |
|
|
314 |
00DB: GOTO 0DA |
|
|
315 |
00DC: GOTO 0DD |
|
|
316 |
.................... output_low (LED2); // Rozsvitime LED |
|
|
317 |
00DD: BSF 03.5 |
|
|
318 |
00DE: BCF 05.3 |
|
|
319 |
00DF: BCF 03.5 |
|
|
320 |
00E0: BCF 05.3 |
|
|
321 |
.................... delay_us(100); |
|
|
322 |
00E1: CLRWDT |
|
|
323 |
00E2: MOVLW 20 |
|
|
324 |
00E3: MOVWF 77 |
|
|
325 |
00E4: DECFSZ 77,F |
|
|
326 |
00E5: GOTO 0E4 |
|
|
327 |
00E6: GOTO 0E7 |
|
|
328 |
.................... output_high (LED2); // Zhasneme LED |
|
|
329 |
00E7: BSF 03.5 |
|
|
330 |
00E8: BCF 05.3 |
|
|
331 |
00E9: BCF 03.5 |
|
|
332 |
00EA: BSF 05.3 |
|
|
333 |
.................... delay_us(100); |
|
|
334 |
00EB: CLRWDT |
|
|
335 |
00EC: MOVLW 20 |
|
|
336 |
00ED: MOVWF 77 |
|
|
337 |
00EE: DECFSZ 77,F |
|
|
338 |
00EF: GOTO 0EE |
|
|
339 |
00F0: GOTO 0F1 |
|
|
340 |
.................... //rozsvit zelenou+cervenou |
|
|
341 |
.................... } |
|
|
342 |
.................... else if(t>160){ |
|
|
343 |
00F1: GOTO 0FA |
|
|
344 |
00F2: MOVF 21,W |
|
|
345 |
00F3: SUBLW A0 |
|
|
346 |
00F4: BTFSC 03.0 |
|
|
347 |
00F5: GOTO 0FA |
|
|
348 |
.................... output_high(LED3); |
|
|
349 |
00F6: BSF 03.5 |
|
|
350 |
00F7: BCF 05.5 |
|
|
351 |
00F8: BCF 03.5 |
|
|
352 |
00F9: BSF 05.5 |
|
|
353 |
.................... //rozsvit cervenou |
|
|
354 |
.................... } |
|
|
355 |
.................... |
|
|
356 |
.................... }} |
|
|
357 |
00FA: GOTO 062 |
|
|
358 |
.................... |
|
|
359 |
.................... |
|
|
360 |
00FB: SLEEP |
|
|
361 |
|
|
|
362 |
Configuration Fuses: |
|
|
363 |
Word 1: 3939 XT NOWDT NOPUT NODEBUG NOPROTECT NOBROWNOUT NOLVP NOCPD WRT_50% |