Line 1... |
Line 1... |
1 |
CCS PCM C Compiler, Version 4.106, 47914 15-V-13 20:34 |
1 |
CCS PCM C Compiler, Version 4.106, 47914 17-V-13 12:14 |
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: 775 words (9%) |
5 |
ROM used: 799 words (10%) |
6 |
Largest free fragment is 2048 |
6 |
Largest free fragment is 2048 |
7 |
RAM used: 28 (8%) at main() level |
7 |
RAM used: 28 (8%) at main() level |
8 |
38 (10%) worst case |
8 |
38 (10%) worst case |
9 |
Stack: 2 locations |
9 |
Stack: 2 locations |
10 |
|
10 |
|
11 |
* |
11 |
* |
12 |
0000: MOVLW 02 |
12 |
0000: MOVLW 02 |
13 |
0001: MOVWF 0A |
13 |
0001: MOVWF 0A |
14 |
0002: GOTO 24F |
14 |
0002: GOTO 266 |
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 |
Line 34... |
Line 34... |
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 |
.................... #use i2c(master, sda=PIN_C4, scl=PIN_C3) |
- |
|
40 |
* |
39 |
* |
- |
|
40 |
0250: MOVLW 37 |
- |
|
41 |
0251: MOVWF 04 |
- |
|
42 |
0252: BCF 03.7 |
- |
|
43 |
0253: MOVF 00,W |
- |
|
44 |
0254: BTFSC 03.2 |
- |
|
45 |
0255: GOTO 263 |
- |
|
46 |
0256: MOVLW 02 |
- |
|
47 |
0257: MOVWF 78 |
- |
|
48 |
0258: CLRF 77 |
- |
|
49 |
0259: DECFSZ 77,F |
- |
|
50 |
025A: GOTO 259 |
- |
|
51 |
025B: DECFSZ 78,F |
- |
|
52 |
025C: GOTO 258 |
- |
|
53 |
025D: MOVLW 97 |
- |
|
54 |
025E: MOVWF 77 |
- |
|
55 |
025F: DECFSZ 77,F |
- |
|
56 |
0260: GOTO 25F |
- |
|
57 |
0261: DECFSZ 00,F |
- |
|
58 |
0262: GOTO 256 |
- |
|
59 |
0263: BCF 0A.3 |
- |
|
60 |
0264: BCF 0A.4 |
- |
|
61 |
0265: GOTO 31D (RETURN) |
- |
|
62 |
.................... #use i2c(Master,Slow,sda=PIN_C4,scl=PIN_C3) |
- |
|
63 |
* |
41 |
001F: MOVLW 08 |
64 |
0089: MOVLW 08 |
42 |
0020: MOVWF 78 |
65 |
008A: MOVWF 78 |
43 |
0021: NOP |
66 |
008B: NOP |
44 |
0022: BCF 07.3 |
67 |
008C: BCF 07.3 |
45 |
0023: BCF 20.3 |
68 |
008D: BCF 20.3 |
46 |
0024: MOVF 20,W |
69 |
008E: MOVF 20,W |
47 |
0025: BSF 03.5 |
70 |
008F: BSF 03.5 |
48 |
0026: MOVWF 07 |
71 |
0090: MOVWF 07 |
49 |
0027: NOP |
72 |
0091: NOP |
50 |
0028: BCF 03.5 |
73 |
0092: BCF 03.5 |
51 |
0029: RLF 3D,F |
74 |
0093: RLF 3D,F |
52 |
002A: BCF 07.4 |
75 |
0094: BCF 07.4 |
53 |
002B: BTFSS 03.0 |
76 |
0095: BTFSS 03.0 |
54 |
002C: GOTO 033 |
77 |
0096: GOTO 09D |
55 |
002D: BSF 20.4 |
78 |
0097: BSF 20.4 |
56 |
002E: MOVF 20,W |
79 |
0098: MOVF 20,W |
57 |
002F: BSF 03.5 |
80 |
0099: BSF 03.5 |
58 |
0030: MOVWF 07 |
81 |
009A: MOVWF 07 |
59 |
0031: GOTO 037 |
82 |
009B: GOTO 0A1 |
60 |
0032: BCF 03.5 |
83 |
009C: BCF 03.5 |
61 |
0033: BCF 20.4 |
84 |
009D: BCF 20.4 |
62 |
0034: MOVF 20,W |
85 |
009E: MOVF 20,W |
63 |
0035: BSF 03.5 |
86 |
009F: BSF 03.5 |
64 |
0036: MOVWF 07 |
87 |
00A0: MOVWF 07 |
65 |
0037: NOP |
88 |
00A1: NOP |
66 |
0038: BCF 03.5 |
89 |
00A2: BCF 03.5 |
67 |
0039: BSF 20.3 |
90 |
00A3: BSF 20.3 |
68 |
003A: MOVF 20,W |
91 |
00A4: MOVF 20,W |
69 |
003B: BSF 03.5 |
92 |
00A5: BSF 03.5 |
70 |
003C: MOVWF 07 |
93 |
00A6: MOVWF 07 |
71 |
003D: BCF 03.5 |
94 |
00A7: BCF 03.5 |
72 |
003E: BTFSS 07.3 |
95 |
00A8: BTFSS 07.3 |
73 |
003F: GOTO 03E |
96 |
00A9: GOTO 0A8 |
74 |
0040: DECFSZ 78,F |
97 |
00AA: DECFSZ 78,F |
75 |
0041: GOTO 021 |
98 |
00AB: GOTO 08B |
76 |
0042: NOP |
99 |
00AC: NOP |
77 |
0043: BCF 07.3 |
100 |
00AD: BCF 07.3 |
78 |
0044: BCF 20.3 |
101 |
00AE: BCF 20.3 |
79 |
0045: MOVF 20,W |
102 |
00AF: MOVF 20,W |
80 |
0046: BSF 03.5 |
103 |
00B0: BSF 03.5 |
81 |
0047: MOVWF 07 |
104 |
00B1: MOVWF 07 |
82 |
0048: NOP |
105 |
00B2: NOP |
83 |
0049: BCF 03.5 |
106 |
00B3: BCF 03.5 |
84 |
004A: BSF 20.4 |
107 |
00B4: BSF 20.4 |
85 |
004B: MOVF 20,W |
108 |
00B5: MOVF 20,W |
86 |
004C: BSF 03.5 |
109 |
00B6: BSF 03.5 |
87 |
004D: MOVWF 07 |
110 |
00B7: MOVWF 07 |
88 |
004E: NOP |
111 |
00B8: NOP |
89 |
004F: NOP |
112 |
00B9: NOP |
90 |
0050: BCF 03.5 |
113 |
00BA: BCF 03.5 |
91 |
0051: BSF 20.3 |
114 |
00BB: BSF 20.3 |
92 |
0052: MOVF 20,W |
115 |
00BC: MOVF 20,W |
93 |
0053: BSF 03.5 |
116 |
00BD: BSF 03.5 |
94 |
0054: MOVWF 07 |
117 |
00BE: MOVWF 07 |
95 |
0055: BCF 03.5 |
118 |
00BF: BCF 03.5 |
96 |
0056: BTFSS 07.3 |
119 |
00C0: BTFSS 07.3 |
97 |
0057: GOTO 056 |
120 |
00C1: GOTO 0C0 |
98 |
0058: CLRF 78 |
121 |
00C2: CLRF 78 |
99 |
0059: NOP |
122 |
00C3: NOP |
100 |
005A: BTFSC 07.4 |
123 |
00C4: BTFSC 07.4 |
101 |
005B: BSF 78.0 |
124 |
00C5: BSF 78.0 |
102 |
005C: BCF 07.3 |
125 |
00C6: BCF 07.3 |
103 |
005D: BCF 20.3 |
126 |
00C7: BCF 20.3 |
104 |
005E: MOVF 20,W |
127 |
00C8: MOVF 20,W |
105 |
005F: BSF 03.5 |
128 |
00C9: BSF 03.5 |
106 |
0060: MOVWF 07 |
129 |
00CA: MOVWF 07 |
107 |
0061: BCF 03.5 |
130 |
00CB: BCF 03.5 |
108 |
0062: BCF 07.4 |
131 |
00CC: BCF 07.4 |
109 |
0063: BCF 20.4 |
132 |
00CD: BCF 20.4 |
110 |
0064: MOVF 20,W |
133 |
00CE: MOVF 20,W |
111 |
0065: BSF 03.5 |
134 |
00CF: BSF 03.5 |
112 |
0066: MOVWF 07 |
135 |
00D0: MOVWF 07 |
113 |
0067: BCF 03.5 |
136 |
00D1: BCF 03.5 |
114 |
0068: RETURN |
137 |
00D2: RETURN |
115 |
* |
138 |
* |
116 |
010B: MOVLW 08 |
139 |
010C: MOVLW 08 |
117 |
010C: MOVWF 3E |
140 |
010D: MOVWF 3E |
118 |
010D: MOVF 77,W |
141 |
010E: MOVF 77,W |
119 |
010E: MOVWF 3F |
142 |
010F: MOVWF 3F |
120 |
010F: BSF 20.4 |
143 |
0110: BSF 20.4 |
121 |
0110: MOVF 20,W |
144 |
0111: MOVF 20,W |
122 |
0111: BSF 03.5 |
145 |
0112: BSF 03.5 |
123 |
0112: MOVWF 07 |
146 |
0113: MOVWF 07 |
124 |
0113: NOP |
147 |
0114: NOP |
125 |
0114: BCF 03.5 |
148 |
0115: BCF 03.5 |
126 |
0115: BSF 20.3 |
149 |
0116: BSF 20.3 |
127 |
0116: MOVF 20,W |
150 |
0117: MOVF 20,W |
128 |
0117: BSF 03.5 |
151 |
0118: BSF 03.5 |
129 |
0118: MOVWF 07 |
152 |
0119: MOVWF 07 |
130 |
0119: BCF 03.5 |
153 |
011A: BCF 03.5 |
131 |
011A: BTFSS 07.3 |
154 |
011B: BTFSS 07.3 |
132 |
011B: GOTO 11A |
155 |
011C: GOTO 11B |
133 |
011C: BTFSC 07.4 |
156 |
011D: BTFSC 07.4 |
134 |
011D: BSF 03.0 |
157 |
011E: BSF 03.0 |
135 |
011E: BTFSS 07.4 |
158 |
011F: BTFSS 07.4 |
136 |
011F: BCF 03.0 |
159 |
0120: BCF 03.0 |
137 |
0120: RLF 78,F |
160 |
0121: RLF 78,F |
138 |
0121: NOP |
161 |
0122: NOP |
139 |
0122: BCF 20.3 |
162 |
0123: BCF 20.3 |
140 |
0123: MOVF 20,W |
163 |
0124: MOVF 20,W |
141 |
0124: BSF 03.5 |
164 |
0125: BSF 03.5 |
142 |
0125: MOVWF 07 |
165 |
0126: MOVWF 07 |
143 |
0126: BCF 03.5 |
166 |
0127: BCF 03.5 |
144 |
0127: BCF 07.3 |
167 |
0128: BCF 07.3 |
145 |
0128: DECFSZ 3E,F |
168 |
0129: DECFSZ 3E,F |
146 |
0129: GOTO 10F |
169 |
012A: GOTO 110 |
147 |
012A: BSF 20.4 |
170 |
012B: BSF 20.4 |
148 |
012B: MOVF 20,W |
171 |
012C: MOVF 20,W |
149 |
012C: BSF 03.5 |
172 |
012D: BSF 03.5 |
150 |
012D: MOVWF 07 |
173 |
012E: MOVWF 07 |
151 |
012E: NOP |
174 |
012F: NOP |
152 |
012F: BCF 03.5 |
175 |
0130: BCF 03.5 |
153 |
0130: BCF 07.4 |
176 |
0131: BCF 07.4 |
154 |
0131: MOVF 3F,W |
177 |
0132: MOVF 3F,W |
155 |
0132: BTFSC 03.2 |
178 |
0133: BTFSC 03.2 |
156 |
0133: GOTO 139 |
179 |
0134: GOTO 13A |
157 |
0134: BCF 20.4 |
180 |
0135: BCF 20.4 |
158 |
0135: MOVF 20,W |
181 |
0136: MOVF 20,W |
159 |
0136: BSF 03.5 |
182 |
0137: BSF 03.5 |
160 |
0137: MOVWF 07 |
183 |
0138: MOVWF 07 |
161 |
0138: BCF 03.5 |
184 |
0139: BCF 03.5 |
162 |
0139: NOP |
185 |
013A: NOP |
163 |
013A: BSF 20.3 |
186 |
013B: BSF 20.3 |
164 |
013B: MOVF 20,W |
187 |
013C: MOVF 20,W |
165 |
013C: BSF 03.5 |
188 |
013D: BSF 03.5 |
166 |
013D: MOVWF 07 |
189 |
013E: MOVWF 07 |
167 |
013E: BCF 03.5 |
190 |
013F: BCF 03.5 |
168 |
013F: BTFSS 07.3 |
191 |
0140: BTFSS 07.3 |
169 |
0140: GOTO 13F |
192 |
0141: GOTO 140 |
170 |
0141: NOP |
193 |
0142: NOP |
171 |
0142: BCF 07.3 |
194 |
0143: BCF 07.3 |
172 |
0143: BCF 20.3 |
195 |
0144: BCF 20.3 |
173 |
0144: MOVF 20,W |
196 |
0145: MOVF 20,W |
174 |
0145: BSF 03.5 |
197 |
0146: BSF 03.5 |
175 |
0146: MOVWF 07 |
198 |
0147: MOVWF 07 |
176 |
0147: NOP |
199 |
0148: NOP |
177 |
0148: BCF 03.5 |
200 |
0149: BCF 03.5 |
178 |
0149: BCF 07.4 |
201 |
014A: BCF 07.4 |
179 |
014A: BCF 20.4 |
202 |
014B: BCF 20.4 |
180 |
014B: MOVF 20,W |
203 |
014C: MOVF 20,W |
181 |
014C: BSF 03.5 |
204 |
014D: BSF 03.5 |
182 |
014D: MOVWF 07 |
205 |
014E: MOVWF 07 |
183 |
014E: BCF 03.5 |
206 |
014F: BCF 03.5 |
184 |
014F: RETURN |
207 |
0150: RETURN |
185 |
.................... #use rs232(baud=115200,parity=N,xmit=PIN_C7,rcv=PIN_C6,bits=8) //rcv TXD xmit RXD |
208 |
.................... #use rs232(baud=9600,parity=N,xmit=PIN_C7,rcv=PIN_C6,bits=8) //rcv TXD xmit RXD |
186 |
* |
209 |
* |
187 |
00A2: BCF 20.7 |
210 |
001F: BCF 20.7 |
188 |
00A3: MOVF 20,W |
211 |
0020: MOVF 20,W |
189 |
00A4: BSF 03.5 |
212 |
0021: BSF 03.5 |
190 |
00A5: MOVWF 07 |
213 |
0022: MOVWF 07 |
191 |
00A6: BCF 03.5 |
214 |
0023: BCF 03.5 |
192 |
00A7: BCF 07.7 |
215 |
0024: BCF 07.7 |
193 |
00A8: MOVLW 08 |
216 |
0025: MOVLW 08 |
194 |
00A9: MOVWF 78 |
217 |
0026: MOVWF 78 |
195 |
00AA: GOTO 0AB |
218 |
0027: GOTO 028 |
196 |
00AB: NOP |
219 |
0028: NOP |
197 |
00AC: BSF 78.7 |
220 |
0029: BSF 78.7 |
198 |
00AD: GOTO 0C0 |
221 |
002A: GOTO 039 |
199 |
00AE: BCF 78.7 |
222 |
002B: BCF 78.7 |
200 |
00AF: MOVF 40,W |
- |
|
201 |
00B0: MOVWF 79 |
- |
|
202 |
00B1: RRF 79,F |
223 |
002C: RRF 40,F |
203 |
00B2: BTFSC 03.0 |
224 |
002D: BTFSC 03.0 |
204 |
00B3: BSF 07.7 |
225 |
002E: BSF 07.7 |
205 |
00B4: BTFSS 03.0 |
226 |
002F: BTFSS 03.0 |
206 |
00B5: BCF 07.7 |
227 |
0030: BCF 07.7 |
207 |
00B6: BSF 78.6 |
228 |
0031: BSF 78.6 |
208 |
00B7: GOTO 0C0 |
229 |
0032: GOTO 039 |
209 |
00B8: BCF 78.6 |
230 |
0033: BCF 78.6 |
210 |
00B9: DECFSZ 78,F |
231 |
0034: DECFSZ 78,F |
211 |
00BA: GOTO 0B1 |
232 |
0035: GOTO 02C |
212 |
00BB: MOVF 79,W |
233 |
0036: GOTO 037 |
- |
|
234 |
0037: NOP |
- |
|
235 |
0038: BSF 07.7 |
213 |
00BC: MOVWF 40 |
236 |
0039: MOVLW 3F |
214 |
00BD: GOTO 0BE |
237 |
003A: MOVWF 04 |
215 |
00BE: NOP |
238 |
003B: DECFSZ 04,F |
216 |
00BF: BSF 07.7 |
239 |
003C: GOTO 03B |
- |
|
240 |
003D: NOP |
217 |
00C0: BTFSC 78.7 |
241 |
003E: BTFSC 78.7 |
218 |
00C1: GOTO 0AE |
242 |
003F: GOTO 02B |
219 |
00C2: BTFSC 78.6 |
243 |
0040: BTFSC 78.6 |
220 |
00C3: GOTO 0B8 |
244 |
0041: GOTO 033 |
221 |
00C4: RETURN |
245 |
0042: RETURN |
222 |
.................... |
246 |
.................... |
223 |
.................... |
247 |
.................... |
224 |
.................... #include "HMC5883L.h" |
248 |
.................... #include "HMC5883L.h" |
- |
|
249 |
.................... // i2c slave addresses |
225 |
.................... #define MAG_ADDR_R 0x3D //addresa pro cteni |
250 |
.................... #define HMC5883L_WRT_ADDR 0x3C |
226 |
.................... #define MAG_ADDR_W 0x3C |
251 |
.................... #define HMC5883L_READ_ADDR 0x3D |
227 |
.................... |
252 |
.................... |
- |
|
253 |
.................... // Register addresses |
- |
|
254 |
.................... #define HMC5883L_CFG_A_REG 0x00 |
- |
|
255 |
.................... #define HMC5883L_CFG_B_REG 0x01 |
- |
|
256 |
.................... #define HMC5883L_MODE_REG 0x02 |
- |
|
257 |
.................... #define HMC5883L_X_MSB_REG 0x03 |
228 |
.................... |
258 |
.................... |
229 |
.................... //Konstanty nastavujici rozsah |
259 |
.................... //Konstanty nastavujici rozsah |
230 |
.................... //pro void set_mag_roz (unsigned int8 h) |
260 |
.................... //pro void set_mag_roz (unsigned int8 h) |
231 |
.................... #define MAG_ROZ088 0x00 |
261 |
.................... #define MAG_ROZ088 0x00 |
232 |
.................... #define MAG_ROZ130 0x20 |
262 |
.................... #define MAG_ROZ130 0x20 |
Line 237... |
Line 267... |
237 |
.................... #define MAG_ROZ560 0xC0 |
267 |
.................... #define MAG_ROZ560 0xC0 |
238 |
.................... #define MAG_ROZ810 0xE0 |
268 |
.................... #define MAG_ROZ810 0xE0 |
239 |
.................... |
269 |
.................... |
240 |
.................... |
270 |
.................... |
241 |
.................... #include "HMC5883L.c" |
271 |
.................... #include "HMC5883L.c" |
242 |
.................... // i2c slave addresses |
- |
|
243 |
.................... #define HMC5883L_WRT_ADDR 0x3C |
- |
|
244 |
.................... #define HMC5883L_READ_ADDR 0x3D |
- |
|
245 |
.................... |
- |
|
246 |
.................... // Register addresses |
- |
|
247 |
.................... #define HMC5883L_CFG_A_REG 0x00 |
- |
|
248 |
.................... #define HMC5883L_CFG_B_REG 0x01 |
- |
|
249 |
.................... #define HMC5883L_MODE_REG 0x02 |
- |
|
250 |
.................... #define HMC5883L_X_MSB_REG 0x03 |
- |
|
251 |
.................... |
- |
|
252 |
.................... //------------------------------ |
272 |
.................... //------------------------------ |
253 |
.................... // Low level routines |
273 |
.................... // Low level routines |
254 |
.................... //------------------------------ |
274 |
.................... //------------------------------ |
255 |
.................... void hmc5883l_write_reg(int8 reg, int8 data) |
275 |
.................... void hmc5883l_write_reg(int8 reg, int8 data) |
256 |
.................... { |
276 |
.................... { |
257 |
.................... i2c_start(); |
277 |
.................... i2c_start(); |
258 |
* |
278 |
* |
259 |
0069: BSF 20.4 |
279 |
00D3: BSF 20.4 |
260 |
006A: MOVF 20,W |
280 |
00D4: MOVF 20,W |
261 |
006B: BSF 03.5 |
281 |
00D5: BSF 03.5 |
262 |
006C: MOVWF 07 |
282 |
00D6: MOVWF 07 |
263 |
006D: NOP |
283 |
00D7: NOP |
264 |
006E: BCF 03.5 |
284 |
00D8: BCF 03.5 |
265 |
006F: BSF 20.3 |
285 |
00D9: BSF 20.3 |
266 |
0070: MOVF 20,W |
286 |
00DA: MOVF 20,W |
267 |
0071: BSF 03.5 |
287 |
00DB: BSF 03.5 |
268 |
0072: MOVWF 07 |
288 |
00DC: MOVWF 07 |
269 |
0073: NOP |
289 |
00DD: NOP |
270 |
0074: BCF 03.5 |
290 |
00DE: BCF 03.5 |
271 |
0075: BCF 07.4 |
291 |
00DF: BCF 07.4 |
272 |
0076: BCF 20.4 |
292 |
00E0: BCF 20.4 |
273 |
0077: MOVF 20,W |
293 |
00E1: MOVF 20,W |
274 |
0078: BSF 03.5 |
294 |
00E2: BSF 03.5 |
275 |
0079: MOVWF 07 |
295 |
00E3: MOVWF 07 |
276 |
007A: NOP |
296 |
00E4: NOP |
277 |
007B: BCF 03.5 |
297 |
00E5: BCF 03.5 |
278 |
007C: BCF 07.3 |
298 |
00E6: BCF 07.3 |
279 |
007D: BCF 20.3 |
299 |
00E7: BCF 20.3 |
280 |
007E: MOVF 20,W |
300 |
00E8: MOVF 20,W |
281 |
007F: BSF 03.5 |
301 |
00E9: BSF 03.5 |
282 |
0080: MOVWF 07 |
302 |
00EA: MOVWF 07 |
283 |
.................... i2c_write(HMC5883L_WRT_ADDR); |
303 |
.................... i2c_write(HMC5883L_WRT_ADDR); |
284 |
0081: MOVLW 3C |
304 |
00EB: MOVLW 3C |
285 |
0082: BCF 03.5 |
305 |
00EC: BCF 03.5 |
286 |
0083: MOVWF 3D |
306 |
00ED: MOVWF 3D |
287 |
0084: CALL 01F |
307 |
00EE: CALL 089 |
288 |
.................... i2c_write(reg); |
308 |
.................... i2c_write(reg); |
289 |
0085: MOVF 37,W |
309 |
00EF: MOVF 37,W |
290 |
0086: MOVWF 3D |
310 |
00F0: MOVWF 3D |
291 |
0087: CALL 01F |
311 |
00F1: CALL 089 |
292 |
.................... i2c_write(data); |
312 |
.................... i2c_write(data); |
293 |
0088: MOVF 38,W |
313 |
00F2: MOVF 38,W |
294 |
0089: MOVWF 3D |
314 |
00F3: MOVWF 3D |
295 |
008A: CALL 01F |
315 |
00F4: CALL 089 |
296 |
.................... i2c_stop(); |
316 |
.................... i2c_stop(); |
297 |
008B: BCF 20.4 |
317 |
00F5: BCF 20.4 |
298 |
008C: MOVF 20,W |
318 |
00F6: MOVF 20,W |
299 |
008D: BSF 03.5 |
319 |
00F7: BSF 03.5 |
300 |
008E: MOVWF 07 |
320 |
00F8: MOVWF 07 |
301 |
008F: NOP |
321 |
00F9: NOP |
302 |
0090: BCF 03.5 |
322 |
00FA: BCF 03.5 |
303 |
0091: BSF 20.3 |
323 |
00FB: BSF 20.3 |
304 |
0092: MOVF 20,W |
324 |
00FC: MOVF 20,W |
305 |
0093: BSF 03.5 |
325 |
00FD: BSF 03.5 |
306 |
0094: MOVWF 07 |
326 |
00FE: MOVWF 07 |
307 |
0095: BCF 03.5 |
327 |
00FF: BCF 03.5 |
308 |
0096: BTFSS 07.3 |
328 |
0100: BTFSS 07.3 |
309 |
0097: GOTO 096 |
329 |
0101: GOTO 100 |
310 |
0098: NOP |
330 |
0102: NOP |
311 |
0099: GOTO 09A |
331 |
0103: GOTO 104 |
312 |
009A: NOP |
332 |
0104: NOP |
313 |
009B: BSF 20.4 |
333 |
0105: BSF 20.4 |
314 |
009C: MOVF 20,W |
334 |
0106: MOVF 20,W |
315 |
009D: BSF 03.5 |
335 |
0107: BSF 03.5 |
316 |
009E: MOVWF 07 |
336 |
0108: MOVWF 07 |
317 |
009F: NOP |
337 |
0109: NOP |
318 |
.................... } |
338 |
.................... } |
319 |
00A0: BCF 03.5 |
339 |
010A: BCF 03.5 |
320 |
00A1: RETURN |
340 |
010B: RETURN |
321 |
.................... |
341 |
.................... |
322 |
.................... //------------------------------ |
342 |
.................... //------------------------------ |
323 |
.................... int8 hmc5883l_read_reg(int8 reg) |
343 |
.................... int8 hmc5883l_read_reg(int8 reg) |
324 |
.................... { |
344 |
.................... { |
325 |
.................... int8 retval; |
345 |
.................... int8 retval; |
Line 345... |
Line 365... |
345 |
.................... |
365 |
.................... |
346 |
.................... // This global structure holds the values read |
366 |
.................... // This global structure holds the values read |
347 |
.................... // from the HMC5883L x,y,z registers. |
367 |
.................... // from the HMC5883L x,y,z registers. |
348 |
.................... hmc5883l_result compass = {0,0,0}; |
368 |
.................... hmc5883l_result compass = {0,0,0}; |
349 |
* |
369 |
* |
350 |
0270: CLRF 21 |
370 |
0287: CLRF 21 |
351 |
0271: CLRF 22 |
371 |
0288: CLRF 22 |
352 |
0272: CLRF 23 |
372 |
0289: CLRF 23 |
353 |
0273: CLRF 24 |
373 |
028A: CLRF 24 |
354 |
0274: CLRF 25 |
374 |
028B: CLRF 25 |
355 |
0275: CLRF 26 |
375 |
028C: CLRF 26 |
356 |
.................... |
376 |
.................... |
357 |
.................... //------------------------------ |
377 |
.................... //------------------------------ |
358 |
.................... void hmc5883l_read_data(void) |
378 |
.................... void hmc5883l_read_data(void) |
359 |
.................... { |
379 |
.................... { |
360 |
.................... unsigned int8 x_lsb; |
380 |
.................... unsigned int8 x_lsb; |
Line 366... |
Line 386... |
366 |
.................... unsigned int8 z_lsb; |
386 |
.................... unsigned int8 z_lsb; |
367 |
.................... unsigned int8 z_msb; |
387 |
.................... unsigned int8 z_msb; |
368 |
.................... |
388 |
.................... |
369 |
.................... i2c_start(); |
389 |
.................... i2c_start(); |
370 |
* |
390 |
* |
371 |
0150: BSF 20.4 |
391 |
0151: BSF 20.4 |
372 |
0151: MOVF 20,W |
392 |
0152: MOVF 20,W |
373 |
0152: BSF 03.5 |
393 |
0153: BSF 03.5 |
374 |
0153: MOVWF 07 |
394 |
0154: MOVWF 07 |
375 |
0154: NOP |
395 |
0155: NOP |
376 |
0155: BCF 03.5 |
396 |
0156: BCF 03.5 |
377 |
0156: BSF 20.3 |
397 |
0157: BSF 20.3 |
378 |
0157: MOVF 20,W |
398 |
0158: MOVF 20,W |
379 |
0158: BSF 03.5 |
399 |
0159: BSF 03.5 |
380 |
0159: MOVWF 07 |
400 |
015A: MOVWF 07 |
381 |
015A: NOP |
401 |
015B: NOP |
382 |
015B: BCF 03.5 |
402 |
015C: BCF 03.5 |
383 |
015C: BCF 07.4 |
403 |
015D: BCF 07.4 |
384 |
015D: BCF 20.4 |
404 |
015E: BCF 20.4 |
385 |
015E: MOVF 20,W |
405 |
015F: MOVF 20,W |
386 |
015F: BSF 03.5 |
406 |
0160: BSF 03.5 |
387 |
0160: MOVWF 07 |
407 |
0161: MOVWF 07 |
388 |
0161: NOP |
408 |
0162: NOP |
389 |
0162: BCF 03.5 |
409 |
0163: BCF 03.5 |
390 |
0163: BCF 07.3 |
410 |
0164: BCF 07.3 |
391 |
0164: BCF 20.3 |
411 |
0165: BCF 20.3 |
392 |
0165: MOVF 20,W |
412 |
0166: MOVF 20,W |
393 |
0166: BSF 03.5 |
413 |
0167: BSF 03.5 |
394 |
0167: MOVWF 07 |
414 |
0168: MOVWF 07 |
395 |
.................... i2c_write(HMC5883L_WRT_ADDR); |
415 |
.................... i2c_write(HMC5883L_WRT_ADDR); |
396 |
0168: MOVLW 3C |
416 |
0169: MOVLW 3C |
397 |
0169: BCF 03.5 |
417 |
016A: BCF 03.5 |
398 |
016A: MOVWF 3D |
418 |
016B: MOVWF 3D |
399 |
016B: CALL 01F |
419 |
016C: CALL 089 |
400 |
.................... i2c_write(HMC5883L_X_MSB_REG); // Point to X-msb register |
420 |
.................... i2c_write(HMC5883L_X_MSB_REG); // Point to X-msb register |
401 |
016C: MOVLW 03 |
421 |
016D: MOVLW 03 |
402 |
016D: MOVWF 3D |
422 |
016E: MOVWF 3D |
403 |
016E: CALL 01F |
423 |
016F: CALL 089 |
404 |
.................... i2c_start(); |
424 |
.................... i2c_start(); |
405 |
016F: BSF 20.4 |
425 |
0170: BSF 20.4 |
406 |
0170: MOVF 20,W |
426 |
0171: MOVF 20,W |
407 |
0171: BSF 03.5 |
427 |
0172: BSF 03.5 |
408 |
0172: MOVWF 07 |
428 |
0173: MOVWF 07 |
409 |
0173: NOP |
429 |
0174: NOP |
410 |
0174: BCF 03.5 |
430 |
0175: BCF 03.5 |
411 |
0175: BSF 20.3 |
431 |
0176: BSF 20.3 |
412 |
0176: MOVF 20,W |
432 |
0177: MOVF 20,W |
413 |
0177: BSF 03.5 |
433 |
0178: BSF 03.5 |
414 |
0178: MOVWF 07 |
434 |
0179: MOVWF 07 |
415 |
0179: NOP |
435 |
017A: NOP |
416 |
017A: BCF 03.5 |
436 |
017B: BCF 03.5 |
417 |
017B: BTFSS 07.3 |
437 |
017C: BTFSS 07.3 |
418 |
017C: GOTO 17B |
438 |
017D: GOTO 17C |
419 |
017D: BCF 07.4 |
439 |
017E: BCF 07.4 |
420 |
017E: BCF 20.4 |
440 |
017F: BCF 20.4 |
421 |
017F: MOVF 20,W |
441 |
0180: MOVF 20,W |
422 |
0180: BSF 03.5 |
442 |
0181: BSF 03.5 |
423 |
0181: MOVWF 07 |
443 |
0182: MOVWF 07 |
424 |
0182: NOP |
444 |
0183: NOP |
425 |
0183: BCF 03.5 |
445 |
0184: BCF 03.5 |
426 |
0184: BCF 07.3 |
446 |
0185: BCF 07.3 |
427 |
0185: BCF 20.3 |
447 |
0186: BCF 20.3 |
428 |
0186: MOVF 20,W |
448 |
0187: MOVF 20,W |
429 |
0187: BSF 03.5 |
449 |
0188: BSF 03.5 |
430 |
0188: MOVWF 07 |
450 |
0189: MOVWF 07 |
431 |
.................... i2c_write(HMC5883L_READ_ADDR); |
451 |
.................... i2c_write(HMC5883L_READ_ADDR); |
432 |
0189: MOVLW 3D |
452 |
018A: MOVLW 3D |
433 |
018A: BCF 03.5 |
453 |
018B: BCF 03.5 |
434 |
018B: MOVWF 3D |
454 |
018C: MOVWF 3D |
435 |
018C: CALL 01F |
455 |
018D: CALL 089 |
436 |
.................... |
456 |
.................... |
437 |
.................... x_msb = i2c_read(); |
457 |
.................... x_msb = i2c_read(); |
438 |
018D: MOVLW 01 |
458 |
018E: MOVLW 01 |
439 |
018E: MOVWF 77 |
459 |
018F: MOVWF 77 |
440 |
018F: CALL 10B |
460 |
0190: CALL 10C |
441 |
0190: MOVF 78,W |
461 |
0191: MOVF 78,W |
442 |
0191: MOVWF 38 |
462 |
0192: MOVWF 38 |
443 |
.................... x_lsb = i2c_read(); |
463 |
.................... x_lsb = i2c_read(); |
444 |
0192: MOVLW 01 |
464 |
0193: MOVLW 01 |
445 |
0193: MOVWF 77 |
465 |
0194: MOVWF 77 |
446 |
0194: CALL 10B |
466 |
0195: CALL 10C |
447 |
0195: MOVF 78,W |
467 |
0196: MOVF 78,W |
448 |
0196: MOVWF 37 |
468 |
0197: MOVWF 37 |
449 |
.................... |
469 |
.................... |
450 |
.................... z_msb = i2c_read(); |
470 |
.................... z_msb = i2c_read(); |
451 |
0197: MOVLW 01 |
471 |
0198: MOVLW 01 |
452 |
0198: MOVWF 77 |
472 |
0199: MOVWF 77 |
453 |
0199: CALL 10B |
473 |
019A: CALL 10C |
454 |
019A: MOVF 78,W |
474 |
019B: MOVF 78,W |
455 |
019B: MOVWF 3C |
475 |
019C: MOVWF 3C |
456 |
.................... z_lsb = i2c_read(); |
476 |
.................... z_lsb = i2c_read(); |
457 |
019C: MOVLW 01 |
477 |
019D: MOVLW 01 |
458 |
019D: MOVWF 77 |
478 |
019E: MOVWF 77 |
459 |
019E: CALL 10B |
479 |
019F: CALL 10C |
460 |
019F: MOVF 78,W |
480 |
01A0: MOVF 78,W |
461 |
01A0: MOVWF 3B |
481 |
01A1: MOVWF 3B |
462 |
.................... |
482 |
.................... |
463 |
.................... y_msb = i2c_read(); |
483 |
.................... y_msb = i2c_read(); |
464 |
01A1: MOVLW 01 |
484 |
01A2: MOVLW 01 |
465 |
01A2: MOVWF 77 |
485 |
01A3: MOVWF 77 |
466 |
01A3: CALL 10B |
486 |
01A4: CALL 10C |
467 |
01A4: MOVF 78,W |
487 |
01A5: MOVF 78,W |
468 |
01A5: MOVWF 3A |
488 |
01A6: MOVWF 3A |
469 |
.................... y_lsb = i2c_read(0); // do a NACK on last read |
489 |
.................... y_lsb = i2c_read(0); // do a NACK on last read |
470 |
01A6: CLRF 77 |
490 |
01A7: CLRF 77 |
471 |
01A7: CALL 10B |
491 |
01A8: CALL 10C |
472 |
01A8: MOVF 78,W |
492 |
01A9: MOVF 78,W |
473 |
01A9: MOVWF 39 |
493 |
01AA: MOVWF 39 |
474 |
.................... |
494 |
.................... |
475 |
.................... i2c_stop(); |
495 |
.................... i2c_stop(); |
476 |
01AA: BCF 20.4 |
496 |
01AB: BCF 20.4 |
477 |
01AB: MOVF 20,W |
497 |
01AC: MOVF 20,W |
478 |
01AC: BSF 03.5 |
498 |
01AD: BSF 03.5 |
479 |
01AD: MOVWF 07 |
499 |
01AE: MOVWF 07 |
480 |
01AE: NOP |
500 |
01AF: NOP |
481 |
01AF: BCF 03.5 |
501 |
01B0: BCF 03.5 |
482 |
01B0: BSF 20.3 |
502 |
01B1: BSF 20.3 |
483 |
01B1: MOVF 20,W |
503 |
01B2: MOVF 20,W |
484 |
01B2: BSF 03.5 |
504 |
01B3: BSF 03.5 |
485 |
01B3: MOVWF 07 |
505 |
01B4: MOVWF 07 |
486 |
01B4: BCF 03.5 |
506 |
01B5: BCF 03.5 |
487 |
01B5: BTFSS 07.3 |
507 |
01B6: BTFSS 07.3 |
488 |
01B6: GOTO 1B5 |
508 |
01B7: GOTO 1B6 |
489 |
01B7: NOP |
509 |
01B8: NOP |
490 |
01B8: GOTO 1B9 |
510 |
01B9: GOTO 1BA |
491 |
01B9: NOP |
511 |
01BA: NOP |
492 |
01BA: BSF 20.4 |
512 |
01BB: BSF 20.4 |
493 |
01BB: MOVF 20,W |
513 |
01BC: MOVF 20,W |
494 |
01BC: BSF 03.5 |
514 |
01BD: BSF 03.5 |
495 |
01BD: MOVWF 07 |
515 |
01BE: MOVWF 07 |
496 |
01BE: NOP |
516 |
01BF: NOP |
497 |
.................... |
517 |
.................... |
498 |
.................... // Combine high and low bytes into 16-bit values. |
518 |
.................... // Combine high and low bytes into 16-bit values. |
499 |
.................... compass.x = make16(x_msb, x_lsb); |
519 |
.................... compass.x = make16(x_msb, x_lsb); |
500 |
01BF: BCF 03.5 |
520 |
01C0: BCF 03.5 |
501 |
01C0: MOVF 38,W |
521 |
01C1: MOVF 38,W |
502 |
01C1: MOVWF 22 |
522 |
01C2: MOVWF 22 |
503 |
01C2: MOVF 37,W |
523 |
01C3: MOVF 37,W |
504 |
01C3: MOVWF 21 |
524 |
01C4: MOVWF 21 |
505 |
.................... compass.y = make16(y_msb, y_lsb); |
525 |
.................... compass.y = make16(y_msb, y_lsb); |
506 |
01C4: MOVF 3A,W |
526 |
01C5: MOVF 3A,W |
507 |
01C5: MOVWF 24 |
527 |
01C6: MOVWF 24 |
508 |
01C6: MOVF 39,W |
528 |
01C7: MOVF 39,W |
509 |
01C7: MOVWF 23 |
529 |
01C8: MOVWF 23 |
510 |
.................... compass.z = make16(z_msb, z_lsb); |
530 |
.................... compass.z = make16(z_msb, z_lsb); |
511 |
01C8: MOVF 3C,W |
531 |
01C9: MOVF 3C,W |
512 |
01C9: MOVWF 26 |
532 |
01CA: MOVWF 26 |
513 |
01CA: MOVF 3B,W |
533 |
01CB: MOVF 3B,W |
514 |
01CB: MOVWF 25 |
534 |
01CC: MOVWF 25 |
515 |
.................... } |
535 |
.................... } |
516 |
01CC: BCF 0A.3 |
536 |
01CD: BCF 0A.3 |
517 |
01CD: BCF 0A.4 |
537 |
01CE: BCF 0A.4 |
518 |
01CE: GOTO 2E1 (RETURN) |
538 |
01CF: GOTO 2F6 (RETURN) |
519 |
.................... |
539 |
.................... |
520 |
.................... |
540 |
.................... |
521 |
.................... |
541 |
.................... |
522 |
.................... |
542 |
.................... |
523 |
.................... #include <math.h> |
543 |
.................... #include <math.h> |
Line 2695... |
Line 2715... |
2695 |
.................... |
2715 |
.................... |
2696 |
.................... |
2716 |
.................... |
2697 |
.................... void main() |
2717 |
.................... void main() |
2698 |
.................... { |
2718 |
.................... { |
2699 |
* |
2719 |
* |
2700 |
024F: CLRF 04 |
2720 |
0266: CLRF 04 |
2701 |
0250: BCF 03.7 |
2721 |
0267: BCF 03.7 |
2702 |
0251: MOVLW 1F |
2722 |
0268: MOVLW 1F |
2703 |
0252: ANDWF 03,F |
2723 |
0269: ANDWF 03,F |
2704 |
0253: MOVLW 71 |
2724 |
026A: MOVLW 71 |
2705 |
0254: BSF 03.5 |
2725 |
026B: BSF 03.5 |
2706 |
0255: MOVWF 0F |
2726 |
026C: MOVWF 0F |
2707 |
0256: MOVF 0F,W |
2727 |
026D: MOVF 0F,W |
2708 |
0257: BCF 03.5 |
2728 |
026E: BCF 03.5 |
2709 |
0258: BCF 20.7 |
2729 |
026F: BCF 20.7 |
2710 |
0259: MOVF 20,W |
2730 |
0270: MOVF 20,W |
2711 |
025A: BSF 03.5 |
2731 |
0271: BSF 03.5 |
2712 |
025B: MOVWF 07 |
2732 |
0272: MOVWF 07 |
2713 |
025C: BCF 03.5 |
2733 |
0273: BCF 03.5 |
2714 |
025D: BSF 07.7 |
2734 |
0274: BSF 07.7 |
2715 |
025E: BSF 03.5 |
2735 |
0275: BSF 03.5 |
2716 |
025F: BSF 03.6 |
2736 |
0276: BSF 03.6 |
2717 |
0260: MOVF 09,W |
2737 |
0277: MOVF 09,W |
2718 |
0261: ANDLW C0 |
2738 |
0278: ANDLW C0 |
2719 |
0262: MOVWF 09 |
2739 |
0279: MOVWF 09 |
2720 |
0263: BCF 03.6 |
2740 |
027A: BCF 03.6 |
2721 |
0264: BCF 1F.4 |
2741 |
027B: BCF 1F.4 |
2722 |
0265: BCF 1F.5 |
2742 |
027C: BCF 1F.5 |
2723 |
0266: MOVLW 00 |
2743 |
027D: MOVLW 00 |
2724 |
0267: BSF 03.6 |
2744 |
027E: BSF 03.6 |
2725 |
0268: MOVWF 08 |
2745 |
027F: MOVWF 08 |
2726 |
0269: BCF 03.5 |
2746 |
0280: BCF 03.5 |
2727 |
026A: CLRF 07 |
2747 |
0281: CLRF 07 |
2728 |
026B: CLRF 08 |
2748 |
0282: CLRF 08 |
2729 |
026C: CLRF 09 |
2749 |
0283: CLRF 09 |
2730 |
* |
2750 |
* |
2731 |
0276: CLRF 34 |
2751 |
028D: CLRF 34 |
2732 |
0277: CLRF 33 |
2752 |
028E: CLRF 33 |
2733 |
.................... float last,b,anemo_speed; |
2753 |
.................... float last,b,anemo_speed; |
2734 |
.................... unsigned int16 anemo_round=0; |
2754 |
.................... unsigned int16 anemo_round=0; |
2735 |
.................... unsigned int16 i; |
2755 |
.................... unsigned int16 i; |
2736 |
.................... |
2756 |
.................... |
2737 |
.................... |
- |
|
2738 |
.................... //signed int16 X,Y,Z; |
2757 |
.................... //signed int16 X,Y,Z; |
2739 |
.................... setup_adc_ports(NO_ANALOGS|VSS_VDD); |
2758 |
.................... setup_adc_ports(NO_ANALOGS|VSS_VDD); |
2740 |
0278: BSF 03.5 |
2759 |
028F: BSF 03.5 |
2741 |
0279: BSF 03.6 |
2760 |
0290: BSF 03.6 |
2742 |
027A: MOVF 09,W |
2761 |
0291: MOVF 09,W |
2743 |
027B: ANDLW C0 |
2762 |
0292: ANDLW C0 |
2744 |
027C: MOVWF 09 |
2763 |
0293: MOVWF 09 |
2745 |
027D: BCF 03.6 |
2764 |
0294: BCF 03.6 |
2746 |
027E: BCF 1F.4 |
2765 |
0295: BCF 1F.4 |
2747 |
027F: BCF 1F.5 |
2766 |
0296: BCF 1F.5 |
2748 |
0280: MOVLW 00 |
2767 |
0297: MOVLW 00 |
2749 |
0281: BSF 03.6 |
2768 |
0298: BSF 03.6 |
2750 |
0282: MOVWF 08 |
2769 |
0299: MOVWF 08 |
2751 |
.................... setup_adc(ADC_CLOCK_DIV_2); |
2770 |
.................... setup_adc(ADC_CLOCK_DIV_2); |
2752 |
0283: BCF 03.5 |
2771 |
029A: BCF 03.5 |
2753 |
0284: BCF 03.6 |
2772 |
029B: BCF 03.6 |
2754 |
0285: BCF 1F.6 |
2773 |
029C: BCF 1F.6 |
2755 |
0286: BCF 1F.7 |
- |
|
2756 |
0287: BSF 03.5 |
- |
|
2757 |
0288: BCF 1F.7 |
2774 |
029D: BCF 1F.7 |
2758 |
0289: BCF 03.5 |
- |
|
2759 |
028A: BSF 1F.0 |
- |
|
2760 |
.................... setup_spi(SPI_SS_DISABLED); |
- |
|
2761 |
028B: BCF 14.5 |
- |
|
2762 |
028C: BCF 20.5 |
- |
|
2763 |
028D: MOVF 20,W |
- |
|
2764 |
028E: BSF 03.5 |
- |
|
2765 |
028F: MOVWF 07 |
- |
|
2766 |
0290: BCF 03.5 |
- |
|
2767 |
0291: BSF 20.4 |
- |
|
2768 |
0292: MOVF 20,W |
- |
|
2769 |
0293: BSF 03.5 |
- |
|
2770 |
0294: MOVWF 07 |
- |
|
2771 |
0295: BCF 03.5 |
- |
|
2772 |
0296: BCF 20.3 |
- |
|
2773 |
0297: MOVF 20,W |
- |
|
2774 |
0298: BSF 03.5 |
- |
|
2775 |
0299: MOVWF 07 |
- |
|
2776 |
029A: MOVLW 01 |
- |
|
2777 |
029B: BCF 03.5 |
- |
|
2778 |
029C: MOVWF 14 |
- |
|
2779 |
029D: MOVLW 00 |
- |
|
2780 |
029E: BSF 03.5 |
2775 |
029E: BSF 03.5 |
2781 |
029F: MOVWF 14 |
2776 |
029F: BCF 1F.7 |
2782 |
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); |
- |
|
2783 |
02A0: MOVF 01,W |
2777 |
02A0: BCF 03.5 |
2784 |
02A1: ANDLW C7 |
2778 |
02A1: BSF 1F.0 |
- |
|
2779 |
.................... setup_spi(SPI_SS_DISABLED); |
2785 |
02A2: IORLW 08 |
2780 |
02A2: BCF 14.5 |
2786 |
02A3: MOVWF 01 |
2781 |
02A3: BCF 20.5 |
2787 |
.................... setup_timer_1(T1_DISABLED); |
- |
|
2788 |
02A4: BCF 03.5 |
2782 |
02A4: MOVF 20,W |
2789 |
02A5: CLRF 10 |
2783 |
02A5: BSF 03.5 |
2790 |
.................... setup_timer_2(T2_DISABLED,0,1); |
- |
|
2791 |
02A6: MOVLW 00 |
2784 |
02A6: MOVWF 07 |
2792 |
02A7: MOVWF 78 |
2785 |
02A7: BCF 03.5 |
2793 |
02A8: MOVWF 12 |
2786 |
02A8: BSF 20.4 |
2794 |
02A9: MOVLW 00 |
2787 |
02A9: MOVF 20,W |
2795 |
02AA: BSF 03.5 |
2788 |
02AA: BSF 03.5 |
2796 |
02AB: MOVWF 12 |
2789 |
02AB: MOVWF 07 |
2797 |
.................... setup_ccp1(CCP_OFF); |
- |
|
2798 |
02AC: BCF 03.5 |
2790 |
02AC: BCF 03.5 |
2799 |
02AD: BSF 20.2 |
2791 |
02AD: BCF 20.3 |
2800 |
02AE: MOVF 20,W |
2792 |
02AE: MOVF 20,W |
2801 |
02AF: BSF 03.5 |
2793 |
02AF: BSF 03.5 |
2802 |
02B0: MOVWF 07 |
2794 |
02B0: MOVWF 07 |
- |
|
2795 |
02B1: MOVLW 01 |
2803 |
02B1: BCF 03.5 |
2796 |
02B2: BCF 03.5 |
- |
|
2797 |
02B3: MOVWF 14 |
- |
|
2798 |
02B4: MOVLW 00 |
- |
|
2799 |
02B5: BSF 03.5 |
- |
|
2800 |
02B6: MOVWF 14 |
- |
|
2801 |
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); |
- |
|
2802 |
02B7: MOVF 01,W |
- |
|
2803 |
02B8: ANDLW C7 |
- |
|
2804 |
02B9: IORLW 08 |
- |
|
2805 |
02BA: MOVWF 01 |
- |
|
2806 |
.................... setup_timer_1(T1_DISABLED); |
- |
|
2807 |
02BB: BCF 03.5 |
- |
|
2808 |
02BC: CLRF 10 |
- |
|
2809 |
.................... setup_timer_2(T2_DISABLED,0,1); |
- |
|
2810 |
02BD: MOVLW 00 |
- |
|
2811 |
02BE: MOVWF 78 |
- |
|
2812 |
02BF: MOVWF 12 |
- |
|
2813 |
02C0: MOVLW 00 |
- |
|
2814 |
02C1: BSF 03.5 |
- |
|
2815 |
02C2: MOVWF 12 |
- |
|
2816 |
.................... setup_ccp1(CCP_OFF); |
- |
|
2817 |
02C3: BCF 03.5 |
- |
|
2818 |
02C4: BSF 20.2 |
- |
|
2819 |
02C5: MOVF 20,W |
- |
|
2820 |
02C6: BSF 03.5 |
- |
|
2821 |
02C7: MOVWF 07 |
- |
|
2822 |
02C8: BCF 03.5 |
2804 |
02B2: CLRF 17 |
2823 |
02C9: CLRF 17 |
2805 |
02B3: BSF 03.5 |
2824 |
02CA: BSF 03.5 |
2806 |
02B4: CLRF 1B |
2825 |
02CB: CLRF 1B |
2807 |
02B5: CLRF 1C |
2826 |
02CC: CLRF 1C |
2808 |
02B6: MOVLW 01 |
2827 |
02CD: MOVLW 01 |
2809 |
02B7: MOVWF 1D |
2828 |
02CE: MOVWF 1D |
2810 |
.................... setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard |
2829 |
.................... setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard |
2811 |
02B8: BCF 03.5 |
2830 |
02CF: BCF 03.5 |
2812 |
02B9: BSF 03.6 |
2831 |
02D0: BSF 03.6 |
2813 |
02BA: CLRF 07 |
2832 |
02D1: CLRF 07 |
2814 |
02BB: CLRF 08 |
2833 |
02D2: CLRF 08 |
2815 |
02BC: CLRF 09 |
2834 |
02D3: CLRF 09 |
- |
|
2835 |
.................... |
- |
|
2836 |
.................... printf("Magnetometr: \r\n",); |
- |
|
2837 |
02D4: MOVLW 04 |
- |
|
2838 |
02D5: MOVWF 0D |
- |
|
2839 |
02D6: MOVLW 00 |
- |
|
2840 |
02D7: MOVWF 0F |
- |
|
2841 |
02D8: BCF 03.6 |
- |
|
2842 |
02D9: CALL 043 |
- |
|
2843 |
.................... printf("(c)mlab JACHO 2013: \r\n",); |
- |
|
2844 |
02DA: MOVLW 0D |
- |
|
2845 |
02DB: BSF 03.6 |
- |
|
2846 |
02DC: MOVWF 0D |
- |
|
2847 |
02DD: MOVLW 00 |
- |
|
2848 |
02DE: MOVWF 0F |
- |
|
2849 |
02DF: BCF 03.6 |
- |
|
2850 |
02E0: CALL 043 |
- |
|
2851 |
.................... printf("X, Y, Z \r\n",); |
- |
|
2852 |
02E1: MOVLW 19 |
- |
|
2853 |
02E2: BSF 03.6 |
- |
|
2854 |
02E3: MOVWF 0D |
- |
|
2855 |
02E4: MOVLW 00 |
- |
|
2856 |
02E5: MOVWF 0F |
- |
|
2857 |
02E6: BCF 03.6 |
- |
|
2858 |
02E7: CALL 043 |
- |
|
2859 |
.................... |
2816 |
.................... |
2860 |
.................... |
2817 |
.................... // Init the HMC5883L. Set Mode register for |
2861 |
.................... // Init the HMC5883L. Set Mode register for |
2818 |
.................... // continuous measurements. |
2862 |
.................... // continuous measurements. |
2819 |
.................... hmc5883l_write_reg(HMC5883L_CFG_A_REG, 0x18); // no average, maximal update range |
2863 |
.................... hmc5883l_write_reg(HMC5883L_CFG_A_REG, 0x18); // no average, maximal update range |
2820 |
02BD: BCF 03.6 |
- |
|
2821 |
02BE: CLRF 37 |
2864 |
02E8: CLRF 37 |
2822 |
02BF: MOVLW 18 |
2865 |
02E9: MOVLW 18 |
2823 |
02C0: MOVWF 38 |
2866 |
02EA: MOVWF 38 |
2824 |
02C1: CALL 069 |
2867 |
02EB: CALL 0D3 |
2825 |
.................... hmc5883l_write_reg(HMC5883L_CFG_B_REG, 0xE0); // maximal range |
2868 |
.................... hmc5883l_write_reg(HMC5883L_CFG_B_REG, 0xE0); // maximal range |
2826 |
02C2: MOVLW 01 |
2869 |
02EC: MOVLW 01 |
2827 |
02C3: MOVWF 37 |
2870 |
02ED: MOVWF 37 |
2828 |
02C4: MOVLW E0 |
2871 |
02EE: MOVLW E0 |
2829 |
02C5: MOVWF 38 |
2872 |
02EF: MOVWF 38 |
2830 |
02C6: CALL 069 |
2873 |
02F0: CALL 0D3 |
2831 |
.................... hmc5883l_write_reg(HMC5883L_MODE_REG, 0x00); |
2874 |
.................... hmc5883l_write_reg(HMC5883L_MODE_REG, 0x00); |
2832 |
02C7: MOVLW 02 |
2875 |
02F1: MOVLW 02 |
2833 |
02C8: MOVWF 37 |
2876 |
02F2: MOVWF 37 |
2834 |
02C9: CLRF 38 |
2877 |
02F3: CLRF 38 |
2835 |
02CA: CALL 069 |
2878 |
02F4: CALL 0D3 |
2836 |
.................... |
2879 |
.................... |
2837 |
.................... // Continuously read and display the x,y,z results. |
2880 |
.................... // Continuously read and display the x,y,z results. |
2838 |
.................... // Wait at least 67 ms between reads, re the HMC5883L data sheet. |
2881 |
.................... // Wait at least 67 ms between reads, re the HMC5883L data sheet. |
2839 |
.................... |
2882 |
.................... |
2840 |
.................... |
2883 |
.................... |
2841 |
.................... printf("Magnetometr: \r\n",); |
- |
|
2842 |
02CB: MOVLW 04 |
- |
|
2843 |
02CC: BSF 03.6 |
- |
|
2844 |
02CD: MOVWF 0D |
- |
|
2845 |
02CE: MOVLW 00 |
- |
|
2846 |
02CF: MOVWF 0F |
- |
|
2847 |
02D0: BCF 03.6 |
- |
|
2848 |
02D1: CALL 0C5 |
- |
|
2849 |
.................... printf("(c)mlab JACHO 2013: \r\n",); |
- |
|
2850 |
02D2: MOVLW 0D |
- |
|
2851 |
02D3: BSF 03.6 |
- |
|
2852 |
02D4: MOVWF 0D |
- |
|
2853 |
02D5: MOVLW 00 |
- |
|
2854 |
02D6: MOVWF 0F |
- |
|
2855 |
02D7: BCF 03.6 |
- |
|
2856 |
02D8: CALL 0C5 |
- |
|
2857 |
.................... printf("X, Y, Z \r\n",); |
- |
|
2858 |
02D9: MOVLW 19 |
- |
|
2859 |
02DA: BSF 03.6 |
- |
|
2860 |
02DB: MOVWF 0D |
- |
|
2861 |
02DC: MOVLW 00 |
- |
|
2862 |
02DD: MOVWF 0F |
- |
|
2863 |
02DE: BCF 03.6 |
- |
|
2864 |
02DF: CALL 0C5 |
- |
|
2865 |
.................... |
- |
|
2866 |
.................... /* while(true) |
- |
|
2867 |
.................... { |
- |
|
2868 |
.................... X = mag_readX(); |
- |
|
2869 |
.................... Y = mag_readY(); |
- |
|
2870 |
.................... Z = mag_readZ(); |
- |
|
2871 |
.................... printf("%4Ld %4Ld %4Ld \r\n", X, Y, Z); |
- |
|
2872 |
.................... Delay_ms(50); |
- |
|
2873 |
.................... |
- |
|
2874 |
.................... } |
- |
|
2875 |
.................... */ |
- |
|
2876 |
.................... |
- |
|
2877 |
.................... while(TRUE) |
2884 |
.................... while(TRUE) |
2878 |
.................... { |
2885 |
.................... { |
2879 |
.................... |
2886 |
.................... |
2880 |
.................... // for(i=0;i<=10;i++) |
- |
|
2881 |
.................... // { |
- |
|
2882 |
.................... hmc5883l_read_data(); |
2887 |
.................... hmc5883l_read_data(); |
2883 |
02E0: GOTO 150 |
2888 |
02F5: GOTO 151 |
2884 |
.................... |
- |
|
2885 |
.................... // b = atan2((float)compass.y,(float)compass.x); // vypocet azimutu z kartezskych souradnic |
- |
|
2886 |
.................... // b = (b/3.141596)*180; // prevod na stupne |
- |
|
2887 |
.................... // b += 180; |
- |
|
2888 |
.................... |
- |
|
2889 |
.................... // anemo_speed += (b-last); |
- |
|
2890 |
.................... // last=b; |
- |
|
2891 |
.................... // delay_ms(10); |
- |
|
2892 |
.................... // } |
- |
|
2893 |
.................... // anemo_speed=anemo_speed/10; |
- |
|
2894 |
.................... |
- |
|
2895 |
.................... printf("%6Ld %6Ld %6Ld \n\r", compass.x, compass.y, compass.z); |
2889 |
.................... printf("%6Ld %6Ld %6Ld \n\r", compass.x, compass.y, compass.z); |
2896 |
02E1: MOVLW 00 |
2890 |
02F6: MOVLW 00 |
2897 |
02E2: MOVWF 04 |
2891 |
02F7: MOVWF 04 |
2898 |
02E3: MOVF 22,W |
2892 |
02F8: MOVF 22,W |
2899 |
02E4: MOVWF 38 |
2893 |
02F9: MOVWF 38 |
2900 |
02E5: MOVF 21,W |
2894 |
02FA: MOVF 21,W |
2901 |
02E6: MOVWF 37 |
2895 |
02FB: MOVWF 37 |
2902 |
02E7: CALL 1CF |
2896 |
02FC: CALL 1D0 |
2903 |
02E8: MOVLW 20 |
2897 |
02FD: MOVLW 20 |
2904 |
02E9: MOVWF 40 |
2898 |
02FE: MOVWF 40 |
2905 |
02EA: CALL 0A2 |
2899 |
02FF: CALL 01F |
2906 |
02EB: MOVLW 00 |
2900 |
0300: MOVLW 00 |
2907 |
02EC: MOVWF 04 |
2901 |
0301: MOVWF 04 |
2908 |
02ED: MOVF 24,W |
2902 |
0302: MOVF 24,W |
2909 |
02EE: MOVWF 38 |
2903 |
0303: MOVWF 38 |
2910 |
02EF: MOVF 23,W |
2904 |
0304: MOVF 23,W |
2911 |
02F0: MOVWF 37 |
2905 |
0305: MOVWF 37 |
2912 |
02F1: CALL 1CF |
2906 |
0306: CALL 1D0 |
2913 |
02F2: MOVLW 20 |
2907 |
0307: MOVLW 20 |
2914 |
02F3: MOVWF 40 |
2908 |
0308: MOVWF 40 |
2915 |
02F4: CALL 0A2 |
2909 |
0309: CALL 01F |
2916 |
02F5: MOVLW 00 |
2910 |
030A: MOVLW 00 |
2917 |
02F6: MOVWF 04 |
2911 |
030B: MOVWF 04 |
2918 |
02F7: MOVF 26,W |
2912 |
030C: MOVF 26,W |
2919 |
02F8: MOVWF 38 |
2913 |
030D: MOVWF 38 |
2920 |
02F9: MOVF 25,W |
2914 |
030E: MOVF 25,W |
2921 |
02FA: MOVWF 37 |
2915 |
030F: MOVWF 37 |
2922 |
02FB: CALL 1CF |
2916 |
0310: CALL 1D0 |
2923 |
02FC: MOVLW 20 |
2917 |
0311: MOVLW 20 |
2924 |
02FD: MOVWF 40 |
2918 |
0312: MOVWF 40 |
2925 |
02FE: CALL 0A2 |
2919 |
0313: CALL 01F |
2926 |
02FF: MOVLW 0A |
2920 |
0314: MOVLW 0A |
2927 |
0300: MOVWF 40 |
2921 |
0315: MOVWF 40 |
2928 |
0301: CALL 0A2 |
2922 |
0316: CALL 01F |
2929 |
0302: MOVLW 0D |
2923 |
0317: MOVLW 0D |
2930 |
0303: MOVWF 40 |
2924 |
0318: MOVWF 40 |
2931 |
0304: CALL 0A2 |
2925 |
0319: CALL 01F |
2932 |
.................... // delay_ms(100); |
2926 |
.................... delay_ms(100); |
- |
|
2927 |
031A: MOVLW 64 |
- |
|
2928 |
031B: MOVWF 37 |
- |
|
2929 |
031C: GOTO 250 |
2933 |
.................... } |
2930 |
.................... } |
2934 |
0305: GOTO 2E0 |
2931 |
031D: GOTO 2F5 |
2935 |
.................... |
2932 |
.................... |
2936 |
.................... } |
2933 |
.................... } |
2937 |
.................... |
2934 |
.................... |
2938 |
.................... |
2935 |
.................... |
2939 |
.................... |
2936 |
.................... |
2940 |
0306: SLEEP |
2937 |
031E: SLEEP |
2941 |
|
2938 |
|
2942 |
Configuration Fuses: |
2939 |
Configuration Fuses: |
2943 |
Word 1: 2CF5 INTRC NOWDT NOPUT MCLR NOPROTECT NOCPD NOBROWNOUT IESO FCMEN NOLVP NODEBUG |
2940 |
Word 1: 2CF5 INTRC NOWDT NOPUT MCLR NOPROTECT NOCPD NOBROWNOUT IESO FCMEN NOLVP NODEBUG |
2944 |
Word 2: 3FFF NOWRT BORV40 |
2941 |
Word 2: 3FFF NOWRT BORV40 |