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