2926 |
jacho |
1 |
CCS PCM C Compiler, Version 4.106, 47914 16-4-13 18:24 |
|
|
2 |
|
|
|
3 |
Filename: c:\users\honza\documents\pic\i2c_magnetometr\main.lst |
|
|
4 |
|
|
|
5 |
ROM used: 788 words (10%) |
|
|
6 |
Largest free fragment is 2048 |
|
|
7 |
RAM used: 7 (2%) at main() level |
|
|
8 |
22 (6%) worst case |
|
|
9 |
Stack: 3 locations |
|
|
10 |
|
|
|
11 |
* |
|
|
12 |
0000: MOVLW 02 |
|
|
13 |
0001: MOVWF 0A |
|
|
14 |
0002: GOTO 237 |
|
|
15 |
0003: NOP |
|
|
16 |
.................... //Magnetometr Jan Chroust 2013 |
|
|
17 |
.................... //vypise hodnoty jednotlivych os |
|
|
18 |
.................... |
|
|
19 |
.................... #include "main.h" |
|
|
20 |
.................... #include <16F887.h> |
|
|
21 |
.................... //////// Standard Header file for the PIC16F887 device //////////////// |
|
|
22 |
.................... #device PIC16F887 |
|
|
23 |
.................... #list |
|
|
24 |
.................... |
|
|
25 |
.................... #device adc=8 |
|
|
26 |
.................... |
|
|
27 |
.................... #FUSES NOWDT //No Watch Dog Timer |
|
|
28 |
.................... #FUSES INTRC //Internal RC Osc |
|
|
29 |
.................... #FUSES NOPUT //No Power Up Timer |
|
|
30 |
.................... #FUSES MCLR //Master Clear pin enabled |
|
|
31 |
.................... #FUSES NOPROTECT //Code not protected from reading |
|
|
32 |
.................... #FUSES NOCPD //No EE protection |
|
|
33 |
.................... #FUSES NOBROWNOUT //No brownout reset |
|
|
34 |
.................... #FUSES IESO //Internal External Switch Over mode enabled |
|
|
35 |
.................... #FUSES FCMEN //Fail-safe clock monitor enabled |
|
|
36 |
.................... #FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O |
|
|
37 |
.................... #FUSES NODEBUG //No Debug mode for ICD |
|
|
38 |
.................... #FUSES NOWRT //Program memory not write protected |
|
|
39 |
.................... #FUSES BORV40 //Brownout reset at 4.0V |
|
|
40 |
.................... |
|
|
41 |
.................... #use delay(clock=8000000) |
|
|
42 |
* |
|
|
43 |
0221: MOVLW 28 |
|
|
44 |
0222: MOVWF 04 |
|
|
45 |
0223: BCF 03.7 |
|
|
46 |
0224: MOVF 00,W |
|
|
47 |
0225: BTFSC 03.2 |
|
|
48 |
0226: GOTO 234 |
|
|
49 |
0227: MOVLW 02 |
|
|
50 |
0228: MOVWF 78 |
|
|
51 |
0229: CLRF 77 |
|
|
52 |
022A: DECFSZ 77,F |
|
|
53 |
022B: GOTO 22A |
|
|
54 |
022C: DECFSZ 78,F |
|
|
55 |
022D: GOTO 229 |
|
|
56 |
022E: MOVLW 97 |
|
|
57 |
022F: MOVWF 77 |
|
|
58 |
0230: DECFSZ 77,F |
|
|
59 |
0231: GOTO 230 |
|
|
60 |
0232: DECFSZ 00,F |
|
|
61 |
0233: GOTO 227 |
|
|
62 |
0234: BCF 0A.3 |
|
|
63 |
0235: BCF 0A.4 |
|
|
64 |
0236: GOTO 310 (RETURN) |
|
|
65 |
.................... |
|
|
66 |
.................... |
|
|
67 |
.................... |
|
|
68 |
.................... #define EEPROM_SDA PIN_B0 |
|
|
69 |
.................... #define EEPROM_SCL PIN_B1 |
|
|
70 |
.................... #use i2c(master, sda=EEPROM_SDA, scl=EEPROM_SCL) |
|
|
71 |
* |
|
|
72 |
009F: MOVLW 08 |
|
|
73 |
00A0: MOVWF 78 |
|
|
74 |
00A1: NOP |
|
|
75 |
00A2: BCF 06.1 |
|
|
76 |
00A3: BSF 03.5 |
|
|
77 |
00A4: BCF 06.1 |
|
|
78 |
00A5: NOP |
|
|
79 |
00A6: BCF 03.5 |
|
|
80 |
00A7: RLF 2C,F |
|
|
81 |
00A8: BCF 06.0 |
|
|
82 |
00A9: BTFSS 03.0 |
|
|
83 |
00AA: GOTO 0AE |
|
|
84 |
00AB: BSF 03.5 |
|
|
85 |
00AC: BSF 06.0 |
|
|
86 |
00AD: BCF 03.5 |
|
|
87 |
00AE: BTFSC 03.0 |
|
|
88 |
00AF: GOTO 0B3 |
|
|
89 |
00B0: BSF 03.5 |
|
|
90 |
00B1: BCF 06.0 |
|
|
91 |
00B2: BCF 03.5 |
|
|
92 |
00B3: BSF 03.5 |
|
|
93 |
00B4: BSF 06.1 |
|
|
94 |
00B5: BCF 03.5 |
|
|
95 |
00B6: BTFSS 06.1 |
|
|
96 |
00B7: GOTO 0B6 |
|
|
97 |
00B8: DECFSZ 78,F |
|
|
98 |
00B9: GOTO 0A1 |
|
|
99 |
00BA: NOP |
|
|
100 |
00BB: BCF 06.1 |
|
|
101 |
00BC: BSF 03.5 |
|
|
102 |
00BD: BCF 06.1 |
|
|
103 |
00BE: NOP |
|
|
104 |
00BF: BSF 06.0 |
|
|
105 |
00C0: NOP |
|
|
106 |
00C1: NOP |
|
|
107 |
00C2: BSF 06.1 |
|
|
108 |
00C3: BCF 03.5 |
|
|
109 |
00C4: BTFSS 06.1 |
|
|
110 |
00C5: GOTO 0C4 |
|
|
111 |
00C6: CLRF 78 |
|
|
112 |
00C7: NOP |
|
|
113 |
00C8: BTFSC 06.0 |
|
|
114 |
00C9: BSF 78.0 |
|
|
115 |
00CA: BCF 06.1 |
|
|
116 |
00CB: BSF 03.5 |
|
|
117 |
00CC: BCF 06.1 |
|
|
118 |
00CD: BCF 03.5 |
|
|
119 |
00CE: BCF 06.0 |
|
|
120 |
00CF: BSF 03.5 |
|
|
121 |
00D0: BCF 06.0 |
|
|
122 |
00D1: BCF 03.5 |
|
|
123 |
00D2: RETURN |
|
|
124 |
* |
|
|
125 |
0107: MOVLW 08 |
|
|
126 |
0108: MOVWF 2D |
|
|
127 |
0109: MOVF 77,W |
|
|
128 |
010A: MOVWF 2E |
|
|
129 |
010B: BSF 03.5 |
|
|
130 |
010C: BSF 06.0 |
|
|
131 |
010D: NOP |
|
|
132 |
010E: BSF 06.1 |
|
|
133 |
010F: BCF 03.5 |
|
|
134 |
0110: BTFSS 06.1 |
|
|
135 |
0111: GOTO 110 |
|
|
136 |
0112: BTFSC 06.0 |
|
|
137 |
0113: BSF 03.0 |
|
|
138 |
0114: BTFSS 06.0 |
|
|
139 |
0115: BCF 03.0 |
|
|
140 |
0116: RLF 78,F |
|
|
141 |
0117: NOP |
|
|
142 |
0118: BSF 03.5 |
|
|
143 |
0119: BCF 06.1 |
|
|
144 |
011A: BCF 03.5 |
|
|
145 |
011B: BCF 06.1 |
|
|
146 |
011C: DECFSZ 2D,F |
|
|
147 |
011D: GOTO 10B |
|
|
148 |
011E: BSF 03.5 |
|
|
149 |
011F: BSF 06.0 |
|
|
150 |
0120: NOP |
|
|
151 |
0121: BCF 03.5 |
|
|
152 |
0122: BCF 06.0 |
|
|
153 |
0123: MOVF 2E,W |
|
|
154 |
0124: BTFSC 03.2 |
|
|
155 |
0125: GOTO 129 |
|
|
156 |
0126: BSF 03.5 |
|
|
157 |
0127: BCF 06.0 |
|
|
158 |
0128: BCF 03.5 |
|
|
159 |
0129: NOP |
|
|
160 |
012A: BSF 03.5 |
|
|
161 |
012B: BSF 06.1 |
|
|
162 |
012C: BCF 03.5 |
|
|
163 |
012D: BTFSS 06.1 |
|
|
164 |
012E: GOTO 12D |
|
|
165 |
012F: NOP |
|
|
166 |
0130: BCF 06.1 |
|
|
167 |
0131: BSF 03.5 |
|
|
168 |
0132: BCF 06.1 |
|
|
169 |
0133: NOP |
|
|
170 |
0134: BCF 03.5 |
|
|
171 |
0135: BCF 06.0 |
|
|
172 |
0136: BSF 03.5 |
|
|
173 |
0137: BCF 06.0 |
|
|
174 |
.................... #use rs232(baud=9600,parity=N,xmit=PIN_B3,rcv=PIN_B2,bits=8) //rcv TXD xmit RXD |
|
|
175 |
* |
|
|
176 |
0037: BSF 03.5 |
|
|
177 |
0038: BCF 06.3 |
|
|
178 |
0039: BCF 03.5 |
|
|
179 |
003A: BCF 06.3 |
|
|
180 |
003B: MOVLW 08 |
|
|
181 |
003C: MOVWF 78 |
|
|
182 |
003D: GOTO 03E |
|
|
183 |
003E: NOP |
|
|
184 |
003F: BSF 78.7 |
|
|
185 |
0040: GOTO 04F |
|
|
186 |
0041: BCF 78.7 |
|
|
187 |
0042: RRF 30,F |
|
|
188 |
0043: BTFSC 03.0 |
|
|
189 |
0044: BSF 06.3 |
|
|
190 |
0045: BTFSS 03.0 |
|
|
191 |
0046: BCF 06.3 |
|
|
192 |
0047: BSF 78.6 |
|
|
193 |
0048: GOTO 04F |
|
|
194 |
0049: BCF 78.6 |
|
|
195 |
004A: DECFSZ 78,F |
|
|
196 |
004B: GOTO 042 |
|
|
197 |
004C: GOTO 04D |
|
|
198 |
004D: NOP |
|
|
199 |
004E: BSF 06.3 |
|
|
200 |
004F: MOVLW 3F |
|
|
201 |
0050: MOVWF 04 |
|
|
202 |
0051: DECFSZ 04,F |
|
|
203 |
0052: GOTO 051 |
|
|
204 |
0053: NOP |
|
|
205 |
0054: BTFSC 78.7 |
|
|
206 |
0055: GOTO 041 |
|
|
207 |
0056: BTFSC 78.6 |
|
|
208 |
0057: GOTO 049 |
|
|
209 |
0058: RETURN |
|
|
210 |
.................... |
|
|
211 |
.................... #include "HMC5883L.h" |
|
|
212 |
.................... #define MAG_ADDR_R 0x3D //addresa pro cteni |
|
|
213 |
.................... #define MAG_ADDR_W 0x3C |
|
|
214 |
.................... |
|
|
215 |
.................... |
|
|
216 |
.................... //Konstanty nastavujici rozsah |
|
|
217 |
.................... //pro void set_mag_roz (unsigned int8 h) |
|
|
218 |
.................... #define MAG_ROZ088 0x00 |
|
|
219 |
.................... #define MAG_ROZ130 0x20 |
|
|
220 |
.................... #define MAG_ROZ190 0x40 |
|
|
221 |
.................... #define MAG_ROZ250 0x60 |
|
|
222 |
.................... #define MAG_ROZ400 0x80 |
|
|
223 |
.................... #define MAG_ROZ470 0xA0 |
|
|
224 |
.................... #define MAG_ROZ560 0xC0 |
|
|
225 |
.................... #define MAG_ROZ810 0xE0 |
|
|
226 |
.................... |
|
|
227 |
.................... |
|
|
228 |
.................... #include "HMC5883L.c" |
|
|
229 |
.................... void set_mag (void) //uvodni nastaveni na kontinualni mereni, rozsah ± 8.1 Ga, frekvence mereni 15HZ |
|
|
230 |
.................... { |
|
|
231 |
.................... i2c_start(); //nastavení Configuration Register A |
|
|
232 |
.................... I2C_Write(MAG_ADDR_W); |
|
|
233 |
.................... I2C_Write(0x00); |
|
|
234 |
.................... I2C_Write(0x70); |
|
|
235 |
.................... i2c_stop(); |
|
|
236 |
.................... Delay_ms(6); |
|
|
237 |
.................... |
|
|
238 |
.................... i2c_start(); //nastavení Configuration Register B |
|
|
239 |
.................... I2C_Write(MAG_ADDR_W); |
|
|
240 |
.................... I2C_Write(0x01); |
|
|
241 |
.................... I2C_Write(MAG_ROZ810); |
|
|
242 |
.................... i2c_stop(); |
|
|
243 |
.................... |
|
|
244 |
.................... Delay_ms(6); |
|
|
245 |
.................... |
|
|
246 |
.................... i2c_start(); //nastveni Mode Register |
|
|
247 |
.................... I2C_Write(MAG_ADDR_W); |
|
|
248 |
.................... I2C_Write(0x02); |
|
|
249 |
.................... I2C_Write(0x00); |
|
|
250 |
.................... i2c_stop(); |
|
|
251 |
.................... Delay_ms(6); |
|
|
252 |
.................... } |
|
|
253 |
.................... |
|
|
254 |
.................... void set_mag_roz (unsigned int8 h) //nastavy rozsah |
|
|
255 |
.................... { |
|
|
256 |
.................... |
|
|
257 |
.................... // |
|
|
258 |
.................... |
|
|
259 |
.................... |
|
|
260 |
.................... i2c_start(); |
|
|
261 |
.................... I2C_Write(MAG_ADDR_W); |
|
|
262 |
.................... I2C_Write(0x01); |
|
|
263 |
.................... I2C_Write(h); |
|
|
264 |
.................... i2c_stop(); |
|
|
265 |
.................... |
|
|
266 |
.................... Delay_ms(6); |
|
|
267 |
.................... |
|
|
268 |
.................... |
|
|
269 |
.................... } |
|
|
270 |
.................... |
|
|
271 |
.................... |
|
|
272 |
.................... byte mag_read(byte reg) //pro cteni reg |
|
|
273 |
.................... { |
|
|
274 |
.................... |
|
|
275 |
.................... i2c_start(); |
|
|
276 |
* |
|
|
277 |
00D3: BSF 03.5 |
|
|
278 |
00D4: BSF 06.0 |
|
|
279 |
00D5: NOP |
|
|
280 |
00D6: BSF 06.1 |
|
|
281 |
00D7: NOP |
|
|
282 |
00D8: BCF 03.5 |
|
|
283 |
00D9: BCF 06.0 |
|
|
284 |
00DA: BSF 03.5 |
|
|
285 |
00DB: BCF 06.0 |
|
|
286 |
00DC: NOP |
|
|
287 |
00DD: BCF 03.5 |
|
|
288 |
00DE: BCF 06.1 |
|
|
289 |
00DF: BSF 03.5 |
|
|
290 |
00E0: BCF 06.1 |
|
|
291 |
.................... I2C_Write(MAG_ADDR_W); |
|
|
292 |
00E1: MOVLW 3C |
|
|
293 |
00E2: BCF 03.5 |
|
|
294 |
00E3: MOVWF 2C |
|
|
295 |
00E4: CALL 09F |
|
|
296 |
.................... I2C_write(reg); |
|
|
297 |
00E5: MOVF 2B,W |
|
|
298 |
00E6: MOVWF 2C |
|
|
299 |
00E7: CALL 09F |
|
|
300 |
.................... i2c_stop(); |
|
|
301 |
00E8: BSF 03.5 |
|
|
302 |
00E9: BCF 06.0 |
|
|
303 |
00EA: NOP |
|
|
304 |
00EB: BSF 06.1 |
|
|
305 |
00EC: BCF 03.5 |
|
|
306 |
00ED: BTFSS 06.1 |
|
|
307 |
00EE: GOTO 0ED |
|
|
308 |
00EF: NOP |
|
|
309 |
00F0: GOTO 0F1 |
|
|
310 |
00F1: NOP |
|
|
311 |
00F2: BSF 03.5 |
|
|
312 |
00F3: BSF 06.0 |
|
|
313 |
00F4: NOP |
|
|
314 |
.................... i2c_start(); |
|
|
315 |
00F5: BSF 06.0 |
|
|
316 |
00F6: NOP |
|
|
317 |
00F7: BSF 06.1 |
|
|
318 |
00F8: NOP |
|
|
319 |
00F9: BCF 03.5 |
|
|
320 |
00FA: BCF 06.0 |
|
|
321 |
00FB: BSF 03.5 |
|
|
322 |
00FC: BCF 06.0 |
|
|
323 |
00FD: NOP |
|
|
324 |
00FE: BCF 03.5 |
|
|
325 |
00FF: BCF 06.1 |
|
|
326 |
0100: BSF 03.5 |
|
|
327 |
0101: BCF 06.1 |
|
|
328 |
.................... I2C_Write(MAG_ADDR_R); |
|
|
329 |
0102: MOVLW 3D |
|
|
330 |
0103: BCF 03.5 |
|
|
331 |
0104: MOVWF 2C |
|
|
332 |
0105: CALL 09F |
|
|
333 |
.................... reg=i2c_read(0); |
|
|
334 |
0106: CLRF 77 |
|
|
335 |
* |
|
|
336 |
0138: MOVF 78,W |
|
|
337 |
0139: BCF 03.5 |
|
|
338 |
013A: MOVWF 2B |
|
|
339 |
.................... return reg; |
|
|
340 |
013B: MOVF 2B,W |
|
|
341 |
013C: MOVWF 78 |
|
|
342 |
.................... } |
|
|
343 |
013D: RETURN |
|
|
344 |
.................... |
|
|
345 |
.................... |
|
|
346 |
.................... signed int16 mag_vypocet(unsigned int8 h, unsigned int8 l) //prepocet na 16bit cislo |
|
|
347 |
.................... { |
|
|
348 |
.................... signed int16 x; |
|
|
349 |
.................... x = (((unsigned int16) h << 8) + l ); |
|
|
350 |
013E: CLRF 30 |
|
|
351 |
013F: MOVF 2B,W |
|
|
352 |
0140: MOVWF 2F |
|
|
353 |
0141: MOVWF 30 |
|
|
354 |
0142: CLRF 2F |
|
|
355 |
0143: MOVF 2C,W |
|
|
356 |
0144: ADDWF 2F,W |
|
|
357 |
0145: MOVWF 78 |
|
|
358 |
0146: MOVF 30,W |
|
|
359 |
0147: MOVWF 7A |
|
|
360 |
0148: BTFSC 03.0 |
|
|
361 |
0149: INCF 7A,F |
|
|
362 |
014A: MOVF 78,W |
|
|
363 |
014B: MOVWF 2D |
|
|
364 |
014C: MOVF 7A,W |
|
|
365 |
014D: MOVWF 2E |
|
|
366 |
.................... return x; |
|
|
367 |
014E: MOVF 2D,W |
|
|
368 |
014F: MOVWF 78 |
|
|
369 |
0150: MOVF 2E,W |
|
|
370 |
0151: MOVWF 79 |
|
|
371 |
.................... } |
|
|
372 |
0152: RETURN |
|
|
373 |
.................... |
|
|
374 |
.................... |
|
|
375 |
.................... signed int16 mag_readX(void) //nacteni osy x |
|
|
376 |
.................... { |
|
|
377 |
.................... unsigned int8 h,l; |
|
|
378 |
.................... signed int16 x; |
|
|
379 |
.................... h=mag_read(0x03); |
|
|
380 |
0153: MOVLW 03 |
|
|
381 |
0154: MOVWF 2B |
|
|
382 |
0155: CALL 0D3 |
|
|
383 |
0156: MOVF 78,W |
|
|
384 |
0157: MOVWF 27 |
|
|
385 |
.................... l=mag_read(0x04); |
|
|
386 |
0158: MOVLW 04 |
|
|
387 |
0159: MOVWF 2B |
|
|
388 |
015A: CALL 0D3 |
|
|
389 |
015B: MOVF 78,W |
|
|
390 |
015C: MOVWF 28 |
|
|
391 |
.................... x=mag_vypocet(h,l); |
|
|
392 |
015D: MOVF 27,W |
|
|
393 |
015E: MOVWF 2B |
|
|
394 |
015F: MOVF 28,W |
|
|
395 |
0160: MOVWF 2C |
|
|
396 |
0161: CALL 13E |
|
|
397 |
0162: MOVF 79,W |
|
|
398 |
0163: MOVWF 2A |
|
|
399 |
0164: MOVF 78,W |
|
|
400 |
0165: MOVWF 29 |
|
|
401 |
.................... return x; |
|
|
402 |
0166: MOVF 29,W |
|
|
403 |
0167: MOVWF 78 |
|
|
404 |
0168: MOVF 2A,W |
|
|
405 |
0169: MOVWF 79 |
|
|
406 |
.................... |
|
|
407 |
.................... } |
|
|
408 |
016A: BCF 0A.3 |
|
|
409 |
016B: BCF 0A.4 |
|
|
410 |
016C: GOTO 2B5 (RETURN) |
|
|
411 |
.................... |
|
|
412 |
.................... |
|
|
413 |
.................... signed int16 mag_readY(void) //nacteni osy x |
|
|
414 |
.................... { |
|
|
415 |
.................... unsigned int8 h,l; |
|
|
416 |
.................... signed int16 x; |
|
|
417 |
.................... h=mag_read(0x07); |
|
|
418 |
016D: MOVLW 07 |
|
|
419 |
016E: MOVWF 2B |
|
|
420 |
016F: CALL 0D3 |
|
|
421 |
0170: MOVF 78,W |
|
|
422 |
0171: MOVWF 27 |
|
|
423 |
.................... l=mag_read(0x08); |
|
|
424 |
0172: MOVLW 08 |
|
|
425 |
0173: MOVWF 2B |
|
|
426 |
0174: CALL 0D3 |
|
|
427 |
0175: MOVF 78,W |
|
|
428 |
0176: MOVWF 28 |
|
|
429 |
.................... x=mag_vypocet(h,l); |
|
|
430 |
0177: MOVF 27,W |
|
|
431 |
0178: MOVWF 2B |
|
|
432 |
0179: MOVF 28,W |
|
|
433 |
017A: MOVWF 2C |
|
|
434 |
017B: CALL 13E |
|
|
435 |
017C: MOVF 79,W |
|
|
436 |
017D: MOVWF 2A |
|
|
437 |
017E: MOVF 78,W |
|
|
438 |
017F: MOVWF 29 |
|
|
439 |
.................... return x; |
|
|
440 |
0180: MOVF 29,W |
|
|
441 |
0181: MOVWF 78 |
|
|
442 |
0182: MOVF 2A,W |
|
|
443 |
0183: MOVWF 79 |
|
|
444 |
.................... |
|
|
445 |
.................... } |
|
|
446 |
0184: BCF 0A.3 |
|
|
447 |
0185: BCF 0A.4 |
|
|
448 |
0186: GOTO 2BA (RETURN) |
|
|
449 |
.................... |
|
|
450 |
.................... |
|
|
451 |
.................... signed int16 mag_readZ(void) //nacteni osy x |
|
|
452 |
.................... { |
|
|
453 |
.................... unsigned int8 h,l; |
|
|
454 |
.................... signed int16 x; |
|
|
455 |
.................... h=mag_read(0x05); |
|
|
456 |
0187: MOVLW 05 |
|
|
457 |
0188: MOVWF 2B |
|
|
458 |
0189: CALL 0D3 |
|
|
459 |
018A: MOVF 78,W |
|
|
460 |
018B: MOVWF 27 |
|
|
461 |
.................... l=mag_read(0x06); |
|
|
462 |
018C: MOVLW 06 |
|
|
463 |
018D: MOVWF 2B |
|
|
464 |
018E: CALL 0D3 |
|
|
465 |
018F: MOVF 78,W |
|
|
466 |
0190: MOVWF 28 |
|
|
467 |
.................... x=mag_vypocet(h,l); |
|
|
468 |
0191: MOVF 27,W |
|
|
469 |
0192: MOVWF 2B |
|
|
470 |
0193: MOVF 28,W |
|
|
471 |
0194: MOVWF 2C |
|
|
472 |
0195: CALL 13E |
|
|
473 |
0196: MOVF 79,W |
|
|
474 |
0197: MOVWF 2A |
|
|
475 |
0198: MOVF 78,W |
|
|
476 |
0199: MOVWF 29 |
|
|
477 |
.................... return x; |
|
|
478 |
019A: MOVF 29,W |
|
|
479 |
019B: MOVWF 78 |
|
|
480 |
019C: MOVF 2A,W |
|
|
481 |
019D: MOVWF 79 |
|
|
482 |
.................... |
|
|
483 |
.................... } |
|
|
484 |
019E: BCF 0A.3 |
|
|
485 |
019F: BCF 0A.4 |
|
|
486 |
01A0: GOTO 2BF (RETURN) |
|
|
487 |
.................... |
|
|
488 |
.................... |
|
|
489 |
.................... |
|
|
490 |
.................... |
|
|
491 |
.................... |
|
|
492 |
.................... void main() |
|
|
493 |
.................... { |
|
|
494 |
* |
|
|
495 |
0237: CLRF 04 |
|
|
496 |
0238: BCF 03.7 |
|
|
497 |
0239: MOVLW 1F |
|
|
498 |
023A: ANDWF 03,F |
|
|
499 |
023B: MOVLW 71 |
|
|
500 |
023C: BSF 03.5 |
|
|
501 |
023D: MOVWF 0F |
|
|
502 |
023E: MOVF 0F,W |
|
|
503 |
023F: BCF 06.3 |
|
|
504 |
0240: BCF 03.5 |
|
|
505 |
0241: BSF 06.3 |
|
|
506 |
0242: BSF 03.5 |
|
|
507 |
0243: BSF 03.6 |
|
|
508 |
0244: MOVF 09,W |
|
|
509 |
0245: ANDLW C0 |
|
|
510 |
0246: MOVWF 09 |
|
|
511 |
0247: BCF 03.6 |
|
|
512 |
0248: BCF 1F.4 |
|
|
513 |
0249: BCF 1F.5 |
|
|
514 |
024A: MOVLW 00 |
|
|
515 |
024B: BSF 03.6 |
|
|
516 |
024C: MOVWF 08 |
|
|
517 |
024D: BCF 03.5 |
|
|
518 |
024E: CLRF 07 |
|
|
519 |
024F: CLRF 08 |
|
|
520 |
0250: CLRF 09 |
|
|
521 |
.................... |
|
|
522 |
.................... setup_adc_ports(NO_ANALOGS|VSS_VDD); |
|
|
523 |
* |
|
|
524 |
0254: BSF 03.5 |
|
|
525 |
0255: BSF 03.6 |
|
|
526 |
0256: MOVF 09,W |
|
|
527 |
0257: ANDLW C0 |
|
|
528 |
0258: MOVWF 09 |
|
|
529 |
0259: BCF 03.6 |
|
|
530 |
025A: BCF 1F.4 |
|
|
531 |
025B: BCF 1F.5 |
|
|
532 |
025C: MOVLW 00 |
|
|
533 |
025D: BSF 03.6 |
|
|
534 |
025E: MOVWF 08 |
|
|
535 |
.................... setup_adc(ADC_CLOCK_DIV_2); |
|
|
536 |
025F: BCF 03.5 |
|
|
537 |
0260: BCF 03.6 |
|
|
538 |
0261: BCF 1F.6 |
|
|
539 |
0262: BCF 1F.7 |
|
|
540 |
0263: BSF 03.5 |
|
|
541 |
0264: BCF 1F.7 |
|
|
542 |
0265: BCF 03.5 |
|
|
543 |
0266: BSF 1F.0 |
|
|
544 |
.................... setup_spi(SPI_SS_DISABLED); |
|
|
545 |
0267: BCF 14.5 |
|
|
546 |
0268: BCF 20.5 |
|
|
547 |
0269: MOVF 20,W |
|
|
548 |
026A: BSF 03.5 |
|
|
549 |
026B: MOVWF 07 |
|
|
550 |
026C: BCF 03.5 |
|
|
551 |
026D: BSF 20.4 |
|
|
552 |
026E: MOVF 20,W |
|
|
553 |
026F: BSF 03.5 |
|
|
554 |
0270: MOVWF 07 |
|
|
555 |
0271: BCF 03.5 |
|
|
556 |
0272: BCF 20.3 |
|
|
557 |
0273: MOVF 20,W |
|
|
558 |
0274: BSF 03.5 |
|
|
559 |
0275: MOVWF 07 |
|
|
560 |
0276: MOVLW 01 |
|
|
561 |
0277: BCF 03.5 |
|
|
562 |
0278: MOVWF 14 |
|
|
563 |
0279: MOVLW 00 |
|
|
564 |
027A: BSF 03.5 |
|
|
565 |
027B: MOVWF 14 |
|
|
566 |
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); |
|
|
567 |
027C: MOVF 01,W |
|
|
568 |
027D: ANDLW C7 |
|
|
569 |
027E: IORLW 08 |
|
|
570 |
027F: MOVWF 01 |
|
|
571 |
.................... setup_timer_1(T1_DISABLED); |
|
|
572 |
0280: BCF 03.5 |
|
|
573 |
0281: CLRF 10 |
|
|
574 |
.................... setup_timer_2(T2_DISABLED,0,1); |
|
|
575 |
0282: MOVLW 00 |
|
|
576 |
0283: MOVWF 78 |
|
|
577 |
0284: MOVWF 12 |
|
|
578 |
0285: MOVLW 00 |
|
|
579 |
0286: BSF 03.5 |
|
|
580 |
0287: MOVWF 12 |
|
|
581 |
.................... setup_ccp1(CCP_OFF); |
|
|
582 |
0288: BCF 03.5 |
|
|
583 |
0289: BSF 20.2 |
|
|
584 |
028A: MOVF 20,W |
|
|
585 |
028B: BSF 03.5 |
|
|
586 |
028C: MOVWF 07 |
|
|
587 |
028D: BCF 03.5 |
|
|
588 |
028E: CLRF 17 |
|
|
589 |
028F: BSF 03.5 |
|
|
590 |
0290: CLRF 1B |
|
|
591 |
0291: CLRF 1C |
|
|
592 |
0292: MOVLW 01 |
|
|
593 |
0293: MOVWF 1D |
|
|
594 |
.................... setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard |
|
|
595 |
0294: BCF 03.5 |
|
|
596 |
0295: BSF 03.6 |
|
|
597 |
0296: CLRF 07 |
|
|
598 |
0297: CLRF 08 |
|
|
599 |
0298: CLRF 09 |
|
|
600 |
.................... |
|
|
601 |
.................... printf("Magnetometr: \r\n",); |
|
|
602 |
0299: MOVLW 04 |
|
|
603 |
029A: MOVWF 0D |
|
|
604 |
029B: MOVLW 00 |
|
|
605 |
029C: MOVWF 0F |
|
|
606 |
029D: BCF 03.6 |
|
|
607 |
029E: CALL 059 |
|
|
608 |
.................... printf("(c)mlab JACHO 2013: \r\n",); |
|
|
609 |
029F: MOVLW 0D |
|
|
610 |
02A0: BSF 03.6 |
|
|
611 |
02A1: MOVWF 0D |
|
|
612 |
02A2: MOVLW 00 |
|
|
613 |
02A3: MOVWF 0F |
|
|
614 |
02A4: BCF 03.6 |
|
|
615 |
02A5: CALL 059 |
|
|
616 |
.................... printf("Vysledky z jednotlivych os:\r\n",); |
|
|
617 |
02A6: MOVLW 19 |
|
|
618 |
02A7: BSF 03.6 |
|
|
619 |
02A8: MOVWF 0D |
|
|
620 |
02A9: MOVLW 00 |
|
|
621 |
02AA: MOVWF 0F |
|
|
622 |
02AB: BCF 03.6 |
|
|
623 |
02AC: CALL 059 |
|
|
624 |
.................... signed int16 X,Y,Z; |
|
|
625 |
.................... |
|
|
626 |
.................... |
|
|
627 |
.................... while(true) |
|
|
628 |
.................... { |
|
|
629 |
.................... printf("Vysledky z jednotlivych os:\r\n",); |
|
|
630 |
02AD: MOVLW 28 |
|
|
631 |
02AE: BSF 03.6 |
|
|
632 |
02AF: MOVWF 0D |
|
|
633 |
02B0: MOVLW 00 |
|
|
634 |
02B1: MOVWF 0F |
|
|
635 |
02B2: BCF 03.6 |
|
|
636 |
02B3: CALL 059 |
|
|
637 |
.................... X=mag_readX(); |
|
|
638 |
02B4: GOTO 153 |
|
|
639 |
02B5: MOVF 79,W |
|
|
640 |
02B6: MOVWF 22 |
|
|
641 |
02B7: MOVF 78,W |
|
|
642 |
02B8: MOVWF 21 |
|
|
643 |
.................... Y=mag_readY(); |
|
|
644 |
02B9: GOTO 16D |
|
|
645 |
02BA: MOVF 79,W |
|
|
646 |
02BB: MOVWF 24 |
|
|
647 |
02BC: MOVF 78,W |
|
|
648 |
02BD: MOVWF 23 |
|
|
649 |
.................... Z=mag_readZ(); |
|
|
650 |
02BE: GOTO 187 |
|
|
651 |
02BF: MOVF 79,W |
|
|
652 |
02C0: MOVWF 26 |
|
|
653 |
02C1: MOVF 78,W |
|
|
654 |
02C2: MOVWF 25 |
|
|
655 |
.................... printf("X: %Ld \r\n", X); |
|
|
656 |
02C3: MOVLW 58 |
|
|
657 |
02C4: MOVWF 30 |
|
|
658 |
02C5: CALL 037 |
|
|
659 |
02C6: MOVLW 3A |
|
|
660 |
02C7: MOVWF 30 |
|
|
661 |
02C8: CALL 037 |
|
|
662 |
02C9: MOVLW 20 |
|
|
663 |
02CA: MOVWF 30 |
|
|
664 |
02CB: CALL 037 |
|
|
665 |
02CC: MOVLW 10 |
|
|
666 |
02CD: MOVWF 04 |
|
|
667 |
02CE: MOVF 22,W |
|
|
668 |
02CF: MOVWF 28 |
|
|
669 |
02D0: MOVF 21,W |
|
|
670 |
02D1: MOVWF 27 |
|
|
671 |
02D2: CALL 1A1 |
|
|
672 |
02D3: MOVLW 20 |
|
|
673 |
02D4: MOVWF 30 |
|
|
674 |
02D5: CALL 037 |
|
|
675 |
02D6: MOVLW 0D |
|
|
676 |
02D7: MOVWF 30 |
|
|
677 |
02D8: CALL 037 |
|
|
678 |
02D9: MOVLW 0A |
|
|
679 |
02DA: MOVWF 30 |
|
|
680 |
02DB: CALL 037 |
|
|
681 |
.................... printf("Y %Ld \r\n", Y); |
|
|
682 |
02DC: MOVLW 59 |
|
|
683 |
02DD: MOVWF 30 |
|
|
684 |
02DE: CALL 037 |
|
|
685 |
02DF: MOVLW 20 |
|
|
686 |
02E0: MOVWF 30 |
|
|
687 |
02E1: CALL 037 |
|
|
688 |
02E2: MOVLW 10 |
|
|
689 |
02E3: MOVWF 04 |
|
|
690 |
02E4: MOVF 24,W |
|
|
691 |
02E5: MOVWF 28 |
|
|
692 |
02E6: MOVF 23,W |
|
|
693 |
02E7: MOVWF 27 |
|
|
694 |
02E8: CALL 1A1 |
|
|
695 |
02E9: MOVLW 20 |
|
|
696 |
02EA: MOVWF 30 |
|
|
697 |
02EB: CALL 037 |
|
|
698 |
02EC: MOVLW 0D |
|
|
699 |
02ED: MOVWF 30 |
|
|
700 |
02EE: CALL 037 |
|
|
701 |
02EF: MOVLW 0A |
|
|
702 |
02F0: MOVWF 30 |
|
|
703 |
02F1: CALL 037 |
|
|
704 |
.................... printf("Z: %Ld \r\n", Z); |
|
|
705 |
02F2: MOVLW 5A |
|
|
706 |
02F3: MOVWF 30 |
|
|
707 |
02F4: CALL 037 |
|
|
708 |
02F5: MOVLW 3A |
|
|
709 |
02F6: MOVWF 30 |
|
|
710 |
02F7: CALL 037 |
|
|
711 |
02F8: MOVLW 20 |
|
|
712 |
02F9: MOVWF 30 |
|
|
713 |
02FA: CALL 037 |
|
|
714 |
02FB: MOVLW 10 |
|
|
715 |
02FC: MOVWF 04 |
|
|
716 |
02FD: MOVF 26,W |
|
|
717 |
02FE: MOVWF 28 |
|
|
718 |
02FF: MOVF 25,W |
|
|
719 |
0300: MOVWF 27 |
|
|
720 |
0301: CALL 1A1 |
|
|
721 |
0302: MOVLW 20 |
|
|
722 |
0303: MOVWF 30 |
|
|
723 |
0304: CALL 037 |
|
|
724 |
0305: MOVLW 0D |
|
|
725 |
0306: MOVWF 30 |
|
|
726 |
0307: CALL 037 |
|
|
727 |
0308: MOVLW 0A |
|
|
728 |
0309: MOVWF 30 |
|
|
729 |
030A: CALL 037 |
|
|
730 |
.................... Delay_ms(2000); |
|
|
731 |
030B: MOVLW 08 |
|
|
732 |
030C: MOVWF 27 |
|
|
733 |
030D: MOVLW FA |
|
|
734 |
030E: MOVWF 28 |
|
|
735 |
030F: GOTO 221 |
|
|
736 |
0310: DECFSZ 27,F |
|
|
737 |
0311: GOTO 30D |
|
|
738 |
.................... |
|
|
739 |
.................... } |
|
|
740 |
0312: GOTO 2AD |
|
|
741 |
.................... } |
|
|
742 |
0313: SLEEP |
|
|
743 |
|
|
|
744 |
Configuration Fuses: |
|
|
745 |
Word 1: 2CF5 INTRC NOWDT NOPUT MCLR NOPROTECT NOCPD NOBROWNOUT IESO FCMEN NOLVP NODEBUG |
|
|
746 |
Word 2: 3FFF NOWRT BORV40 |