Rev Author Line No. Line
2985 kaklik 1 CCS PCM C Compiler, Version 4.106, 47914 15-V-13 18:53
2926 jacho 2  
2984 kaklik 3 Filename: Z:\home\kaklik\svnMLAB\Modules\Sensors\MAG01A\SW\PIC16F887\main.lst
2926 jacho 4  
2985 kaklik 5 ROM used: 821 words (10%)
2926 jacho 6 Largest free fragment is 2048
2985 kaklik 7 RAM used: 18 (5%) at main() level
8 27 (7%) worst case
9 Stack: 2 locations
2926 jacho 10  
11 *
2985 kaklik 12 0000: MOVLW 02
2926 jacho 13 0001: MOVWF 0A
2985 kaklik 14 0002: GOTO 250
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)
2984 kaklik 39 .................... #use i2c(master, sda=PIN_C4, scl=PIN_C3)
2926 jacho 40 *
2984 kaklik 41 001F: MOVLW 08
42 0020: MOVWF 78
43 0021: NOP
44 0022: BCF 07.3
45 0023: BCF 20.3
46 0024: MOVF 20,W
47 0025: BSF 03.5
48 0026: MOVWF 07
49 0027: NOP
50 0028: BCF 03.5
2985 kaklik 51 0029: RLF 32,F
2984 kaklik 52 002A: BCF 07.4
53 002B: BTFSS 03.0
54 002C: GOTO 033
55 002D: BSF 20.4
56 002E: MOVF 20,W
57 002F: BSF 03.5
58 0030: MOVWF 07
59 0031: GOTO 037
60 0032: BCF 03.5
61 0033: BCF 20.4
62 0034: MOVF 20,W
63 0035: BSF 03.5
64 0036: MOVWF 07
65 0037: NOP
66 0038: BCF 03.5
67 0039: BSF 20.3
68 003A: MOVF 20,W
69 003B: BSF 03.5
70 003C: MOVWF 07
71 003D: BCF 03.5
72 003E: BTFSS 07.3
73 003F: GOTO 03E
74 0040: DECFSZ 78,F
75 0041: GOTO 021
76 0042: NOP
77 0043: BCF 07.3
78 0044: BCF 20.3
79 0045: MOVF 20,W
80 0046: BSF 03.5
81 0047: MOVWF 07
82 0048: NOP
83 0049: BCF 03.5
84 004A: BSF 20.4
85 004B: MOVF 20,W
86 004C: BSF 03.5
87 004D: MOVWF 07
88 004E: NOP
89 004F: NOP
90 0050: BCF 03.5
91 0051: BSF 20.3
92 0052: MOVF 20,W
93 0053: BSF 03.5
94 0054: MOVWF 07
95 0055: BCF 03.5
96 0056: BTFSS 07.3
97 0057: GOTO 056
98 0058: CLRF 78
99 0059: NOP
100 005A: BTFSC 07.4
101 005B: BSF 78.0
102 005C: BCF 07.3
103 005D: BCF 20.3
104 005E: MOVF 20,W
105 005F: BSF 03.5
106 0060: MOVWF 07
107 0061: BCF 03.5
108 0062: BCF 07.4
109 0063: BCF 20.4
110 0064: MOVF 20,W
111 0065: BSF 03.5
112 0066: MOVWF 07
113 0067: BCF 03.5
114 0068: RETURN
2926 jacho 115 *
2985 kaklik 116 010C: MOVLW 08
117 010D: MOVWF 33
118 010E: MOVF 77,W
119 010F: MOVWF 34
120 0110: BSF 20.4
121 0111: MOVF 20,W
122 0112: BSF 03.5
123 0113: MOVWF 07
124 0114: NOP
125 0115: BCF 03.5
126 0116: BSF 20.3
127 0117: MOVF 20,W
128 0118: BSF 03.5
129 0119: MOVWF 07
130 011A: BCF 03.5
131 011B: BTFSS 07.3
132 011C: GOTO 11B
133 011D: BTFSC 07.4
134 011E: BSF 03.0
135 011F: BTFSS 07.4
136 0120: BCF 03.0
137 0121: RLF 78,F
138 0122: NOP
139 0123: BCF 20.3
140 0124: MOVF 20,W
141 0125: BSF 03.5
142 0126: MOVWF 07
143 0127: BCF 03.5
144 0128: BCF 07.3
145 0129: DECFSZ 33,F
146 012A: GOTO 110
147 012B: BSF 20.4
148 012C: MOVF 20,W
149 012D: BSF 03.5
150 012E: MOVWF 07
151 012F: NOP
152 0130: BCF 03.5
153 0131: BCF 07.4
154 0132: MOVF 34,W
155 0133: BTFSC 03.2
156 0134: GOTO 13A
157 0135: BCF 20.4
158 0136: MOVF 20,W
159 0137: BSF 03.5
160 0138: MOVWF 07
161 0139: BCF 03.5
162 013A: NOP
163 013B: BSF 20.3
164 013C: MOVF 20,W
165 013D: BSF 03.5
166 013E: MOVWF 07
167 013F: BCF 03.5
168 0140: BTFSS 07.3
169 0141: GOTO 140
170 0142: NOP
171 0143: BCF 07.3
172 0144: BCF 20.3
173 0145: MOVF 20,W
174 0146: BSF 03.5
175 0147: MOVWF 07
176 0148: NOP
177 0149: BCF 03.5
178 014A: BCF 07.4
179 014B: BCF 20.4
180 014C: MOVF 20,W
181 014D: BSF 03.5
182 014E: MOVWF 07
183 014F: BCF 03.5
184 0150: RETURN
2984 kaklik 185 .................... #use rs232(baud=9600,parity=N,xmit=PIN_C7,rcv=PIN_C6,bits=8) //rcv TXD xmit RXD
186 *
2985 kaklik 187 00A2: BCF 20.7
188 00A3: MOVF 20,W
189 00A4: BSF 03.5
190 00A5: MOVWF 07
191 00A6: BCF 03.5
192 00A7: BCF 07.7
193 00A8: MOVLW 08
194 00A9: MOVWF 78
195 00AA: GOTO 0AB
196 00AB: NOP
197 00AC: BSF 78.7
198 00AD: GOTO 0BC
199 00AE: BCF 78.7
200 00AF: RRF 35,F
201 00B0: BTFSC 03.0
202 00B1: BSF 07.7
203 00B2: BTFSS 03.0
204 00B3: BCF 07.7
205 00B4: BSF 78.6
206 00B5: GOTO 0BC
207 00B6: BCF 78.6
208 00B7: DECFSZ 78,F
209 00B8: GOTO 0AF
210 00B9: GOTO 0BA
211 00BA: NOP
212 00BB: BSF 07.7
213 00BC: MOVLW 3F
214 00BD: MOVWF 04
215 00BE: DECFSZ 04,F
216 00BF: GOTO 0BE
217 00C0: NOP
218 00C1: BTFSC 78.7
219 00C2: GOTO 0AE
220 00C3: BTFSC 78.6
221 00C4: GOTO 0B6
222 00C5: RETURN
2926 jacho 223 ....................
2984 kaklik 224 ....................
2926 jacho 225 .................... #include "HMC5883L.h"
226 .................... #define MAG_ADDR_R 0x3D //addresa pro cteni
227 .................... #define MAG_ADDR_W 0x3C
228 ....................
229 ....................
230 .................... //Konstanty nastavujici rozsah
231 .................... //pro void set_mag_roz (unsigned int8 h)
232 .................... #define MAG_ROZ088 0x00
233 .................... #define MAG_ROZ130 0x20
234 .................... #define MAG_ROZ190 0x40
235 .................... #define MAG_ROZ250 0x60
236 .................... #define MAG_ROZ400 0x80
237 .................... #define MAG_ROZ470 0xA0
238 .................... #define MAG_ROZ560 0xC0
239 .................... #define MAG_ROZ810 0xE0
240 ....................
241 ....................
242 .................... #include "HMC5883L.c"
2985 kaklik 243 .................... // i2c slave addresses
244 .................... #define HMC5883L_WRT_ADDR 0x3C
245 .................... #define HMC5883L_READ_ADDR 0x3D
246 ....................
247 .................... // Register addresses
248 .................... #define HMC5883L_CFG_A_REG 0x00
249 .................... #define HMC5883L_CFG_B_REG 0x01
250 .................... #define HMC5883L_MODE_REG 0x02
251 .................... #define HMC5883L_X_MSB_REG 0x03
252 ....................
253 .................... //------------------------------
254 .................... // Low level routines
255 .................... //------------------------------
256 .................... void hmc5883l_write_reg(int8 reg, int8 data)
2926 jacho 257 .................... {
2985 kaklik 258 .................... i2c_start();
2984 kaklik 259 *
2985 kaklik 260 0069: BSF 20.4
261 006A: MOVF 20,W
262 006B: BSF 03.5
263 006C: MOVWF 07
264 006D: NOP
265 006E: BCF 03.5
266 006F: BSF 20.3
267 0070: MOVF 20,W
268 0071: BSF 03.5
269 0072: MOVWF 07
270 0073: NOP
271 0074: BCF 03.5
272 0075: BCF 07.4
273 0076: BCF 20.4
274 0077: MOVF 20,W
275 0078: BSF 03.5
276 0079: MOVWF 07
277 007A: NOP
278 007B: BCF 03.5
279 007C: BCF 07.3
280 007D: BCF 20.3
2984 kaklik 281 007E: MOVF 20,W
282 007F: BSF 03.5
283 0080: MOVWF 07
2985 kaklik 284 .................... i2c_write(HMC5883L_WRT_ADDR);
285 0081: MOVLW 3C
2984 kaklik 286 0082: BCF 03.5
2985 kaklik 287 0083: MOVWF 32
288 0084: CALL 01F
289 .................... i2c_write(reg);
290 0085: MOVF 2C,W
291 0086: MOVWF 32
292 0087: CALL 01F
293 .................... i2c_write(data);
294 0088: MOVF 2D,W
295 0089: MOVWF 32
296 008A: CALL 01F
297 .................... i2c_stop();
298 008B: BCF 20.4
299 008C: MOVF 20,W
300 008D: BSF 03.5
301 008E: MOVWF 07
302 008F: NOP
303 0090: BCF 03.5
304 0091: BSF 20.3
2984 kaklik 305 0092: MOVF 20,W
306 0093: BSF 03.5
307 0094: MOVWF 07
2985 kaklik 308 0095: BCF 03.5
309 0096: BTFSS 07.3
310 0097: GOTO 096
311 0098: NOP
312 0099: GOTO 09A
313 009A: NOP
314 009B: BSF 20.4
315 009C: MOVF 20,W
316 009D: BSF 03.5
317 009E: MOVWF 07
318 009F: NOP
2926 jacho 319 .................... }
2985 kaklik 320 00A0: BCF 03.5
321 00A1: RETURN
2926 jacho 322 ....................
2985 kaklik 323 .................... //------------------------------
324 .................... int8 hmc5883l_read_reg(int8 reg)
2926 jacho 325 .................... {
2985 kaklik 326 .................... int8 retval;
2926 jacho 327 ....................
2985 kaklik 328 .................... i2c_start();
329 .................... i2c_write(HMC5883L_WRT_ADDR);
330 .................... i2c_write(reg);
331 .................... i2c_start();
332 .................... i2c_write(HMC5883L_READ_ADDR);
333 .................... retval = i2c_read(0);
334 .................... i2c_stop();
2926 jacho 335 ....................
2985 kaklik 336 .................... return(retval);
2926 jacho 337 .................... }
338 ....................
2985 kaklik 339 .................... //------------------------------
340 .................... typedef struct
341 .................... {
342 .................... signed int16 x;
343 .................... signed int16 y;
344 .................... signed int16 z;
345 .................... }hmc5883l_result;
2926 jacho 346 ....................
2985 kaklik 347 .................... // This global structure holds the values read
348 .................... // from the HMC5883L x,y,z registers.
349 .................... hmc5883l_result compass = {0,0,0};
2926 jacho 350 *
2985 kaklik 351 0271: CLRF 21
352 0272: CLRF 22
353 0273: CLRF 23
354 0274: CLRF 24
355 0275: CLRF 25
356 0276: CLRF 26
2926 jacho 357 ....................
2985 kaklik 358 .................... //------------------------------
359 .................... void hmc5883l_read_data(void)
2926 jacho 360 .................... {
2985 kaklik 361 .................... unsigned int8 x_lsb;
362 .................... unsigned int8 x_msb;
2926 jacho 363 ....................
2985 kaklik 364 .................... unsigned int8 y_lsb;
365 .................... unsigned int8 y_msb;
2926 jacho 366 ....................
2985 kaklik 367 .................... unsigned int8 z_lsb;
368 .................... unsigned int8 z_msb;
2926 jacho 369 ....................
2985 kaklik 370 .................... i2c_start();
371 *
372 0151: BSF 20.4
373 0152: MOVF 20,W
374 0153: BSF 03.5
375 0154: MOVWF 07
376 0155: NOP
377 0156: BCF 03.5
378 0157: BSF 20.3
379 0158: MOVF 20,W
380 0159: BSF 03.5
381 015A: MOVWF 07
382 015B: NOP
383 015C: BCF 03.5
384 015D: BCF 07.4
385 015E: BCF 20.4
386 015F: MOVF 20,W
387 0160: BSF 03.5
388 0161: MOVWF 07
389 0162: NOP
390 0163: BCF 03.5
391 0164: BCF 07.3
392 0165: BCF 20.3
393 0166: MOVF 20,W
394 0167: BSF 03.5
395 0168: MOVWF 07
396 .................... i2c_write(HMC5883L_WRT_ADDR);
397 0169: MOVLW 3C
398 016A: BCF 03.5
399 016B: MOVWF 32
400 016C: CALL 01F
401 .................... i2c_write(HMC5883L_X_MSB_REG); // Point to X-msb register
402 016D: MOVLW 03
403 016E: MOVWF 32
404 016F: CALL 01F
405 .................... i2c_start();
406 0170: BSF 20.4
407 0171: MOVF 20,W
408 0172: BSF 03.5
409 0173: MOVWF 07
410 0174: NOP
411 0175: BCF 03.5
412 0176: BSF 20.3
413 0177: MOVF 20,W
414 0178: BSF 03.5
415 0179: MOVWF 07
416 017A: NOP
417 017B: BCF 03.5
418 017C: BTFSS 07.3
419 017D: GOTO 17C
420 017E: BCF 07.4
421 017F: BCF 20.4
422 0180: MOVF 20,W
423 0181: BSF 03.5
424 0182: MOVWF 07
425 0183: NOP
426 0184: BCF 03.5
427 0185: BCF 07.3
428 0186: BCF 20.3
429 0187: MOVF 20,W
430 0188: BSF 03.5
431 0189: MOVWF 07
432 .................... i2c_write(HMC5883L_READ_ADDR);
433 018A: MOVLW 3D
434 018B: BCF 03.5
435 018C: MOVWF 32
436 018D: CALL 01F
2926 jacho 437 ....................
2985 kaklik 438 .................... x_msb = i2c_read();
439 018E: MOVLW 01
440 018F: MOVWF 77
441 0190: CALL 10C
442 0191: MOVF 78,W
443 0192: MOVWF 2D
444 .................... x_lsb = i2c_read();
445 0193: MOVLW 01
446 0194: MOVWF 77
447 0195: CALL 10C
448 0196: MOVF 78,W
449 0197: MOVWF 2C
2926 jacho 450 ....................
2985 kaklik 451 .................... z_msb = i2c_read();
452 0198: MOVLW 01
453 0199: MOVWF 77
454 019A: CALL 10C
455 019B: MOVF 78,W
456 019C: MOVWF 31
457 .................... z_lsb = i2c_read();
458 019D: MOVLW 01
459 019E: MOVWF 77
460 019F: CALL 10C
461 01A0: MOVF 78,W
462 01A1: MOVWF 30
2926 jacho 463 ....................
2985 kaklik 464 .................... y_msb = i2c_read();
465 01A2: MOVLW 01
466 01A3: MOVWF 77
467 01A4: CALL 10C
468 01A5: MOVF 78,W
469 01A6: MOVWF 2F
470 .................... y_lsb = i2c_read(0); // do a NACK on last read
471 01A7: CLRF 77
472 01A8: CALL 10C
473 01A9: MOVF 78,W
474 01AA: MOVWF 2E
475 ....................
476 .................... i2c_stop();
477 01AB: BCF 20.4
478 01AC: MOVF 20,W
479 01AD: BSF 03.5
480 01AE: MOVWF 07
481 01AF: NOP
482 01B0: BCF 03.5
483 01B1: BSF 20.3
484 01B2: MOVF 20,W
485 01B3: BSF 03.5
486 01B4: MOVWF 07
487 01B5: BCF 03.5
488 01B6: BTFSS 07.3
489 01B7: GOTO 1B6
490 01B8: NOP
491 01B9: GOTO 1BA
492 01BA: NOP
493 01BB: BSF 20.4
494 01BC: MOVF 20,W
495 01BD: BSF 03.5
496 01BE: MOVWF 07
497 01BF: NOP
498 ....................
499 .................... // Combine high and low bytes into 16-bit values.
500 .................... compass.x = make16(x_msb, x_lsb);
501 01C0: BCF 03.5
502 01C1: MOVF 2D,W
503 01C2: MOVWF 22
504 01C3: MOVF 2C,W
505 01C4: MOVWF 21
506 .................... compass.y = make16(y_msb, y_lsb);
507 01C5: MOVF 2F,W
508 01C6: MOVWF 24
509 01C7: MOVF 2E,W
510 01C8: MOVWF 23
511 .................... compass.z = make16(z_msb, z_lsb);
512 01C9: MOVF 31,W
513 01CA: MOVWF 26
514 01CB: MOVF 30,W
515 01CC: MOVWF 25
2926 jacho 516 .................... }
2985 kaklik 517 01CD: BCF 0A.3
518 01CE: BCF 0A.4
519 01CF: GOTO 2EE (RETURN)
2926 jacho 520 ....................
521 ....................
522 ....................
523 ....................
524 ....................
525 .................... void main()
526 .................... {
527 *
2985 kaklik 528 0250: CLRF 04
529 0251: BCF 03.7
530 0252: MOVLW 1F
531 0253: ANDWF 03,F
532 0254: MOVLW 71
533 0255: BSF 03.5
534 0256: MOVWF 0F
535 0257: MOVF 0F,W
536 0258: BCF 03.5
537 0259: BCF 20.7
538 025A: MOVF 20,W
539 025B: BSF 03.5
540 025C: MOVWF 07
541 025D: BCF 03.5
542 025E: BSF 07.7
543 025F: BSF 03.5
544 0260: BSF 03.6
545 0261: MOVF 09,W
546 0262: ANDLW C0
547 0263: MOVWF 09
548 0264: BCF 03.6
549 0265: BCF 1F.4
550 0266: BCF 1F.5
551 0267: MOVLW 00
552 0268: BSF 03.6
553 0269: MOVWF 08
554 026A: BCF 03.5
555 026B: CLRF 07
556 026C: CLRF 08
557 026D: CLRF 09
558 *
559 0277: CLRF 29
560 0278: CLRF 28
561 .................... int1 last;
562 .................... unsigned int16 anemo_round=0;
563 .................... unsigned int16 i;
564 ....................
565 ....................
566 .................... //signed int16 X,Y,Z;
2984 kaklik 567 .................... setup_adc_ports(NO_ANALOGS|VSS_VDD);
2985 kaklik 568 0279: BSF 03.5
569 027A: BSF 03.6
570 027B: MOVF 09,W
571 027C: ANDLW C0
572 027D: MOVWF 09
573 027E: BCF 03.6
574 027F: BCF 1F.4
575 0280: BCF 1F.5
576 0281: MOVLW 00
577 0282: BSF 03.6
578 0283: MOVWF 08
2984 kaklik 579 .................... setup_adc(ADC_CLOCK_DIV_2);
2985 kaklik 580 0284: BCF 03.5
581 0285: BCF 03.6
582 0286: BCF 1F.6
583 0287: BCF 1F.7
584 0288: BSF 03.5
585 0289: BCF 1F.7
586 028A: BCF 03.5
587 028B: BSF 1F.0
2984 kaklik 588 .................... setup_spi(SPI_SS_DISABLED);
2985 kaklik 589 028C: BCF 14.5
590 028D: BCF 20.5
591 028E: MOVF 20,W
592 028F: BSF 03.5
593 0290: MOVWF 07
594 0291: BCF 03.5
595 0292: BSF 20.4
596 0293: MOVF 20,W
597 0294: BSF 03.5
598 0295: MOVWF 07
599 0296: BCF 03.5
600 0297: BCF 20.3
601 0298: MOVF 20,W
602 0299: BSF 03.5
603 029A: MOVWF 07
604 029B: MOVLW 01
605 029C: BCF 03.5
606 029D: MOVWF 14
607 029E: MOVLW 00
608 029F: BSF 03.5
609 02A0: MOVWF 14
2984 kaklik 610 .................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
2985 kaklik 611 02A1: MOVF 01,W
612 02A2: ANDLW C7
613 02A3: IORLW 08
614 02A4: MOVWF 01
2984 kaklik 615 .................... setup_timer_1(T1_DISABLED);
2985 kaklik 616 02A5: BCF 03.5
617 02A6: CLRF 10
2984 kaklik 618 .................... setup_timer_2(T2_DISABLED,0,1);
2985 kaklik 619 02A7: MOVLW 00
620 02A8: MOVWF 78
621 02A9: MOVWF 12
622 02AA: MOVLW 00
623 02AB: BSF 03.5
624 02AC: MOVWF 12
2984 kaklik 625 .................... setup_ccp1(CCP_OFF);
2985 kaklik 626 02AD: BCF 03.5
627 02AE: BSF 20.2
628 02AF: MOVF 20,W
629 02B0: BSF 03.5
630 02B1: MOVWF 07
631 02B2: BCF 03.5
632 02B3: CLRF 17
633 02B4: BSF 03.5
634 02B5: CLRF 1B
635 02B6: CLRF 1C
636 02B7: MOVLW 01
637 02B8: MOVWF 1D
2984 kaklik 638 .................... setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
2985 kaklik 639 02B9: BCF 03.5
640 02BA: BSF 03.6
641 02BB: CLRF 07
642 02BC: CLRF 08
643 02BD: CLRF 09
2926 jacho 644 ....................
2985 kaklik 645 .................... // Init the HMC5883L. Set Mode register for
646 .................... // continuous measurements.
647 .................... hmc5883l_write_reg(HMC5883L_CFG_A_REG, 0x18); // no average, maximal update range
648 02BE: BCF 03.6
649 02BF: CLRF 2C
650 02C0: MOVLW 18
651 02C1: MOVWF 2D
652 02C2: CALL 069
653 .................... hmc5883l_write_reg(HMC5883L_CFG_B_REG, 0xE0); // maximal range
654 02C3: MOVLW 01
655 02C4: MOVWF 2C
656 02C5: MOVLW E0
657 02C6: MOVWF 2D
658 02C7: CALL 069
659 .................... hmc5883l_write_reg(HMC5883L_MODE_REG, 0x00);
660 02C8: MOVLW 02
661 02C9: MOVWF 2C
662 02CA: CLRF 2D
663 02CB: CALL 069
2926 jacho 664 ....................
2985 kaklik 665 .................... // Continuously read and display the x,y,z results.
666 .................... // Wait at least 67 ms between reads, re the HMC5883L data sheet.
667 ....................
668 ....................
2984 kaklik 669 .................... printf("Magnetometr: \r\n",);
2985 kaklik 670 02CC: MOVLW 04
671 02CD: BSF 03.6
672 02CE: MOVWF 0D
673 02CF: MOVLW 00
674 02D0: MOVWF 0F
675 02D1: BCF 03.6
676 02D2: CALL 0C6
2984 kaklik 677 .................... printf("(c)mlab JACHO 2013: \r\n",);
2985 kaklik 678 02D3: MOVLW 0D
679 02D4: BSF 03.6
680 02D5: MOVWF 0D
681 02D6: MOVLW 00
682 02D7: MOVWF 0F
683 02D8: BCF 03.6
684 02D9: CALL 0C6
2984 kaklik 685 .................... printf("X, Y, Z \r\n",);
2985 kaklik 686 02DA: MOVLW 19
687 02DB: BSF 03.6
688 02DC: MOVWF 0D
689 02DD: MOVLW 00
690 02DE: MOVWF 0F
691 02DF: BCF 03.6
692 02E0: CALL 0C6
2926 jacho 693 ....................
2985 kaklik 694 .................... /* while(true)
2984 kaklik 695 .................... {
696 .................... X = mag_readX();
697 .................... Y = mag_readY();
698 .................... Z = mag_readZ();
699 .................... printf("%4Ld %4Ld %4Ld \r\n", X, Y, Z);
700 .................... Delay_ms(50);
2926 jacho 701 ....................
2984 kaklik 702 .................... }
2985 kaklik 703 .................... */
704 ....................
705 .................... while(TRUE)
706 .................... {
707 ....................
708 .................... for( i=0;i<=1000;i++)
709 02E1: CLRF 2B
710 02E2: CLRF 2A
711 02E3: MOVF 2B,W
712 02E4: SUBLW 03
713 02E5: BTFSS 03.0
714 02E6: GOTO 303
715 02E7: BTFSS 03.2
716 02E8: GOTO 2ED
717 02E9: MOVF 2A,W
718 02EA: SUBLW E8
719 02EB: BTFSS 03.0
720 02EC: GOTO 303
721 .................... {
722 .................... // delay_ms();
723 .................... hmc5883l_read_data();
724 02ED: GOTO 151
725 ....................
726 .................... if(compass.x < 0)
727 02EE: BTFSS 22.7
728 02EF: GOTO 2F6
729 .................... {
730 .................... if(last == 1) anemo_round++;
731 02F0: BTFSS 27.0
732 02F1: GOTO 2F5
733 02F2: INCF 28,F
734 02F3: BTFSC 03.2
735 02F4: INCF 29,F
736 .................... last=0;
737 02F5: BCF 27.0
738 .................... }
739 .................... if(compass.x > 0) last=1;
740 02F6: BTFSC 22.7
741 02F7: GOTO 2FF
742 02F8: MOVF 22,F
743 02F9: BTFSS 03.2
744 02FA: GOTO 2FE
745 02FB: MOVF 21,W
746 02FC: SUBLW 00
747 02FD: BTFSS 03.0
748 02FE: BSF 27.0
749 .................... }
750 02FF: INCF 2A,F
751 0300: BTFSC 03.2
752 0301: INCF 2B,F
753 0302: GOTO 2E3
754 ....................
755 .................... printf("%6Ld %6Ld %6Ld %6Ld \n\r", compass.x, compass.y, compass.z, anemo_round);
756 0303: MOVLW 00
757 0304: MOVWF 04
758 0305: MOVF 22,W
759 0306: MOVWF 2D
760 0307: MOVF 21,W
761 0308: MOVWF 2C
762 0309: CALL 1D0
763 030A: MOVLW 20
764 030B: MOVWF 35
765 030C: CALL 0A2
766 030D: MOVLW 00
767 030E: MOVWF 04
768 030F: MOVF 24,W
769 0310: MOVWF 2D
770 0311: MOVF 23,W
771 0312: MOVWF 2C
772 0313: CALL 1D0
773 0314: MOVLW 20
774 0315: MOVWF 35
775 0316: CALL 0A2
776 0317: MOVLW 00
777 0318: MOVWF 04
778 0319: MOVF 26,W
779 031A: MOVWF 2D
780 031B: MOVF 25,W
781 031C: MOVWF 2C
782 031D: CALL 1D0
783 031E: MOVLW 20
784 031F: MOVWF 35
785 0320: CALL 0A2
786 0321: MOVLW 00
787 0322: MOVWF 04
788 0323: MOVF 29,W
789 0324: MOVWF 2D
790 0325: MOVF 28,W
791 0326: MOVWF 2C
792 0327: CALL 1D0
793 0328: MOVLW 20
794 0329: MOVWF 35
795 032A: CALL 0A2
796 032B: MOVLW 0A
797 032C: MOVWF 35
798 032D: CALL 0A2
799 032E: MOVLW 0D
800 032F: MOVWF 35
801 0330: CALL 0A2
802 .................... anemo_round=0;
803 0331: CLRF 29
804 0332: CLRF 28
805 .................... }
806 0333: GOTO 2E1
807 ....................
2926 jacho 808 .................... }
2985 kaklik 809 ....................
810 ....................
811 ....................
812 0334: SLEEP
2926 jacho 813  
814 Configuration Fuses:
815 Word 1: 2CF5 INTRC NOWDT NOPUT MCLR NOPROTECT NOCPD NOBROWNOUT IESO FCMEN NOLVP NODEBUG
816 Word 2: 3FFF NOWRT BORV40