Rev Author Line No. Line
2978 kaklik 1 CCS PCM C Compiler, Version 4.106, 47914 14-V-13 19:16
2953 jacho 2  
2978 kaklik 3 Filename: Z:\home\kaklik\svnMLAB\Modules\CommSerial\I2CHUB02A\SW\PIC16F887\main.lst
2953 jacho 4  
5 ROM used: 468 words (6%)
6 Largest free fragment is 2048
7 RAM used: 7 (2%) at main() level
8 11 (3%) worst case
9 Stack: 3 locations
10  
11 *
12 0000: MOVLW 01
13 0001: MOVWF 0A
14 0002: GOTO 155
15 0003: NOP
16 .................... #include "main.h"
17 .................... #include <16F887.h>
18 .................... //////// Standard Header file for the PIC16F887 device ////////////////
19 .................... #device PIC16F887
20 .................... #list
21 ....................
22 .................... #device adc=8
23 ....................
24 .................... #FUSES NOWDT //No Watch Dog Timer
25 .................... #FUSES INTRC //Internal RC Osc
26 .................... #FUSES NOPUT //No Power Up Timer
27 .................... #FUSES MCLR //Master Clear pin enabled
28 .................... #FUSES NOPROTECT //Code not protected from reading
29 .................... #FUSES NOCPD //No EE protection
30 .................... #FUSES NOBROWNOUT //No brownout reset
31 .................... #FUSES IESO //Internal External Switch Over mode enabled
32 .................... #FUSES FCMEN //Fail-safe clock monitor enabled
33 .................... #FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
34 .................... #FUSES NODEBUG //No Debug mode for ICD
35 .................... #FUSES NOWRT //Program memory not write protected
36 .................... #FUSES BORV40 //Brownout reset at 4.0V
37 ....................
38 .................... #use delay(clock=8000000)
39 *
40 013F: MOVLW 22
41 0140: MOVWF 04
42 0141: BCF 03.7
43 0142: MOVF 00,W
44 0143: BTFSC 03.2
45 0144: GOTO 152
46 0145: MOVLW 02
47 0146: MOVWF 78
48 0147: CLRF 77
49 0148: DECFSZ 77,F
50 0149: GOTO 148
51 014A: DECFSZ 78,F
52 014B: GOTO 147
53 014C: MOVLW 97
54 014D: MOVWF 77
55 014E: DECFSZ 77,F
56 014F: GOTO 14E
57 0150: DECFSZ 00,F
58 0151: GOTO 145
59 0152: BCF 0A.3
60 0153: BCF 0A.4
61 0154: GOTO 1D0 (RETURN)
62 ....................
63 ....................
64 .................... //I2CHUB
65 .................... //ADRESA pro èteni 0xE1
66 .................... //pro zápis 0xE0
67 ....................
2978 kaklik 68 .................... #use i2c(master, sda=PIN_C4, scl=PIN_C3)
2953 jacho 69 *
70 0083: MOVLW 08
71 0084: MOVWF 78
72 0085: NOP
73 0086: BCF 07.3
74 0087: BCF 20.3
75 0088: MOVF 20,W
76 0089: BSF 03.5
77 008A: MOVWF 07
78 008B: NOP
79 008C: BCF 03.5
80 008D: RLF 22,F
81 008E: BCF 07.4
82 008F: BTFSS 03.0
83 0090: GOTO 097
84 0091: BSF 20.4
85 0092: MOVF 20,W
86 0093: BSF 03.5
87 0094: MOVWF 07
88 0095: GOTO 09B
89 0096: BCF 03.5
90 0097: BCF 20.4
91 0098: MOVF 20,W
92 0099: BSF 03.5
93 009A: MOVWF 07
94 009B: NOP
95 009C: BCF 03.5
96 009D: BSF 20.3
97 009E: MOVF 20,W
98 009F: BSF 03.5
99 00A0: MOVWF 07
100 00A1: BCF 03.5
101 00A2: BTFSS 07.3
102 00A3: GOTO 0A2
103 00A4: DECFSZ 78,F
104 00A5: GOTO 085
105 00A6: NOP
106 00A7: BCF 07.3
107 00A8: BCF 20.3
108 00A9: MOVF 20,W
109 00AA: BSF 03.5
110 00AB: MOVWF 07
111 00AC: NOP
112 00AD: BCF 03.5
113 00AE: BSF 20.4
114 00AF: MOVF 20,W
115 00B0: BSF 03.5
116 00B1: MOVWF 07
117 00B2: NOP
118 00B3: NOP
119 00B4: BCF 03.5
120 00B5: BSF 20.3
121 00B6: MOVF 20,W
122 00B7: BSF 03.5
123 00B8: MOVWF 07
124 00B9: BCF 03.5
125 00BA: BTFSS 07.3
126 00BB: GOTO 0BA
127 00BC: CLRF 78
128 00BD: NOP
129 00BE: BTFSC 07.4
130 00BF: BSF 78.0
131 00C0: BCF 07.3
132 00C1: BCF 20.3
133 00C2: MOVF 20,W
134 00C3: BSF 03.5
135 00C4: MOVWF 07
136 00C5: BCF 03.5
137 00C6: BCF 07.4
138 00C7: BCF 20.4
139 00C8: MOVF 20,W
140 00C9: BSF 03.5
141 00CA: MOVWF 07
142 00CB: BCF 03.5
143 00CC: RETURN
144 .................... #use rs232(baud=9600,parity=N,xmit=PIN_C7,rcv=PIN_C6,bits=8) //rcv TXD xmit RXD
145 *
146 0019: BCF 20.7
147 001A: MOVF 20,W
148 001B: BSF 03.5
149 001C: MOVWF 07
150 001D: BCF 03.5
151 001E: BCF 07.7
152 001F: MOVLW 08
153 0020: MOVWF 78
154 0021: GOTO 022
155 0022: NOP
156 0023: BSF 78.7
157 0024: GOTO 033
158 0025: BCF 78.7
159 0026: RRF 25,F
160 0027: BTFSC 03.0
161 0028: BSF 07.7
162 0029: BTFSS 03.0
163 002A: BCF 07.7
164 002B: BSF 78.6
165 002C: GOTO 033
166 002D: BCF 78.6
167 002E: DECFSZ 78,F
168 002F: GOTO 026
169 0030: GOTO 031
170 0031: NOP
171 0032: BSF 07.7
172 0033: MOVLW 3F
173 0034: MOVWF 04
174 0035: DECFSZ 04,F
175 0036: GOTO 035
176 0037: NOP
177 0038: BTFSC 78.7
178 0039: GOTO 025
179 003A: BTFSC 78.6
180 003B: GOTO 02D
181 003C: RETURN
182 ....................
183 .................... void setHUB(int d) //vstupuje 1-8
184 .................... //hodnota udava jaky port bude pripojen na master I2C
185 .................... //zde je nastaveno propojeni jen jedne brany, je mozne propojit i vice bran naraz
186 .................... {
187 .................... switch (d) {
188 *
189 00CD: MOVF 21,W
190 00CE: XORLW 01
191 00CF: BTFSC 03.2
192 00D0: GOTO 0E7
193 00D1: XORLW 03
194 00D2: BTFSC 03.2
195 00D3: GOTO 0EA
196 00D4: XORLW 01
197 00D5: BTFSC 03.2
198 00D6: GOTO 0ED
199 00D7: XORLW 07
200 00D8: BTFSC 03.2
201 00D9: GOTO 0F0
202 00DA: XORLW 01
203 00DB: BTFSC 03.2
204 00DC: GOTO 0F3
205 00DD: XORLW 03
206 00DE: BTFSC 03.2
207 00DF: GOTO 0F6
208 00E0: XORLW 01
209 00E1: BTFSC 03.2
210 00E2: GOTO 0F9
211 00E3: XORLW 0F
212 00E4: BTFSC 03.2
213 00E5: GOTO 0FC
214 00E6: GOTO 0FF
215 ....................
216 .................... case 1: d=0x01;
217 00E7: MOVLW 01
218 00E8: MOVWF 21
219 ....................
220 .................... break;
221 00E9: GOTO 107
222 ....................
223 .................... case 2: d=0x02;
224 00EA: MOVLW 02
225 00EB: MOVWF 21
226 ....................
227 .................... break;
228 00EC: GOTO 107
229 ....................
230 .................... case 3: d=0x04;
231 00ED: MOVLW 04
232 00EE: MOVWF 21
233 ....................
234 .................... break;
235 00EF: GOTO 107
236 ....................
237 .................... case 4: d=0x08;
238 00F0: MOVLW 08
239 00F1: MOVWF 21
240 ....................
241 .................... break;
242 00F2: GOTO 107
243 .................... case 5: d=0x10;
244 00F3: MOVLW 10
245 00F4: MOVWF 21
246 ....................
247 .................... break;
248 00F5: GOTO 107
249 ....................
250 .................... case 6: d=0x20;
251 00F6: MOVLW 20
252 00F7: MOVWF 21
253 ....................
254 .................... break;
255 00F8: GOTO 107
256 .................... case 7: d=0x40;
257 00F9: MOVLW 40
258 00FA: MOVWF 21
259 ....................
260 .................... break;
261 00FB: GOTO 107
262 ....................
263 .................... case 8: d=0x80;
264 00FC: MOVLW 80
265 00FD: MOVWF 21
266 ....................
267 .................... break;
268 00FE: GOTO 107
269 ....................
270 .................... default:printf("chyba");
271 00FF: MOVLW 04
272 0100: BSF 03.6
273 0101: MOVWF 0D
274 0102: MOVLW 00
275 0103: MOVWF 0F
276 0104: BCF 03.6
277 0105: CALL 03D
278 ....................
279 .................... break; }
280 0106: GOTO 107
281 ....................
282 .................... i2c_start();
283 0107: BSF 20.4
284 0108: MOVF 20,W
285 0109: BSF 03.5
286 010A: MOVWF 07
287 010B: NOP
288 010C: BCF 03.5
289 010D: BSF 20.3
290 010E: MOVF 20,W
291 010F: BSF 03.5
292 0110: MOVWF 07
293 0111: NOP
294 0112: BCF 03.5
295 0113: BCF 07.4
296 0114: BCF 20.4
297 0115: MOVF 20,W
298 0116: BSF 03.5
299 0117: MOVWF 07
300 0118: NOP
301 0119: BCF 03.5
302 011A: BCF 07.3
303 011B: BCF 20.3
304 011C: MOVF 20,W
305 011D: BSF 03.5
306 011E: MOVWF 07
307 .................... I2C_Write(0xE0);
308 011F: MOVLW E0
309 0120: BCF 03.5
310 0121: MOVWF 22
311 0122: CALL 083
312 ....................
313 .................... I2C_write(d);
314 0123: MOVF 21,W
315 0124: MOVWF 22
316 0125: CALL 083
317 .................... i2c_stop();
318 0126: BCF 20.4
319 0127: MOVF 20,W
320 0128: BSF 03.5
321 0129: MOVWF 07
322 012A: NOP
323 012B: BCF 03.5
324 012C: BSF 20.3
325 012D: MOVF 20,W
326 012E: BSF 03.5
327 012F: MOVWF 07
328 0130: BCF 03.5
329 0131: BTFSS 07.3
330 0132: GOTO 131
331 0133: NOP
332 0134: GOTO 135
333 0135: NOP
334 0136: BSF 20.4
335 0137: MOVF 20,W
336 0138: BSF 03.5
337 0139: MOVWF 07
338 013A: NOP
339 ....................
340 .................... }
341 013B: BCF 03.5
342 013C: BCF 0A.3
343 013D: BCF 0A.4
344 013E: GOTO 1CB (RETURN)
345 ....................
346 ....................
347 .................... void main()
348 .................... {
349 *
350 0018: DATA 00,00
351 *
352 0155: CLRF 04
353 0156: BCF 03.7
354 0157: MOVLW 1F
355 0158: ANDWF 03,F
356 0159: MOVLW 71
357 015A: BSF 03.5
358 015B: MOVWF 0F
359 015C: MOVF 0F,W
360 015D: BCF 03.5
361 015E: BCF 20.7
362 015F: MOVF 20,W
363 0160: BSF 03.5
364 0161: MOVWF 07
365 0162: BCF 03.5
366 0163: BSF 07.7
367 0164: BSF 03.5
368 0165: BSF 03.6
369 0166: MOVF 09,W
370 0167: ANDLW C0
371 0168: MOVWF 09
372 0169: BCF 03.6
373 016A: BCF 1F.4
374 016B: BCF 1F.5
375 016C: MOVLW 00
376 016D: BSF 03.6
377 016E: MOVWF 08
378 016F: BCF 03.5
379 0170: CLRF 07
380 0171: CLRF 08
381 0172: CLRF 09
382 ....................
383 .................... setup_adc_ports(NO_ANALOGS|VSS_VDD);
384 *
385 0176: BSF 03.5
386 0177: BSF 03.6
387 0178: MOVF 09,W
388 0179: ANDLW C0
389 017A: MOVWF 09
390 017B: BCF 03.6
391 017C: BCF 1F.4
392 017D: BCF 1F.5
393 017E: MOVLW 00
394 017F: BSF 03.6
395 0180: MOVWF 08
396 .................... setup_adc(ADC_CLOCK_DIV_2);
397 0181: BCF 03.5
398 0182: BCF 03.6
399 0183: BCF 1F.6
400 0184: BCF 1F.7
401 0185: BSF 03.5
402 0186: BCF 1F.7
403 0187: BCF 03.5
404 0188: BSF 1F.0
405 .................... setup_spi(SPI_SS_DISABLED);
406 0189: BCF 14.5
407 018A: BCF 20.5
408 018B: MOVF 20,W
409 018C: BSF 03.5
410 018D: MOVWF 07
411 018E: BCF 03.5
412 018F: BSF 20.4
413 0190: MOVF 20,W
414 0191: BSF 03.5
415 0192: MOVWF 07
416 0193: BCF 03.5
417 0194: BCF 20.3
418 0195: MOVF 20,W
419 0196: BSF 03.5
420 0197: MOVWF 07
421 0198: MOVLW 01
422 0199: BCF 03.5
423 019A: MOVWF 14
424 019B: MOVLW 00
425 019C: BSF 03.5
426 019D: MOVWF 14
427 .................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
428 019E: MOVF 01,W
429 019F: ANDLW C7
430 01A0: IORLW 08
431 01A1: MOVWF 01
432 .................... setup_timer_1(T1_DISABLED);
433 01A2: BCF 03.5
434 01A3: CLRF 10
435 .................... setup_timer_2(T2_DISABLED,0,1);
436 01A4: MOVLW 00
437 01A5: MOVWF 78
438 01A6: MOVWF 12
439 01A7: MOVLW 00
440 01A8: BSF 03.5
441 01A9: MOVWF 12
442 .................... setup_ccp1(CCP_OFF);
443 01AA: BCF 03.5
444 01AB: BSF 20.2
445 01AC: MOVF 20,W
446 01AD: BSF 03.5
447 01AE: MOVWF 07
448 01AF: BCF 03.5
449 01B0: CLRF 17
450 01B1: BSF 03.5
451 01B2: CLRF 1B
452 01B3: CLRF 1C
453 01B4: MOVLW 01
454 01B5: MOVWF 1D
455 .................... setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
456 01B6: BCF 03.5
457 01B7: BSF 03.6
458 01B8: CLRF 07
459 01B9: CLRF 08
460 01BA: CLRF 09
461 ....................
462 .................... printf("I2CHUB \r\n",);
463 01BB: MOVLW 07
464 01BC: MOVWF 0D
465 01BD: MOVLW 00
466 01BE: MOVWF 0F
467 01BF: BCF 03.6
468 01C0: CALL 03D
469 .................... printf("(c)MLAB 2013 JACHO \r\n",);
470 01C1: MOVLW 0D
471 01C2: BSF 03.6
472 01C3: MOVWF 0D
473 01C4: MOVLW 00
474 01C5: MOVWF 0F
475 01C6: BCF 03.6
476 01C7: CALL 03D
477 ....................
478 .................... while(TRUE)
479 .................... {
480 .................... setHUB(3); //pripoji prislusnou branu
481 01C8: MOVLW 03
482 01C9: MOVWF 21
483 01CA: GOTO 0CD
484 .................... delay_ms(1000);
485 01CB: MOVLW 04
486 01CC: MOVWF 21
487 01CD: MOVLW FA
488 01CE: MOVWF 22
489 01CF: GOTO 13F
490 01D0: DECFSZ 21,F
491 01D1: GOTO 1CD
492 .................... }
493 01D2: GOTO 1C8
494 .................... }
495 ....................
496 01D3: SLEEP
497  
498 Configuration Fuses:
499 Word 1: 2CF5 INTRC NOWDT NOPUT MCLR NOPROTECT NOCPD NOBROWNOUT IESO FCMEN NOLVP NODEBUG
500 Word 2: 3FFF NOWRT BORV40