Rev Author Line No. Line
2984 kaklik 1 CCS PCM C Compiler, Version 4.106, 47914 15-V-13 16:26
2926 jacho 2  
2984 kaklik 3 Filename: Z:\home\kaklik\svnMLAB\Modules\Sensors\MAG01A\SW\PIC16F887\main.lst
2926 jacho 4  
2984 kaklik 5 ROM used: 972 words (12%)
2926 jacho 6 Largest free fragment is 2048
2984 kaklik 7 RAM used: 12 (3%) at main() level
2926 jacho 8 22 (6%) worst case
9 Stack: 3 locations
10  
11 *
2984 kaklik 12 0000: MOVLW 03
2926 jacho 13 0001: MOVWF 0A
2984 kaklik 14 0002: GOTO 317
2926 jacho 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 ....................
2984 kaklik 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
2926 jacho 37 ....................
38 .................... #use delay(clock=8000000)
39 *
2984 kaklik 40 0069: MOVLW 27
41 006A: MOVWF 04
42 006B: BCF 03.7
43 006C: MOVF 00,W
44 006D: BTFSC 03.2
45 006E: GOTO 07C
46 006F: MOVLW 02
47 0070: MOVWF 78
48 0071: CLRF 77
49 0072: DECFSZ 77,F
50 0073: GOTO 072
51 0074: DECFSZ 78,F
52 0075: GOTO 071
53 0076: MOVLW 97
54 0077: MOVWF 77
55 0078: DECFSZ 77,F
56 0079: GOTO 078
57 007A: DECFSZ 00,F
58 007B: GOTO 06F
59 007C: RETURN
60 .................... #use i2c(master, sda=PIN_C4, scl=PIN_C3)
2926 jacho 61 *
2984 kaklik 62 001F: MOVLW 08
63 0020: MOVWF 78
64 0021: NOP
65 0022: BCF 07.3
66 0023: BCF 20.3
67 0024: MOVF 20,W
68 0025: BSF 03.5
69 0026: MOVWF 07
70 0027: NOP
71 0028: BCF 03.5
72 0029: RLF 2C,F
73 002A: BCF 07.4
74 002B: BTFSS 03.0
75 002C: GOTO 033
76 002D: BSF 20.4
77 002E: MOVF 20,W
78 002F: BSF 03.5
79 0030: MOVWF 07
80 0031: GOTO 037
81 0032: BCF 03.5
82 0033: BCF 20.4
83 0034: MOVF 20,W
84 0035: BSF 03.5
85 0036: MOVWF 07
86 0037: NOP
87 0038: BCF 03.5
88 0039: BSF 20.3
89 003A: MOVF 20,W
90 003B: BSF 03.5
91 003C: MOVWF 07
92 003D: BCF 03.5
93 003E: BTFSS 07.3
94 003F: GOTO 03E
95 0040: DECFSZ 78,F
96 0041: GOTO 021
97 0042: NOP
98 0043: BCF 07.3
99 0044: BCF 20.3
100 0045: MOVF 20,W
101 0046: BSF 03.5
102 0047: MOVWF 07
103 0048: NOP
104 0049: BCF 03.5
105 004A: BSF 20.4
106 004B: MOVF 20,W
107 004C: BSF 03.5
108 004D: MOVWF 07
109 004E: NOP
110 004F: NOP
111 0050: BCF 03.5
112 0051: BSF 20.3
113 0052: MOVF 20,W
114 0053: BSF 03.5
115 0054: MOVWF 07
116 0055: BCF 03.5
117 0056: BTFSS 07.3
118 0057: GOTO 056
119 0058: CLRF 78
120 0059: NOP
121 005A: BTFSC 07.4
122 005B: BSF 78.0
123 005C: BCF 07.3
124 005D: BCF 20.3
125 005E: MOVF 20,W
126 005F: BSF 03.5
127 0060: MOVWF 07
128 0061: BCF 03.5
129 0062: BCF 07.4
130 0063: BCF 20.4
131 0064: MOVF 20,W
132 0065: BSF 03.5
133 0066: MOVWF 07
134 0067: BCF 03.5
135 0068: RETURN
2926 jacho 136 *
2984 kaklik 137 01EB: MOVLW 08
138 01EC: MOVWF 2D
139 01ED: MOVF 77,W
140 01EE: MOVWF 2E
141 01EF: BSF 20.4
142 01F0: MOVF 20,W
143 01F1: BSF 03.5
144 01F2: MOVWF 07
145 01F3: NOP
146 01F4: BCF 03.5
147 01F5: BSF 20.3
148 01F6: MOVF 20,W
149 01F7: BSF 03.5
150 01F8: MOVWF 07
151 01F9: BCF 03.5
152 01FA: BTFSS 07.3
153 01FB: GOTO 1FA
154 01FC: BTFSC 07.4
155 01FD: BSF 03.0
156 01FE: BTFSS 07.4
157 01FF: BCF 03.0
158 0200: RLF 78,F
159 0201: NOP
160 0202: BCF 20.3
161 0203: MOVF 20,W
162 0204: BSF 03.5
163 0205: MOVWF 07
164 0206: BCF 03.5
165 0207: BCF 07.3
166 0208: DECFSZ 2D,F
167 0209: GOTO 1EF
168 020A: BSF 20.4
169 020B: MOVF 20,W
170 020C: BSF 03.5
171 020D: MOVWF 07
172 020E: NOP
173 020F: BCF 03.5
174 0210: BCF 07.4
175 0211: MOVF 2E,W
176 0212: BTFSC 03.2
177 0213: GOTO 219
178 0214: BCF 20.4
179 0215: MOVF 20,W
180 0216: BSF 03.5
181 0217: MOVWF 07
182 0218: BCF 03.5
183 0219: NOP
184 021A: BSF 20.3
185 021B: MOVF 20,W
186 021C: BSF 03.5
187 021D: MOVWF 07
188 021E: BCF 03.5
189 021F: BTFSS 07.3
190 0220: GOTO 21F
191 0221: NOP
192 0222: BCF 07.3
193 0223: BCF 20.3
194 0224: MOVF 20,W
195 0225: BSF 03.5
196 0226: MOVWF 07
197 0227: NOP
198 0228: BCF 03.5
199 0229: BCF 07.4
200 022A: BCF 20.4
201 022B: MOVF 20,W
202 022C: BSF 03.5
203 022D: MOVWF 07
204 .................... #use rs232(baud=9600,parity=N,xmit=PIN_C7,rcv=PIN_C6,bits=8) //rcv TXD xmit RXD
205 *
206 012F: BCF 20.7
207 0130: MOVF 20,W
2926 jacho 208 0131: BSF 03.5
2984 kaklik 209 0132: MOVWF 07
210 0133: BCF 03.5
211 0134: BCF 07.7
212 0135: MOVLW 08
213 0136: MOVWF 78
214 0137: GOTO 138
215 0138: NOP
216 0139: BSF 78.7
217 013A: GOTO 149
218 013B: BCF 78.7
219 013C: RRF 30,F
220 013D: BTFSC 03.0
221 013E: BSF 07.7
222 013F: BTFSS 03.0
223 0140: BCF 07.7
224 0141: BSF 78.6
225 0142: GOTO 149
226 0143: BCF 78.6
227 0144: DECFSZ 78,F
228 0145: GOTO 13C
229 0146: GOTO 147
230 0147: NOP
231 0148: BSF 07.7
232 0149: MOVLW 3F
233 014A: MOVWF 04
234 014B: DECFSZ 04,F
235 014C: GOTO 14B
236 014D: NOP
237 014E: BTFSC 78.7
238 014F: GOTO 13B
239 0150: BTFSC 78.6
240 0151: GOTO 143
241 0152: RETURN
2926 jacho 242 ....................
2984 kaklik 243 ....................
2926 jacho 244 .................... #include "HMC5883L.h"
245 .................... #define MAG_ADDR_R 0x3D //addresa pro cteni
246 .................... #define MAG_ADDR_W 0x3C
247 ....................
248 ....................
249 .................... //Konstanty nastavujici rozsah
250 .................... //pro void set_mag_roz (unsigned int8 h)
251 .................... #define MAG_ROZ088 0x00
252 .................... #define MAG_ROZ130 0x20
253 .................... #define MAG_ROZ190 0x40
254 .................... #define MAG_ROZ250 0x60
255 .................... #define MAG_ROZ400 0x80
256 .................... #define MAG_ROZ470 0xA0
257 .................... #define MAG_ROZ560 0xC0
258 .................... #define MAG_ROZ810 0xE0
259 ....................
260 ....................
261 .................... #include "HMC5883L.c"
262 .................... void set_mag (void) //uvodni nastaveni na kontinualni mereni, rozsah ± 8.1 Ga, frekvence mereni 15HZ
263 .................... {
264 .................... i2c_start(); //nastavení Configuration Register A
2984 kaklik 265 *
266 007D: BSF 20.4
267 007E: MOVF 20,W
268 007F: BSF 03.5
269 0080: MOVWF 07
270 0081: NOP
271 0082: BCF 03.5
272 0083: BSF 20.3
273 0084: MOVF 20,W
274 0085: BSF 03.5
275 0086: MOVWF 07
276 0087: NOP
277 0088: BCF 03.5
278 0089: BCF 07.4
279 008A: BCF 20.4
280 008B: MOVF 20,W
281 008C: BSF 03.5
282 008D: MOVWF 07
283 008E: NOP
284 008F: BCF 03.5
285 0090: BCF 07.3
286 0091: BCF 20.3
287 0092: MOVF 20,W
288 0093: BSF 03.5
289 0094: MOVWF 07
2926 jacho 290 .................... I2C_Write(MAG_ADDR_W);
2984 kaklik 291 0095: MOVLW 3C
292 0096: BCF 03.5
293 0097: MOVWF 2C
294 0098: CALL 01F
2926 jacho 295 .................... I2C_Write(0x00);
2984 kaklik 296 0099: CLRF 2C
297 009A: CALL 01F
2926 jacho 298 .................... I2C_Write(0x70);
2984 kaklik 299 009B: MOVLW 70
300 009C: MOVWF 2C
301 009D: CALL 01F
2926 jacho 302 .................... i2c_stop();
2984 kaklik 303 009E: BCF 20.4
304 009F: MOVF 20,W
305 00A0: BSF 03.5
306 00A1: MOVWF 07
307 00A2: NOP
308 00A3: BCF 03.5
309 00A4: BSF 20.3
310 00A5: MOVF 20,W
311 00A6: BSF 03.5
312 00A7: MOVWF 07
313 00A8: BCF 03.5
314 00A9: BTFSS 07.3
315 00AA: GOTO 0A9
316 00AB: NOP
317 00AC: GOTO 0AD
318 00AD: NOP
319 00AE: BSF 20.4
320 00AF: MOVF 20,W
321 00B0: BSF 03.5
322 00B1: MOVWF 07
323 00B2: NOP
2926 jacho 324 .................... Delay_ms(6);
2984 kaklik 325 00B3: MOVLW 06
326 00B4: BCF 03.5
327 00B5: MOVWF 27
328 00B6: CALL 069
2926 jacho 329 ....................
330 .................... i2c_start(); //nastavení Configuration Register B
2984 kaklik 331 00B7: BSF 20.4
332 00B8: MOVF 20,W
333 00B9: BSF 03.5
334 00BA: MOVWF 07
335 00BB: NOP
336 00BC: BCF 03.5
337 00BD: BSF 20.3
338 00BE: MOVF 20,W
339 00BF: BSF 03.5
340 00C0: MOVWF 07
341 00C1: NOP
342 00C2: BCF 03.5
343 00C3: BCF 07.4
344 00C4: BCF 20.4
345 00C5: MOVF 20,W
346 00C6: BSF 03.5
347 00C7: MOVWF 07
348 00C8: NOP
349 00C9: BCF 03.5
350 00CA: BCF 07.3
351 00CB: BCF 20.3
352 00CC: MOVF 20,W
353 00CD: BSF 03.5
354 00CE: MOVWF 07
2926 jacho 355 .................... I2C_Write(MAG_ADDR_W);
2984 kaklik 356 00CF: MOVLW 3C
357 00D0: BCF 03.5
358 00D1: MOVWF 2C
359 00D2: CALL 01F
2926 jacho 360 .................... I2C_Write(0x01);
2984 kaklik 361 00D3: MOVLW 01
362 00D4: MOVWF 2C
363 00D5: CALL 01F
2926 jacho 364 .................... I2C_Write(MAG_ROZ810);
2984 kaklik 365 00D6: MOVLW E0
366 00D7: MOVWF 2C
367 00D8: CALL 01F
2926 jacho 368 .................... i2c_stop();
2984 kaklik 369 00D9: BCF 20.4
370 00DA: MOVF 20,W
371 00DB: BSF 03.5
372 00DC: MOVWF 07
373 00DD: NOP
374 00DE: BCF 03.5
375 00DF: BSF 20.3
376 00E0: MOVF 20,W
377 00E1: BSF 03.5
378 00E2: MOVWF 07
379 00E3: BCF 03.5
380 00E4: BTFSS 07.3
381 00E5: GOTO 0E4
382 00E6: NOP
383 00E7: GOTO 0E8
384 00E8: NOP
385 00E9: BSF 20.4
386 00EA: MOVF 20,W
387 00EB: BSF 03.5
388 00EC: MOVWF 07
389 00ED: NOP
2926 jacho 390 ....................
391 .................... Delay_ms(6);
2984 kaklik 392 00EE: MOVLW 06
393 00EF: BCF 03.5
394 00F0: MOVWF 27
395 00F1: CALL 069
2926 jacho 396 ....................
397 .................... i2c_start(); //nastveni Mode Register
2984 kaklik 398 00F2: BSF 20.4
399 00F3: MOVF 20,W
400 00F4: BSF 03.5
401 00F5: MOVWF 07
402 00F6: NOP
403 00F7: BCF 03.5
404 00F8: BSF 20.3
405 00F9: MOVF 20,W
406 00FA: BSF 03.5
407 00FB: MOVWF 07
408 00FC: NOP
409 00FD: BCF 03.5
410 00FE: BCF 07.4
411 00FF: BCF 20.4
412 0100: MOVF 20,W
413 0101: BSF 03.5
414 0102: MOVWF 07
415 0103: NOP
416 0104: BCF 03.5
417 0105: BCF 07.3
418 0106: BCF 20.3
419 0107: MOVF 20,W
420 0108: BSF 03.5
421 0109: MOVWF 07
2926 jacho 422 .................... I2C_Write(MAG_ADDR_W);
2984 kaklik 423 010A: MOVLW 3C
424 010B: BCF 03.5
425 010C: MOVWF 2C
426 010D: CALL 01F
2926 jacho 427 .................... I2C_Write(0x02);
2984 kaklik 428 010E: MOVLW 02
429 010F: MOVWF 2C
430 0110: CALL 01F
2926 jacho 431 .................... I2C_Write(0x00);
2984 kaklik 432 0111: CLRF 2C
433 0112: CALL 01F
2926 jacho 434 .................... i2c_stop();
2984 kaklik 435 0113: BCF 20.4
436 0114: MOVF 20,W
437 0115: BSF 03.5
438 0116: MOVWF 07
439 0117: NOP
440 0118: BCF 03.5
441 0119: BSF 20.3
442 011A: MOVF 20,W
443 011B: BSF 03.5
444 011C: MOVWF 07
445 011D: BCF 03.5
446 011E: BTFSS 07.3
447 011F: GOTO 11E
448 0120: NOP
449 0121: GOTO 122
450 0122: NOP
451 0123: BSF 20.4
452 0124: MOVF 20,W
453 0125: BSF 03.5
454 0126: MOVWF 07
455 0127: NOP
2926 jacho 456 .................... Delay_ms(6);
2984 kaklik 457 0128: MOVLW 06
458 0129: BCF 03.5
459 012A: MOVWF 27
460 012B: CALL 069
2926 jacho 461 .................... }
2984 kaklik 462 012C: BCF 0A.3
463 012D: BCF 0A.4
464 012E: GOTO 37F (RETURN)
2926 jacho 465 ....................
466 .................... void set_mag_roz (unsigned int8 h) //nastavy rozsah
467 .................... {
468 ....................
469 .................... //
470 ....................
471 ....................
472 .................... i2c_start();
473 .................... I2C_Write(MAG_ADDR_W);
474 .................... I2C_Write(0x01);
475 .................... I2C_Write(h);
476 .................... i2c_stop();
477 ....................
478 .................... Delay_ms(6);
479 ....................
480 ....................
481 .................... }
482 ....................
483 ....................
484 .................... byte mag_read(byte reg) //pro cteni reg
485 .................... {
486 ....................
487 .................... i2c_start();
488 *
2984 kaklik 489 0199: BSF 20.4
490 019A: MOVF 20,W
491 019B: BSF 03.5
492 019C: MOVWF 07
493 019D: NOP
494 019E: BCF 03.5
495 019F: BSF 20.3
496 01A0: MOVF 20,W
497 01A1: BSF 03.5
498 01A2: MOVWF 07
499 01A3: NOP
500 01A4: BCF 03.5
501 01A5: BCF 07.4
502 01A6: BCF 20.4
503 01A7: MOVF 20,W
504 01A8: BSF 03.5
505 01A9: MOVWF 07
506 01AA: NOP
507 01AB: BCF 03.5
508 01AC: BCF 07.3
509 01AD: BCF 20.3
510 01AE: MOVF 20,W
511 01AF: BSF 03.5
512 01B0: MOVWF 07
2926 jacho 513 .................... I2C_Write(MAG_ADDR_W);
2984 kaklik 514 01B1: MOVLW 3C
515 01B2: BCF 03.5
516 01B3: MOVWF 2C
517 01B4: CALL 01F
2926 jacho 518 .................... I2C_write(reg);
2984 kaklik 519 01B5: MOVF 2B,W
520 01B6: MOVWF 2C
521 01B7: CALL 01F
2926 jacho 522 .................... i2c_stop();
2984 kaklik 523 01B8: BCF 20.4
524 01B9: MOVF 20,W
525 01BA: BSF 03.5
526 01BB: MOVWF 07
527 01BC: NOP
528 01BD: BCF 03.5
529 01BE: BSF 20.3
530 01BF: MOVF 20,W
531 01C0: BSF 03.5
532 01C1: MOVWF 07
533 01C2: BCF 03.5
534 01C3: BTFSS 07.3
535 01C4: GOTO 1C3
536 01C5: NOP
537 01C6: GOTO 1C7
538 01C7: NOP
539 01C8: BSF 20.4
540 01C9: MOVF 20,W
541 01CA: BSF 03.5
542 01CB: MOVWF 07
543 01CC: NOP
2926 jacho 544 .................... i2c_start();
2984 kaklik 545 01CD: BCF 03.5
546 01CE: BSF 20.4
547 01CF: MOVF 20,W
548 01D0: BSF 03.5
549 01D1: MOVWF 07
550 01D2: NOP
551 01D3: BCF 03.5
552 01D4: BSF 20.3
553 01D5: MOVF 20,W
554 01D6: BSF 03.5
555 01D7: MOVWF 07
556 01D8: NOP
557 01D9: BCF 03.5
558 01DA: BCF 07.4
559 01DB: BCF 20.4
560 01DC: MOVF 20,W
561 01DD: BSF 03.5
562 01DE: MOVWF 07
563 01DF: NOP
564 01E0: BCF 03.5
565 01E1: BCF 07.3
566 01E2: BCF 20.3
567 01E3: MOVF 20,W
568 01E4: BSF 03.5
569 01E5: MOVWF 07
2926 jacho 570 .................... I2C_Write(MAG_ADDR_R);
2984 kaklik 571 01E6: MOVLW 3D
572 01E7: BCF 03.5
573 01E8: MOVWF 2C
574 01E9: CALL 01F
2926 jacho 575 .................... reg=i2c_read(0);
2984 kaklik 576 01EA: CLRF 77
2926 jacho 577 *
2984 kaklik 578 022E: MOVF 78,W
579 022F: BCF 03.5
580 0230: MOVWF 2B
2926 jacho 581 .................... return reg;
2984 kaklik 582 0231: MOVF 2B,W
583 0232: MOVWF 78
2926 jacho 584 .................... }
2984 kaklik 585 0233: RETURN
2926 jacho 586 ....................
587 ....................
588 .................... signed int16 mag_vypocet(unsigned int8 h, unsigned int8 l) //prepocet na 16bit cislo
589 .................... {
590 .................... signed int16 x;
591 .................... x = (((unsigned int16) h << 8) + l );
2984 kaklik 592 0234: CLRF 30
593 0235: MOVF 2B,W
594 0236: MOVWF 2F
595 0237: MOVWF 30
596 0238: CLRF 2F
597 0239: MOVF 2C,W
598 023A: ADDWF 2F,W
599 023B: MOVWF 78
600 023C: MOVF 30,W
601 023D: MOVWF 7A
602 023E: BTFSC 03.0
603 023F: INCF 7A,F
604 0240: MOVF 78,W
605 0241: MOVWF 2D
606 0242: MOVF 7A,W
607 0243: MOVWF 2E
2926 jacho 608 .................... return x;
2984 kaklik 609 0244: MOVF 2D,W
610 0245: MOVWF 78
611 0246: MOVF 2E,W
612 0247: MOVWF 79
2926 jacho 613 .................... }
2984 kaklik 614 0248: RETURN
2926 jacho 615 ....................
616 ....................
617 .................... signed int16 mag_readX(void) //nacteni osy x
618 .................... {
619 .................... unsigned int8 h,l;
620 .................... signed int16 x;
621 .................... h=mag_read(0x03);
2984 kaklik 622 0249: MOVLW 03
623 024A: MOVWF 2B
624 024B: CALL 199
625 024C: MOVF 78,W
626 024D: MOVWF 27
2926 jacho 627 .................... l=mag_read(0x04);
2984 kaklik 628 024E: MOVLW 04
629 024F: MOVWF 2B
630 0250: CALL 199
631 0251: MOVF 78,W
632 0252: MOVWF 28
2926 jacho 633 .................... x=mag_vypocet(h,l);
2984 kaklik 634 0253: MOVF 27,W
635 0254: MOVWF 2B
636 0255: MOVF 28,W
637 0256: MOVWF 2C
638 0257: CALL 234
639 0258: MOVF 79,W
640 0259: MOVWF 2A
641 025A: MOVF 78,W
642 025B: MOVWF 29
2926 jacho 643 .................... return x;
2984 kaklik 644 025C: MOVF 29,W
645 025D: MOVWF 78
646 025E: MOVF 2A,W
647 025F: MOVWF 79
2926 jacho 648 ....................
649 .................... }
2984 kaklik 650 0260: BCF 0A.3
651 0261: BCF 0A.4
652 0262: GOTO 395 (RETURN)
2926 jacho 653 ....................
654 ....................
655 .................... signed int16 mag_readY(void) //nacteni osy x
656 .................... {
657 .................... unsigned int8 h,l;
658 .................... signed int16 x;
659 .................... h=mag_read(0x07);
2984 kaklik 660 0263: MOVLW 07
661 0264: MOVWF 2B
662 0265: CALL 199
663 0266: MOVF 78,W
664 0267: MOVWF 27
2926 jacho 665 .................... l=mag_read(0x08);
2984 kaklik 666 0268: MOVLW 08
667 0269: MOVWF 2B
668 026A: CALL 199
669 026B: MOVF 78,W
670 026C: MOVWF 28
2926 jacho 671 .................... x=mag_vypocet(h,l);
2984 kaklik 672 026D: MOVF 27,W
673 026E: MOVWF 2B
674 026F: MOVF 28,W
675 0270: MOVWF 2C
676 0271: CALL 234
677 0272: MOVF 79,W
678 0273: MOVWF 2A
679 0274: MOVF 78,W
680 0275: MOVWF 29
2926 jacho 681 .................... return x;
2984 kaklik 682 0276: MOVF 29,W
683 0277: MOVWF 78
684 0278: MOVF 2A,W
685 0279: MOVWF 79
2926 jacho 686 ....................
687 .................... }
2984 kaklik 688 027A: BCF 0A.3
689 027B: BCF 0A.4
690 027C: GOTO 39A (RETURN)
2926 jacho 691 ....................
692 ....................
693 .................... signed int16 mag_readZ(void) //nacteni osy x
694 .................... {
695 .................... unsigned int8 h,l;
696 .................... signed int16 x;
697 .................... h=mag_read(0x05);
2984 kaklik 698 027D: MOVLW 05
699 027E: MOVWF 2B
700 027F: CALL 199
701 0280: MOVF 78,W
702 0281: MOVWF 27
2926 jacho 703 .................... l=mag_read(0x06);
2984 kaklik 704 0282: MOVLW 06
705 0283: MOVWF 2B
706 0284: CALL 199
707 0285: MOVF 78,W
708 0286: MOVWF 28
2926 jacho 709 .................... x=mag_vypocet(h,l);
2984 kaklik 710 0287: MOVF 27,W
711 0288: MOVWF 2B
712 0289: MOVF 28,W
713 028A: MOVWF 2C
714 028B: CALL 234
715 028C: MOVF 79,W
716 028D: MOVWF 2A
717 028E: MOVF 78,W
718 028F: MOVWF 29
2926 jacho 719 .................... return x;
2984 kaklik 720 0290: MOVF 29,W
721 0291: MOVWF 78
722 0292: MOVF 2A,W
723 0293: MOVWF 79
2926 jacho 724 ....................
725 .................... }
2984 kaklik 726 0294: BCF 0A.3
727 0295: BCF 0A.4
728 0296: GOTO 39F (RETURN)
2926 jacho 729 ....................
730 ....................
731 ....................
732 ....................
733 ....................
2984 kaklik 734 ....................
2926 jacho 735 .................... void main()
736 .................... {
737 *
2984 kaklik 738 0317: CLRF 04
739 0318: BCF 03.7
740 0319: MOVLW 1F
741 031A: ANDWF 03,F
742 031B: MOVLW 71
743 031C: BSF 03.5
744 031D: MOVWF 0F
745 031E: MOVF 0F,W
746 031F: BCF 03.5
747 0320: BCF 20.7
748 0321: MOVF 20,W
749 0322: BSF 03.5
750 0323: MOVWF 07
751 0324: BCF 03.5
752 0325: BSF 07.7
753 0326: BSF 03.5
754 0327: BSF 03.6
755 0328: MOVF 09,W
756 0329: ANDLW C0
757 032A: MOVWF 09
758 032B: BCF 03.6
759 032C: BCF 1F.4
760 032D: BCF 1F.5
761 032E: MOVLW 00
762 032F: BSF 03.6
763 0330: MOVWF 08
764 0331: BCF 03.5
765 0332: CLRF 07
766 0333: CLRF 08
767 0334: CLRF 09
768 .................... signed int16 X,Y,Z;
769 .................... setup_adc_ports(NO_ANALOGS|VSS_VDD);
2926 jacho 770 *
2984 kaklik 771 0338: BSF 03.5
772 0339: BSF 03.6
773 033A: MOVF 09,W
774 033B: ANDLW C0
775 033C: MOVWF 09
776 033D: BCF 03.6
777 033E: BCF 1F.4
778 033F: BCF 1F.5
779 0340: MOVLW 00
780 0341: BSF 03.6
781 0342: MOVWF 08
782 .................... setup_adc(ADC_CLOCK_DIV_2);
783 0343: BCF 03.5
784 0344: BCF 03.6
785 0345: BCF 1F.6
786 0346: BCF 1F.7
787 0347: BSF 03.5
788 0348: BCF 1F.7
789 0349: BCF 03.5
790 034A: BSF 1F.0
791 .................... setup_spi(SPI_SS_DISABLED);
792 034B: BCF 14.5
793 034C: BCF 20.5
794 034D: MOVF 20,W
795 034E: BSF 03.5
796 034F: MOVWF 07
797 0350: BCF 03.5
798 0351: BSF 20.4
799 0352: MOVF 20,W
800 0353: BSF 03.5
801 0354: MOVWF 07
802 0355: BCF 03.5
803 0356: BCF 20.3
804 0357: MOVF 20,W
805 0358: BSF 03.5
806 0359: MOVWF 07
807 035A: MOVLW 01
808 035B: BCF 03.5
809 035C: MOVWF 14
810 035D: MOVLW 00
811 035E: BSF 03.5
812 035F: MOVWF 14
813 .................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
814 0360: MOVF 01,W
815 0361: ANDLW C7
816 0362: IORLW 08
817 0363: MOVWF 01
818 .................... setup_timer_1(T1_DISABLED);
819 0364: BCF 03.5
820 0365: CLRF 10
821 .................... setup_timer_2(T2_DISABLED,0,1);
822 0366: MOVLW 00
823 0367: MOVWF 78
824 0368: MOVWF 12
825 0369: MOVLW 00
826 036A: BSF 03.5
827 036B: MOVWF 12
828 .................... setup_ccp1(CCP_OFF);
829 036C: BCF 03.5
830 036D: BSF 20.2
831 036E: MOVF 20,W
832 036F: BSF 03.5
833 0370: MOVWF 07
834 0371: BCF 03.5
835 0372: CLRF 17
836 0373: BSF 03.5
837 0374: CLRF 1B
838 0375: CLRF 1C
839 0376: MOVLW 01
840 0377: MOVWF 1D
841 .................... setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
842 0378: BCF 03.5
843 0379: BSF 03.6
844 037A: CLRF 07
845 037B: CLRF 08
846 037C: CLRF 09
2926 jacho 847 ....................
2984 kaklik 848 .................... set_mag();
849 037D: BCF 03.6
850 037E: GOTO 07D
2926 jacho 851 ....................
2984 kaklik 852 .................... printf("Magnetometr: \r\n",);
853 037F: MOVLW 04
854 0380: BSF 03.6
855 0381: MOVWF 0D
856 0382: MOVLW 00
857 0383: MOVWF 0F
858 0384: BCF 03.6
859 0385: CALL 153
860 .................... printf("(c)mlab JACHO 2013: \r\n",);
861 0386: MOVLW 0D
862 0387: BSF 03.6
863 0388: MOVWF 0D
864 0389: MOVLW 00
865 038A: MOVWF 0F
866 038B: BCF 03.6
867 038C: CALL 153
868 .................... printf("X, Y, Z \r\n",);
869 038D: MOVLW 19
870 038E: BSF 03.6
871 038F: MOVWF 0D
872 0390: MOVLW 00
873 0391: MOVWF 0F
874 0392: BCF 03.6
875 0393: CALL 153
2926 jacho 876 ....................
2984 kaklik 877 .................... while(true)
878 .................... {
879 .................... X = mag_readX();
880 0394: GOTO 249
881 0395: MOVF 79,W
882 0396: MOVWF 22
883 0397: MOVF 78,W
884 0398: MOVWF 21
885 .................... Y = mag_readY();
886 0399: GOTO 263
887 039A: MOVF 79,W
888 039B: MOVWF 24
889 039C: MOVF 78,W
890 039D: MOVWF 23
891 .................... Z = mag_readZ();
892 039E: GOTO 27D
893 039F: MOVF 79,W
894 03A0: MOVWF 26
895 03A1: MOVF 78,W
896 03A2: MOVWF 25
897 .................... printf("%4Ld %4Ld %4Ld \r\n", X, Y, Z);
898 03A3: MOVLW 02
899 03A4: MOVWF 04
900 03A5: MOVF 22,W
901 03A6: MOVWF 28
902 03A7: MOVF 21,W
903 03A8: MOVWF 27
904 03A9: CALL 297
905 03AA: MOVLW 20
906 03AB: MOVWF 30
907 03AC: CALL 12F
908 03AD: MOVLW 02
909 03AE: MOVWF 04
910 03AF: MOVF 24,W
911 03B0: MOVWF 28
912 03B1: MOVF 23,W
913 03B2: MOVWF 27
914 03B3: CALL 297
915 03B4: MOVLW 20
916 03B5: MOVWF 30
917 03B6: CALL 12F
918 03B7: MOVLW 02
919 03B8: MOVWF 04
920 03B9: MOVF 26,W
921 03BA: MOVWF 28
922 03BB: MOVF 25,W
923 03BC: MOVWF 27
924 03BD: CALL 297
925 03BE: MOVLW 20
926 03BF: MOVWF 30
927 03C0: CALL 12F
928 03C1: MOVLW 0D
929 03C2: MOVWF 30
930 03C3: CALL 12F
931 03C4: MOVLW 0A
932 03C5: MOVWF 30
933 03C6: CALL 12F
934 .................... Delay_ms(50);
935 03C7: MOVLW 32
936 03C8: MOVWF 27
937 03C9: CALL 069
2926 jacho 938 ....................
2984 kaklik 939 .................... }
940 03CA: GOTO 394
2926 jacho 941 .................... }
2984 kaklik 942 03CB: SLEEP
2926 jacho 943  
944 Configuration Fuses:
945 Word 1: 2CF5 INTRC NOWDT NOPUT MCLR NOPROTECT NOCPD NOBROWNOUT IESO FCMEN NOLVP NODEBUG
946 Word 2: 3FFF NOWRT BORV40