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