Rev Author Line No. Line
165 krcmar 1 CCS PCM C Compiler, Version 4.059d, 15399 19-III-07 15:20
160 krcmar 2  
3 Filename: main.lst
4  
165 krcmar 5 ROM used: 268 words (13%)
6 Largest free fragment is 1780
160 krcmar 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
165 krcmar 16 ....................
160 krcmar 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
165 krcmar 67 .................... int8 t; // Promenna pro nacteni hodnoty z cidla
160 krcmar 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 ....................
165 krcmar 160 ....................
161 ....................
162 .................... while(TRUE){
163 .................... t=read_adc(); // Prvni precteni cidla
160 krcmar 164 0062: BSF 1F.2
165 0063: BTFSC 1F.2
166 0064: GOTO 063
167 0065: MOVF 1E,W
168 0066: MOVWF 21
165 krcmar 169 .................... //printf("%d\n\r",t);
160 krcmar 170 ....................
165 krcmar 171 .................... if(t>00&&t<40){
160 krcmar 172 0067: MOVF 21,F
173 0068: BTFSC 03.2
165 krcmar 174 0069: GOTO 07B
160 krcmar 175 006A: MOVF 21,W
165 krcmar 176 006B: SUBLW 27
160 krcmar 177 006C: BTFSS 03.0
165 krcmar 178 006D: GOTO 07B
179 .................... output_low(LED2);
160 krcmar 180 006E: BSF 03.5
165 krcmar 181 006F: BCF 05.3
160 krcmar 182 0070: BCF 03.5
165 krcmar 183 0071: BCF 05.3
184 .................... output_low(LED3);
185 0072: BSF 03.5
186 0073: BCF 05.5
187 0074: BCF 03.5
188 0075: BCF 05.5
189 .................... output_high(LED1);
190 0076: BSF 03.5
191 0077: BCF 05.2
192 0078: BCF 03.5
193 0079: BSF 05.2
160 krcmar 194 .................... //rozsvit modrou
195 .................... }
165 krcmar 196 .................... else if(t>39&&t<60){
197 007A: GOTO 10A
198 007B: MOVF 21,W
199 007C: SUBLW 27
200 007D: BTFSC 03.0
201 007E: GOTO 0B0
202 007F: MOVF 21,W
203 0080: SUBLW 3B
204 0081: BTFSS 03.0
205 0082: GOTO 0B0
206 .................... output_low(LED3);
207 0083: BSF 03.5
208 0084: BCF 05.5
209 0085: BCF 03.5
210 0086: BCF 05.5
211 .................... output_high (LED1); // Zhasneme LED
212 0087: BSF 03.5
213 0088: BCF 05.2
214 0089: BCF 03.5
215 008A: BSF 05.2
160 krcmar 216 .................... delay_us(100);
165 krcmar 217 008B: CLRWDT
218 008C: MOVLW 20
219 008D: MOVWF 77
220 008E: DECFSZ 77,F
221 008F: GOTO 08E
222 0090: GOTO 091
160 krcmar 223 .................... output_low (LED1); // Rozsvitime LED
165 krcmar 224 0091: BSF 03.5
225 0092: BCF 05.2
226 0093: BCF 03.5
227 0094: BCF 05.2
160 krcmar 228 .................... delay_us(100);
165 krcmar 229 0095: CLRWDT
230 0096: MOVLW 20
231 0097: MOVWF 77
232 0098: DECFSZ 77,F
233 0099: GOTO 098
234 009A: GOTO 09B
160 krcmar 235 .................... output_low (LED2); // Rozsvitime LED
165 krcmar 236 009B: BSF 03.5
237 009C: BCF 05.3
238 009D: BCF 03.5
239 009E: BCF 05.3
160 krcmar 240 .................... delay_us(100);
165 krcmar 241 009F: CLRWDT
242 00A0: MOVLW 20
243 00A1: MOVWF 77
244 00A2: DECFSZ 77,F
245 00A3: GOTO 0A2
246 00A4: GOTO 0A5
160 krcmar 247 .................... output_high (LED2); // Zhasneme LED
165 krcmar 248 00A5: BSF 03.5
249 00A6: BCF 05.3
250 00A7: BCF 03.5
251 00A8: BSF 05.3
160 krcmar 252 .................... delay_us(100);
165 krcmar 253 00A9: CLRWDT
254 00AA: MOVLW 20
255 00AB: MOVWF 77
256 00AC: DECFSZ 77,F
257 00AD: GOTO 0AC
258 00AE: GOTO 0AF
160 krcmar 259 .................... //rozsvit modrou+zelenou
260 .................... }
165 krcmar 261 .................... else if(t>59&&t<80){
262 00AF: GOTO 10A
263 00B0: MOVF 21,W
264 00B1: SUBLW 3B
265 00B2: BTFSC 03.0
266 00B3: GOTO 0C5
267 00B4: MOVF 21,W
268 00B5: SUBLW 4F
269 00B6: BTFSS 03.0
270 00B7: GOTO 0C5
271 .................... output_low(LED3);
272 00B8: BSF 03.5
273 00B9: BCF 05.5
274 00BA: BCF 03.5
275 00BB: BCF 05.5
276 .................... output_low(LED1);
277 00BC: BSF 03.5
278 00BD: BCF 05.2
279 00BE: BCF 03.5
280 00BF: BCF 05.2
281 .................... output_high(LED2);
282 00C0: BSF 03.5
283 00C1: BCF 05.3
284 00C2: BCF 03.5
285 00C3: BSF 05.3
160 krcmar 286 .................... //rozvit zelenou
287 .................... }
165 krcmar 288 .................... else if(t>79&&t<100){
289 00C4: GOTO 10A
160 krcmar 290 00C5: MOVF 21,W
165 krcmar 291 00C6: SUBLW 4F
292 00C7: BTFSC 03.0
293 00C8: GOTO 0FA
294 00C9: MOVF 21,W
295 00CA: SUBLW 63
296 00CB: BTFSS 03.0
297 00CC: GOTO 0FA
298 .................... output_low(LED1);
299 00CD: BSF 03.5
300 00CE: BCF 05.2
301 00CF: BCF 03.5
302 00D0: BCF 05.2
303 .................... output_high (LED3); // Zhasneme LED
304 00D1: BSF 03.5
305 00D2: BCF 05.5
306 00D3: BCF 03.5
307 00D4: BSF 05.5
160 krcmar 308 .................... delay_us(100);
165 krcmar 309 00D5: CLRWDT
310 00D6: MOVLW 20
311 00D7: MOVWF 77
312 00D8: DECFSZ 77,F
313 00D9: GOTO 0D8
314 00DA: GOTO 0DB
160 krcmar 315 .................... output_low (LED3); // Rozsvitime LED
165 krcmar 316 00DB: BSF 03.5
317 00DC: BCF 05.5
318 00DD: BCF 03.5
319 00DE: BCF 05.5
160 krcmar 320 .................... delay_us(100);
165 krcmar 321 00DF: CLRWDT
322 00E0: MOVLW 20
323 00E1: MOVWF 77
324 00E2: DECFSZ 77,F
325 00E3: GOTO 0E2
326 00E4: GOTO 0E5
160 krcmar 327 .................... output_low (LED2); // Rozsvitime LED
165 krcmar 328 00E5: BSF 03.5
329 00E6: BCF 05.3
330 00E7: BCF 03.5
331 00E8: BCF 05.3
160 krcmar 332 .................... delay_us(100);
165 krcmar 333 00E9: CLRWDT
334 00EA: MOVLW 20
335 00EB: MOVWF 77
336 00EC: DECFSZ 77,F
337 00ED: GOTO 0EC
338 00EE: GOTO 0EF
160 krcmar 339 .................... output_high (LED2); // Zhasneme LED
165 krcmar 340 00EF: BSF 03.5
341 00F0: BCF 05.3
342 00F1: BCF 03.5
343 00F2: BSF 05.3
160 krcmar 344 .................... delay_us(100);
165 krcmar 345 00F3: CLRWDT
346 00F4: MOVLW 20
347 00F5: MOVWF 77
348 00F6: DECFSZ 77,F
349 00F7: GOTO 0F6
350 00F8: GOTO 0F9
160 krcmar 351 .................... //rozsvit zelenou+cervenou
352 .................... }
165 krcmar 353 .................... else if(t>99){
354 00F9: GOTO 10A
355 00FA: MOVF 21,W
356 00FB: SUBLW 63
357 00FC: BTFSC 03.0
358 00FD: GOTO 10A
359 .................... output_low(LED1);
360 00FE: BSF 03.5
361 00FF: BCF 05.2
362 0100: BCF 03.5
363 0101: BCF 05.2
364 .................... output_low(LED2);
365 0102: BSF 03.5
366 0103: BCF 05.3
367 0104: BCF 03.5
368 0105: BCF 05.3
369 .................... output_high(LED3);
370 0106: BSF 03.5
371 0107: BCF 05.5
372 0108: BCF 03.5
373 0109: BSF 05.5
160 krcmar 374 .................... //rozsvit cervenou
375 .................... }
376 .................... }}
165 krcmar 377 010A: GOTO 062
160 krcmar 378 ....................
379 ....................
165 krcmar 380 010B: SLEEP
160 krcmar 381  
382 Configuration Fuses:
383 Word 1: 3939 XT NOWDT NOPUT NODEBUG NOPROTECT NOBROWNOUT NOLVP NOCPD WRT_50%