Rev 3462 Rev 3463
Line 1... Line 1...
1 CCS PCM C Compiler, Version 4.106, 47914 04-II-14 11:45 1 CCS PCM C Compiler, Version 4.106, 47914 04-II-14 15:49
2   2  
3 Filename: Z:\home\kaklik\svn\svnMLAB\Designs\Measuring_instruments\RMDS01C\SW\PIC16F887\main.lst 3 Filename: Z:\home\kaklik\svn\svnMLAB\Designs\Measuring_instruments\RMDS01C\SW\PIC16F887\main.lst
4   4  
5 ROM used: 984 words (12%) 5 ROM used: 421 words (5%)
6 Largest free fragment is 2048 6 Largest free fragment is 2048
7 RAM used: 43 (12%) at main() level 7 RAM used: 31 (8%) at main() level
8 96 (26%) worst case 8 37 (10%) worst case
9 Stack: 3 worst case (1 in main + 2 for interrupts) 9 Stack: 3 worst case (1 in main + 2 for interrupts)
10   10  
11 * 11 *
12 0000: MOVLW 03 12 0000: MOVLW 01
13 0001: MOVWF 0A 13 0001: MOVWF 0A
14 0002: GOTO 332 14 0002: GOTO 111
15 0003: NOP 15 0003: NOP
16 0004: MOVWF 7F 16 0004: MOVWF 7F
17 0005: SWAPF 03,W 17 0005: SWAPF 03,W
18 0006: CLRF 03 18 0006: CLRF 03
19 0007: MOVWF 21 19 0007: MOVWF 21
Line 30... Line 30...
30 0012: MOVWF 25 30 0012: MOVWF 25
31 0013: MOVF 7A,W 31 0013: MOVF 7A,W
32 0014: MOVWF 26 32 0014: MOVWF 26
33 0015: BCF 03.7 33 0015: BCF 03.7
34 0016: BCF 03.5 34 0016: BCF 03.5
35 0017: BTFSS 0B.4 -  
36 0018: GOTO 01B -  
37 0019: BTFSC 0B.1 -  
38 001A: GOTO 038 -  
39 001B: MOVLW 8C 35 0017: MOVLW 8C
40 001C: MOVWF 04 36 0018: MOVWF 04
41 001D: BTFSS 00.0 37 0019: BTFSS 00.3
42 001E: GOTO 021 38 001A: GOTO 01D
43 001F: BTFSC 0C.0 -  
44 0020: GOTO 03B -  
45 0021: MOVLW 8C -  
46 0022: MOVWF 04 -  
47 0023: BTFSS 00.3 -  
48 0024: GOTO 027 -  
49 0025: BTFSC 0C.3 39 001B: BTFSC 0C.3
50 0026: GOTO 03E 40 001C: GOTO 02E
51 0027: MOVF 22,W 41 001D: MOVF 22,W
52 0028: MOVWF 04 42 001E: MOVWF 04
53 0029: MOVF 23,W 43 001F: MOVF 23,W
54 002A: MOVWF 77 44 0020: MOVWF 77
55 002B: MOVF 24,W 45 0021: MOVF 24,W
56 002C: MOVWF 78 46 0022: MOVWF 78
57 002D: MOVF 25,W 47 0023: MOVF 25,W
58 002E: MOVWF 79 48 0024: MOVWF 79
59 002F: MOVF 26,W 49 0025: MOVF 26,W
60 0030: MOVWF 7A 50 0026: MOVWF 7A
61 0031: MOVF 20,W 51 0027: MOVF 20,W
62 0032: MOVWF 0A 52 0028: MOVWF 0A
63 0033: SWAPF 21,W 53 0029: SWAPF 21,W
64 0034: MOVWF 03 54 002A: MOVWF 03
65 0035: SWAPF 7F,F 55 002B: SWAPF 7F,F
66 0036: SWAPF 7F,W 56 002C: SWAPF 7F,W
67 0037: RETFIE 57 002D: RETFIE
68 0038: BCF 0A.3 -  
69 0039: BCF 0A.4 -  
70 003A: GOTO 145 -  
71 003B: BCF 0A.3 58 002E: BCF 0A.3
72 003C: BCF 0A.4 59 002F: BCF 0A.4
73 003D: GOTO 2C6 60 0030: GOTO 03E
74 003E: BCF 0A.3 -  
75 003F: BCF 0A.4 61 .................... #define ID "$Id: main.c 2916 2013-04-14 17:42:03Z kaklik $"
76 0040: GOTO 06D -  
77 .................... #include "main.h" 62 .................... #include "main.h"
78 .................... #include <16F887.h> 63 .................... #include <16F887.h>
79 .................... //////// Standard Header file for the PIC16F887 device //////////////// 64 .................... //////// Standard Header file for the PIC16F887 device ////////////////
80 .................... #device PIC16F887 65 .................... #device PIC16F887
81 .................... #list 66 .................... #list
Line 96... Line 81...
96 .................... #FUSES NOWRT //Program memory not write protected 81 .................... #FUSES NOWRT //Program memory not write protected
97 .................... #FUSES BORV40 //Brownout reset at 4.0V 82 .................... #FUSES BORV40 //Brownout reset at 4.0V
98 .................... 83 ....................
99 .................... #use delay(clock=20000000) 84 .................... #use delay(clock=20000000)
100 * 85 *
101 02D2: MOVLW 47 86 00D8: MOVLW 3A
102 02D3: MOVWF 04 87 00D9: MOVWF 04
103 02D4: BCF 03.7 88 00DA: BCF 03.7
104 02D5: MOVF 00,W 89 00DB: MOVF 00,W
105 02D6: BTFSC 03.2 90 00DC: BTFSC 03.2
106 02D7: GOTO 2E5 91 00DD: GOTO 0EB
107 02D8: MOVLW 06 92 00DE: MOVLW 06
108 02D9: MOVWF 78 93 00DF: MOVWF 78
109 02DA: CLRF 77 94 00E0: CLRF 77
110 02DB: DECFSZ 77,F 95 00E1: DECFSZ 77,F
111 02DC: GOTO 2DB 96 00E2: GOTO 0E1
112 02DD: DECFSZ 78,F 97 00E3: DECFSZ 78,F
113 02DE: GOTO 2DA 98 00E4: GOTO 0E0
114 02DF: MOVLW 7B 99 00E5: MOVLW 7B
115 02E0: MOVWF 77 100 00E6: MOVWF 77
116 02E1: DECFSZ 77,F 101 00E7: DECFSZ 77,F
117 02E2: GOTO 2E1 102 00E8: GOTO 0E7
118 02E3: DECFSZ 00,F 103 00E9: DECFSZ 00,F
119 02E4: GOTO 2D8 104 00EA: GOTO 0DE
120 02E5: BCF 0A.3 105 00EB: BCF 0A.3
121 02E6: BCF 0A.4 106 00EC: BCF 0A.4
122 02E7: GOTO 3B7 (RETURN) 107 00ED: GOTO 179 (RETURN)
123 .................... #use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,errors) 108 .................... #use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,errors)
124 .................... 109 ....................
125 .................... //NOTE: Must declare MASTER before SLAVE, i2c_isr_state() returns 0 -  
126 .................... // when MASTER is the most recent #use i2c -  
127 .................... //#use i2c(MASTER, sda=PIN_C1, scl=PIN_C0, stream=I2CM) -  
128 .................... #use i2c(SLAVE, Fast, sda=PIN_C4, scl=PIN_C3, force_hw, address=0xA0) -  
129 * -  
130 00AC: MOVF 4C,W -  
131 00AD: MOVWF 13 -  
132 00AE: BSF 14.4 -  
133 00AF: BCF 0C.3 -  
134 00B0: BSF 03.5 -  
135 00B1: BTFSC 14.0 -  
136 00B2: GOTO 0B1 -  
137 00B3: CLRF 78 -  
138 00B4: BCF 03.5 -  
139 00B5: BTFSC 14.4 -  
140 00B6: INCF 78,F -  
141 .................... -  
142 .................... -  
143 .................... -  
144 .................... #include <string.h> -  
145 .................... //////////////////////////////////////////////////////////////////////////// -  
146 .................... //// (C) Copyright 1996,2008 Custom Computer Services //// -  
147 .................... //// This source code may only be used by licensed users of the CCS C //// -  
148 .................... //// compiler. This source code may only be distributed to other //// -  
149 .................... //// licensed users of the CCS C compiler. No other use, reproduction //// -  
150 .................... //// or distribution is permitted without written permission. //// -  
151 .................... //// Derivative programs created using this software in object code //// -  
152 .................... //// form are not restricted in any way. //// -  
153 .................... //////////////////////////////////////////////////////////////////////////// -  
154 .................... -  
155 .................... #ifndef _STRING -  
156 .................... #define _STRING -  
157 .................... #include <stddef.h> -  
158 .................... /////////////////////////////////////////////////////////////////////////// -  
159 .................... //// (C) Copyright 1996,2003 Custom Computer Services //// -  
160 .................... //// This source code may only be used by licensed users of the CCS C //// -  
161 .................... //// compiler. This source code may only be distributed to other //// -  
162 .................... //// licensed users of the CCS C compiler. No other use, reproduction //// -  
163 .................... //// or distribution is permitted without written permission. //// -  
164 .................... //// Derivative programs created using this software in object code //// -  
165 .................... //// form are not restricted in any way. //// -  
166 .................... /////////////////////////////////////////////////////////////////////////// -  
167 .................... -  
168 .................... #ifndef _STDDEF -  
169 .................... -  
170 .................... #define _STDDEF -  
171 .................... -  
172 .................... #if sizeof(unsigned int8 *)==1 -  
173 .................... #define ptrdiff_t unsigned int8 -  
174 .................... #else -  
175 .................... #define ptrdiff_t unsigned int16 -  
176 .................... #endif -  
177 .................... -  
178 .................... #define size_t unsigned int8 -  
179 .................... #define wchar_t char -  
180 .................... #define NULL 0 -  
181 .................... -  
182 .................... #define offsetof(s,f) (offsetofbit(s,f)/8) -  
183 .................... -  
184 .................... #endif -  
185 .................... -  
186 .................... #include <ctype.h> -  
187 .................... //////////////////////////////////////////////////////////////////////////// -  
188 .................... //// (C) Copyright 1996,2003 Custom Computer Services //// -  
189 .................... //// This source code may only be used by licensed users of the CCS C //// -  
190 .................... //// compiler. This source code may only be distributed to other //// -  
191 .................... //// licensed users of the CCS C compiler. No other use, reproduction //// -  
192 .................... //// or distribution is permitted without written permission. //// -  
193 .................... //// Derivative programs created using this software in object code //// -  
194 .................... //// form are not restricted in any way. //// -  
195 .................... //////////////////////////////////////////////////////////////////////////// -  
196 .................... -  
197 .................... #ifndef _CTYPE -  
198 .................... #define _CTYPE -  
199 .................... -  
200 .................... #define islower(x) isamong(x,"abcdefghijklmnopqrstuvwxyz") -  
201 .................... #define isupper(x) isamong(x,"ABCDEFGHIJKLMNOPQRSTUVWXYZ") -  
202 .................... #define isalnum(x) isamong(x,"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz") -  
203 .................... #define isalpha(x) isamong(x,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz") -  
204 .................... #define isdigit(x) isamong(x,"0123456789") -  
205 .................... #define isspace(x) ((x)==' ') -  
206 .................... #define isxdigit(x) isamong(x,"0123456789ABCDEFabcdef") -  
207 .................... #define iscntrl(x) ((x)<' ') -  
208 .................... #define isprint(x) ((x)>=' ') -  
209 .................... #define isgraph(x) ((x)>' ') -  
210 .................... #define ispunct(x) (((x)>' ')&&!isalnum(x)) -  
211 .................... -  
212 .................... #endif -  
213 .................... -  
214 .................... -  
215 .................... -  
216 .................... -  
217 .................... -  
218 .................... ////////////////////////////////////////////// -  
219 .................... //// Uncomment the following define to //// -  
220 .................... //// allow some functions to use a //// -  
221 .................... //// quicker algorithm, but use more ROM //// -  
222 .................... //// //// -  
223 .................... //// #define FASTER_BUT_MORE_ROM //// -  
224 .................... ////////////////////////////////////////////// -  
225 .................... -  
226 .................... -  
227 .................... -  
228 .................... /*Copying functions*/ -  
229 .................... /* standard template: -  
230 .................... void *memmove(void *s1, void *s2, size_t n). -  
231 .................... Copies max of n characters safely (not following ending '\0') -  
232 .................... from s2 in s1; if s2 has less than n characters, appends 0 */ -  
233 .................... -  
234 .................... char *memmove(void *s1,char *s2,size_t n) -  
235 .................... { -  
236 .................... char *sc1; -  
237 .................... char *sc2; -  
238 .................... sc1=s1; -  
239 .................... sc2=s2; -  
240 .................... if(sc2<sc1 && sc1 <sc2 +n) -  
241 .................... for(sc1+=n,sc2+=n;0<n;--n) -  
242 .................... *--sc1=*--sc2; -  
243 .................... else -  
244 .................... for(;0<n;--n) -  
245 .................... *sc1++=*sc2++; -  
246 .................... return s1; -  
247 .................... } -  
248 .................... -  
249 .................... /* Standard template: char *strcpy(char *s1, const char *s2) -  
250 .................... copies the string s2 including the null character to s1. -  
251 .................... This is a compiler built in to handle the different address -  
252 .................... spaces */ -  
253 .................... -  
254 .................... #define strcopy strcpy -  
255 .................... -  
256 .................... /* standard template: -  
257 .................... char *strncpy(char *s1, const char *s2, size_t n). -  
258 .................... Copies max of n characters (not following ending '\0') -  
259 .................... from s2 in s1; if s2 has less than n characters, appends 0 */ -  
260 .................... -  
261 .................... char *strncpy(char *s1, char *s2, size_t n) -  
262 .................... { -  
263 .................... char *s; -  
264 .................... -  
265 .................... for (s = s1; n > 0 && *s2 != '\0'; n--) -  
266 * -  
267 0101: MOVF 63,W -  
268 0102: MOVWF 68 -  
269 0103: MOVF 62,W -  
270 0104: MOVWF 67 -  
271 0105: MOVF 66,F -  
272 0106: BTFSC 03.2 -  
273 0107: GOTO 130 -  
274 0108: MOVF 65,W -  
275 0109: MOVWF 7A -  
276 010A: MOVF 64,W -  
277 010B: MOVWF 04 -  
278 010C: BCF 03.7 -  
279 010D: BTFSC 7A.0 -  
280 010E: BSF 03.7 -  
281 010F: MOVF 00,F -  
282 0110: BTFSC 03.2 -  
283 0111: GOTO 130 -  
284 .................... *s++ = *s2++; -  
285 0112: MOVF 68,W -  
286 0113: MOVWF 7A -  
287 0114: MOVF 67,W -  
288 0115: INCF 67,F -  
289 0116: BTFSC 03.2 -  
290 0117: INCF 68,F -  
291 0118: MOVWF 69 -  
292 0119: MOVF 7A,W -  
293 011A: MOVWF 6A -  
294 011B: MOVF 65,W -  
295 011C: MOVWF 7A -  
296 011D: MOVF 64,W -  
297 011E: INCF 64,F -  
298 011F: BTFSC 03.2 -  
299 0120: INCF 65,F -  
300 0121: MOVWF 04 -  
301 0122: BCF 03.7 -  
302 0123: BTFSC 7A.0 -  
303 0124: BSF 03.7 -  
304 0125: MOVF 00,W -  
305 0126: MOVWF 6B -  
306 0127: MOVF 69,W -  
307 0128: MOVWF 04 -  
308 0129: BCF 03.7 -  
309 012A: BTFSC 6A.0 -  
310 012B: BSF 03.7 -  
311 012C: MOVF 6B,W -  
312 012D: MOVWF 00 -  
313 012E: DECF 66,F -  
314 012F: GOTO 105 -  
315 .................... for (; n > 0; n--) -  
316 0130: MOVF 66,F -  
317 0131: BTFSC 03.2 -  
318 0132: GOTO 140 -  
319 .................... *s++ = '\0'; -  
320 0133: MOVF 68,W -  
321 0134: MOVWF 7A -  
322 0135: MOVF 67,W -  
323 0136: INCF 67,F -  
324 0137: BTFSC 03.2 -  
325 0138: INCF 68,F -  
326 0139: MOVWF 04 -  
327 013A: BCF 03.7 -  
328 013B: BTFSC 7A.0 -  
329 013C: BSF 03.7 -  
330 013D: CLRF 00 -  
331 013E: DECF 66,F -  
332 013F: GOTO 130 -  
333 .................... -  
334 .................... return(s1); -  
335 0140: MOVF 62,W -  
336 0141: MOVWF 78 -  
337 0142: MOVF 63,W -  
338 0143: MOVWF 79 -  
339 .................... } -  
340 0144: RETURN -  
341 .................... /***********************************************************/ -  
342 .................... -  
343 .................... /*concatenation functions*/ -  
344 .................... /* standard template: char *strcat(char *s1, const char *s2) -  
345 .................... appends s2 to s1*/ -  
346 .................... -  
347 .................... char *strcat(char *s1, char *s2) -  
348 .................... { -  
349 .................... char *s; -  
350 .................... -  
351 .................... for (s = s1; *s != '\0'; ++s); -  
352 .................... while(*s2 != '\0') -  
353 .................... { -  
354 .................... *s = *s2; -  
355 .................... ++s; -  
356 .................... ++s2; -  
357 .................... } -  
358 .................... -  
359 .................... *s = '\0'; -  
360 .................... return(s1); -  
361 .................... } -  
362 .................... /* standard template: char *strncat(char *s1, char *s2,size_t n) -  
363 .................... appends not more than n characters from s2 to s1*/ -  
364 .................... -  
365 .................... char *strncat(char *s1, char *s2, size_t n) -  
366 .................... { -  
367 .................... char *s; -  
368 .................... -  
369 .................... for (s = s1; *s != '\0'; ++s); -  
370 .................... while(*s2 != '\0' && 0<n) -  
371 .................... { -  
372 .................... *s = *s2; -  
373 .................... ++s; -  
374 .................... ++s2; -  
375 .................... --n; -  
376 .................... } -  
377 .................... -  
378 .................... *s = '\0'; -  
379 .................... return(s1); -  
380 .................... } -  
381 .................... -  
382 .................... /***********************************************************/ -  
383 .................... -  
384 .................... -  
385 .................... /*comparison functions*/ -  
386 .................... /* standard template: signed int memcmp(void *s1, void *s2). -  
387 .................... Compares s1 & s2; returns -1 if s1<s2, 0 if s1=s2, 1 if s1>s2 */ -  
388 .................... -  
389 .................... signed int8 memcmp(void * s1,char *s2,size_t n) -  
390 .................... { -  
391 .................... char *su1, *su2; -  
392 .................... for(su1=s1, su2=s2; 0<n; ++su1, ++su2, --n) -  
393 .................... { -  
394 .................... if(*su1!=*su2) -  
395 .................... return ((*su1<*su2)?-1:+1); -  
396 .................... } -  
397 .................... return 0; -  
398 .................... } -  
399 .................... -  
400 .................... /* standard template: int strcmp(const char *s1, const char *s2). -  
401 .................... Compares s1 & s2; returns -1 if s1<s2, 0 if s1=s2, 1 if s1>s2 */ -  
402 .................... -  
403 .................... signed int8 strcmp(char *s1, char *s2) -  
404 .................... { -  
405 .................... for (; *s1 == *s2; s1++, s2++) -  
406 .................... if (*s1 == '\0') -  
407 .................... return(0); -  
408 .................... return((*s1 < *s2) ? -1: 1); -  
409 .................... } -  
410 .................... /* standard template: int strcoll(const char *s1, const char *s2). -  
411 .................... Compares s1 & s2; returns -1 if s1<s2, 0 if s1=s2, 1 if s1>s2 */ -  
412 .................... -  
413 .................... signed int8 strcoll(char *s1, char *s2) -  
414 .................... { -  
415 .................... for (; *s1 == *s2; s1++, s2++) -  
416 .................... if (*s1 == '\0') -  
417 .................... return(0); -  
418 .................... return((*s1 < *s2) ? -1: 1); -  
419 .................... } -  
420 .................... -  
421 .................... /* standard template: -  
422 .................... int strncmp(const char *s1, const char *s2, size_t n). -  
423 .................... Compares max of n characters (not following 0) from s1 to s2; -  
424 .................... returns same as strcmp */ -  
425 .................... -  
426 .................... signed int8 strncmp(char *s1, char *s2, size_t n) -  
427 .................... { -  
428 .................... for (; n > 0; s1++, s2++, n--) -  
429 .................... if (*s1 != *s2) -  
430 .................... return((*s1 <*s2) ? -1: 1); -  
431 .................... else if (*s1 == '\0') -  
432 .................... return(0); -  
433 .................... return(0); -  
434 .................... } -  
435 .................... /* standard template: -  
436 .................... int strxfrm(const char *s1, const char *s2, size_t n). -  
437 .................... transforms maximum of n characters from s2 and places them into s1*/ -  
438 .................... size_t strxfrm(char *s1, char *s2, size_t n) -  
439 .................... { -  
440 .................... char *s; -  
441 .................... unsigned int8 n1; -  
442 .................... n1=n; -  
443 .................... for (s = s1; n > 0 && *s2 != '\0'; n--) -  
444 .................... *s++ = *s2++; -  
445 .................... for (; n > 0; n--) -  
446 .................... *s++ = '\0'; -  
447 .................... -  
448 .................... return(n1); -  
449 .................... } -  
450 .................... -  
451 .................... -  
452 .................... -  
453 .................... -  
454 .................... -  
455 .................... /***********************************************************/ -  
456 .................... /*Search functions*/ -  
457 .................... /* standard template: void *memchr(const char *s, int c). -  
458 .................... Finds first occurrence of c in n characters of s */ -  
459 .................... -  
460 .................... char *memchr(void *s,unsigned int8 c,size_t n) -  
461 .................... { -  
462 .................... char uc; -  
463 .................... char *su; -  
464 .................... uc=c; -  
465 .................... for(su=s;0<n;++su,--n) -  
466 .................... if(*su==uc) -  
467 .................... return su; -  
468 .................... return NULL; -  
469 .................... } -  
470 .................... -  
471 .................... /* standard template: char *strchr(const char *s, int c). -  
472 .................... Finds first occurrence of c in s */ -  
473 .................... -  
474 .................... char *strchr(char *s, unsigned int8 c) -  
475 .................... { -  
476 .................... for (; *s != c; s++) -  
477 .................... if (*s == '\0') -  
478 .................... return(0); -  
479 .................... return(s); -  
480 .................... } -  
481 .................... /* standard template: -  
482 .................... size_t strcspn(const char *s1, const char *s2). -  
483 .................... Computes length of max initial segment of s1 that -  
484 .................... consists entirely of characters NOT from s2*/ -  
485 .................... -  
486 .................... unsigned int8 strcspn(char *s1, char *s2) -  
487 .................... { -  
488 .................... char *sc1, *sc2; -  
489 .................... -  
490 .................... for (sc1 = s1; *sc1 != 0; sc1++) -  
491 .................... for (sc2 = s2; *sc2 != 0; sc2++) -  
492 .................... if (*sc1 == *sc2) -  
493 .................... return(sc1 - s1); -  
494 .................... return(sc1 - s1); -  
495 .................... } -  
496 .................... /* standard template: -  
497 .................... char *strpbrk(const char *s1, const char *s2). -  
498 .................... Locates first occurence of any character from s2 in s1; -  
499 .................... returns s1 if s2 is empty string */ -  
500 .................... -  
501 .................... char *strpbrk(char *s1, char *s2) -  
502 .................... { -  
503 .................... char *sc1, *sc2; -  
504 .................... -  
505 .................... for (sc1 = s1; *sc1 != 0; sc1++) -  
506 .................... for (sc2 = s2; *sc2 != 0; sc2++) -  
507 .................... if (*sc1 == *sc2) -  
508 .................... return(sc1); -  
509 .................... return(0); -  
510 .................... } -  
511 .................... -  
512 .................... -  
513 .................... /* standard template: char *strrchr(const char *s, int c). -  
514 .................... Finds last occurrence of c in s */ -  
515 .................... -  
516 .................... char *strrchr(char *s, unsigned int8 c) -  
517 .................... { -  
518 .................... char *p; -  
519 .................... -  
520 .................... for (p = 0; ; s++) -  
521 .................... { -  
522 .................... if (*s == c) -  
523 .................... p = s; -  
524 .................... if (*s == '\0') -  
525 .................... return(p); -  
526 .................... } -  
527 .................... } -  
528 .................... /* computes length of max initial segment of s1 consisting -  
529 .................... entirely of characters from s2 */ -  
530 .................... -  
531 .................... unsigned int8 strspn(char *s1, char *s2) -  
532 .................... { -  
533 .................... char *sc1, *sc2; -  
534 .................... -  
535 .................... for (sc1 = s1; *sc1 != 0; sc1++) -  
536 .................... for (sc2 = s2; ; sc2++) -  
537 .................... if (*sc2 == '\0') -  
538 .................... return(sc1 - s1); -  
539 .................... else if (*sc1 == *sc2) -  
540 .................... break; -  
541 .................... return(sc1 - s1); -  
542 .................... } -  
543 .................... /* standard template: -  
544 .................... char *strstr(const char *s1, const char *s2); -  
545 .................... Locates first occurence of character sequence s2 in s1; -  
546 .................... returns 0 if s2 is empty string -  
547 .................... -  
548 .................... Uncomment #define FASTER_BUT_MORE_ROM at the top of the -  
549 .................... file to use the faster algorithm */ -  
550 .................... char *strstr(char *s1, char *s2) -  
551 .................... { -  
552 .................... char *s, *t; -  
553 .................... -  
554 .................... #ifdef FASTER_BUT_MORE_ROM -  
555 .................... if (*s2 == '\0') -  
556 .................... return(s1); -  
557 .................... #endif -  
558 .................... -  
559 .................... while (*s1) -  
560 .................... { -  
561 .................... for(s = s1, t = s2; *t && (*s == *t); ++s, ++t); -  
562 .................... -  
563 .................... if (*t == '\0') -  
564 .................... return s1; -  
565 .................... ++s1; -  
566 .................... #ifdef FASTER_BUT_MORE_ROM -  
567 .................... while(*s1 != '\0' && *s1 != *s2) -  
568 .................... ++s1; -  
569 .................... #endif -  
570 .................... } -  
571 .................... return 0; -  
572 .................... } -  
573 .................... 110 ....................
574 .................... /* standard template: char *strtok(char *s1, const char *s2). -  
575 .................... 111 ....................
576 .................... Finds next token in s1 delimited by a character from separator -  
577 .................... string s2 (which can be different from call to call). First call -  
578 .................... starts at beginning of s1 searching for first character NOT -  
579 .................... contained in s2; returns 0 if none is found. -  
580 .................... If one is found, it is the start of first token (return value). -  
581 .................... Function then searches from there for a character contained in s2. -  
582 .................... If none is found, current token extends to end of s1, and subsequent -  
583 .................... searches for a token will return 0. If one is found, it is -  
584 .................... overwritten by '\0', which terminates current token. Function saves -  
585 .................... pointer to following character from which next search will start. -  
586 .................... Each subsequent call, with 0 as first argument, starts searching 112 .................... #use i2c(SLAVE, Fast, sda=PIN_C4, scl=PIN_C3, force_hw, address=0xA2)
587 .................... from saved pointer */ -  
588 .................... -  
589 .................... char *strtok(char *s1, char *s2) -  
590 .................... { -  
591 .................... char *beg, *end; -  
592 .................... static char *save; -  
593 * 113 *
594 0366: CLRF 29 114 0031: MOVF 13,W
595 0367: CLRF 2A 115 0032: MOVF 3F,W
596 .................... -  
597 .................... beg = (s1)? s1: save; -  
598 .................... beg += strspn(beg, s2); -  
599 .................... if (*beg == '\0') -  
600 .................... { -  
601 .................... *save = ' '; -  
602 .................... return(0); -  
603 .................... } -  
604 .................... end = strpbrk(beg, s2); -  
605 .................... if (*end != '\0') -  
606 .................... { -  
607 .................... *end = '\0'; -  
608 .................... end++; -  
609 .................... } -  
610 .................... save = end; -  
611 .................... return(beg); -  
612 .................... } -  
613 .................... -  
614 .................... /*****************************************************************/ -  
615 .................... /*Miscellaneous functions*/ -  
616 .................... /* standard template -  
617 .................... maps error number in errnum to an error message string -  
618 .................... Returns: Pointer to string -  
619 .................... */ -  
620 .................... #ifdef _ERRNO -  
621 .................... char * strerror(unsigned int8 errnum) -  
622 .................... { -  
623 .................... char s[15]; -  
624 .................... switch( errnum) -  
625 .................... { -  
626 .................... case 0: -  
627 .................... strcpy(s,"no errors"); -  
628 .................... return s; -  
629 .................... case EDOM : -  
630 .................... strcpy(s,"domain error"); -  
631 .................... return s; -  
632 .................... case ERANGE: -  
633 .................... strcpy(s,"range error"); -  
634 .................... return s; -  
635 .................... } -  
636 .................... } -  
637 .................... #ENDIF -  
638 .................... /* standard template: size_t strlen(const char *s). -  
639 .................... Computes length of s1 (preceding terminating 0) */ -  
640 .................... -  
641 .................... unsigned int8 strlen(char *s) -  
642 .................... { -  
643 .................... char *sc; -  
644 .................... -  
645 .................... for (sc = s; *sc != 0; sc++); -  
646 .................... return(sc - s); -  
647 .................... } 116 0033: MOVWF 13
648 .................... 117 0034: BSF 14.4
649 .................... /* standard template: size_t stricmp(const char *s1, const char *s2). -  
650 .................... Compares s1 to s2 ignoring case (upper vs. lower) */ -  
651 .................... 118 0035: BCF 0C.3
652 .................... signed int8 stricmp(char *s1, char *s2) -  
653 .................... { -  
654 .................... for(; *s1==*s2||(isalpha(*s1)&&isalpha(*s2)&&(*s1==*s2+32||*s2==*s1+32)); -  
655 .................... s1++, s2++) -  
656 .................... if (*s1 == '\0') -  
657 .................... return(0); -  
658 .................... return((*s1 < *s2) ? -1: 1); -  
659 .................... } -  
660 .................... 119 0036: BSF 03.5
661 .................... 120 0037: BTFSC 14.0
662 .................... /* standard template: char *strlwr(char *s). -  
663 .................... Replaces uppercase letters by lowercase; -  
664 .................... returns pointer to new string s */ -  
665 .................... 121 0038: GOTO 037
666 .................... char *strlwr(char *s) -  
667 .................... { 122 0039: CLRF 78
668 .................... char *p; -  
669 .................... -  
670 .................... for (p = s; *p != '\0'; p++) -  
671 .................... if (*p >= 'A' && *p <='Z') -  
672 .................... *p += 'a' - 'A'; -  
673 .................... return(s); -  
674 .................... } -  
675 .................... 123 003A: BCF 03.5
676 .................... 124 003B: BTFSC 14.4
677 .................... /************************************************************/ -  
678 .................... 125 003C: INCF 78,F
679 .................... 126 003D: RETURN
680 .................... #endif -  
681 .................... 127 ....................
-   128 .................... //#include <string.h>
682 .................... 129 ....................
683 .................... #define LED PIN_E1 130 .................... #define LED PIN_E1
684 .................... #define CE PIN_E2 131 .................... #define CE PIN_E2
685 .................... 132 ....................
686 .................... #define SEL0 PIN_E0 // external counter division ratio 133 .................... #define SEL0 PIN_E0 // external counter division ratio
Line 689... Line 136...
689 .................... #define CLKI PIN_C0 // internal counter input 136 .................... #define CLKI PIN_C0 // internal counter input
690 .................... #define BEEP PIN_C3 // buzzer 137 .................... #define BEEP PIN_C3 // buzzer
691 .................... 138 ....................
692 .................... unsigned int32 count; 139 .................... unsigned int32 count;
693 .................... 140 ....................
694 .................... 141 .................... const int8 buf_len=8;
695 .................... int8 buffer[0x10]; // I2C buffer 142 .................... int8 buffer[buf_len]; // I2C buffer
696 .................... int8 address; 143 .................... int8 address=0;
697 .................... 144 ....................
698 .................... unsigned int16 of=0; // count of overflow 145 .................... unsigned int16 of=0; // count of overflow
699 .................... 146 ....................
700 .................... const char cmd[40]={0xB5, 0x62, 0x06, 0x31, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x80, 0x84, 0x1E, 0x00, 0xE0, 0xC8, 0x10, 0x00, 0x40, 0x42, 0x0F, 0x00, 0xA0, 0x86, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF7, 0x00, 0x00, 0x00, 0x12, 0x03}; 147 .................... const char cmd[40]={0xB5, 0x62, 0x06, 0x31, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x80, 0x84, 0x1E, 0x00, 0xE0, 0xC8, 0x10, 0x00, 0x40, 0x42, 0x0F, 0x00, 0xA0, 0x86, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF7, 0x00, 0x00, 0x00, 0x12, 0x03};
701 .................... 148 ....................
-   149 ....................
702 .................... #INT_SSP 150 .................... #INT_SSP
703 .................... void ssp_interupt () 151 .................... void ssp_interupt ()
704 .................... { 152 .................... {
705 .................... BYTE incoming, state; 153 .................... BYTE incoming, state;
706 .................... 154 ....................
707 .................... state = i2c_isr_state(); 155 .................... state = i2c_isr_state();
708 * -  
709 006D: BSF 03.5 156 003E: BSF 03.5
710 006E: BTFSC 14.5 157 003F: BTFSC 14.5
711 006F: GOTO 078 158 0040: GOTO 049
712 0070: BCF 03.5 159 0041: BCF 03.5
713 0071: CLRF 42 160 0042: CLRF 38
714 0072: BSF 03.5 161 0043: BSF 03.5
715 0073: BTFSS 14.2 162 0044: BTFSS 14.2
716 0074: GOTO 078 163 0045: GOTO 049
717 0075: BCF 03.5 164 0046: BCF 03.5
718 0076: BSF 42.7 165 0047: BSF 38.7
719 0077: BSF 03.5 166 0048: BSF 03.5
720 0078: BCF 03.5 167 0049: BCF 03.5
721 0079: MOVF 42,W 168 004A: MOVF 38,W
722 007A: INCF 42,F 169 004B: INCF 38,F
723 007B: MOVWF 4A 170 004C: MOVWF 3D
724 .................... -  
725 .................... if(state < 0x80) //Master is sending data 171 .................... if(state < 0x80) //Master is sending data
726 007C: MOVF 4A,W 172 004D: MOVF 3D,W
727 007D: SUBLW 7F 173 004E: SUBLW 7F
728 007E: BTFSS 03.0 174 004F: BTFSS 03.0
729 007F: GOTO 0A0 175 0050: GOTO 069
730 .................... { 176 .................... {
731 .................... incoming = i2c_read(); 177 .................... incoming = i2c_read();
732 0080: BCF 14.6 178 0051: BCF 14.6
733 0081: BTFSS 0C.3 179 0052: BTFSS 0C.3
734 0082: GOTO 081 180 0053: GOTO 052
735 0083: MOVF 13,W 181 0054: MOVF 13,W
736 0084: BSF 14.4 182 0055: BSF 14.4
737 0085: MOVWF 49 183 0056: MOVWF 3C
738 .................... if(state == 1) //First received byte is address 184 .................... if(state == 1) //First received byte is address
739 0086: DECFSZ 4A,W 185 0057: DECFSZ 3D,W
740 0087: GOTO 096 186 0058: GOTO 05F
741 .................... { 187 .................... {
742 .................... address = incoming; 188 .................... address = incoming;
743 0088: MOVF 49,W 189 0059: MOVF 3C,W
744 0089: MOVWF 3F 190 005A: MOVWF 35
745 .................... if (incoming == 2) 191 .................... if (incoming == 2)
746 008A: MOVF 49,W 192 005B: MOVF 3C,W
747 008B: SUBLW 02 193 005C: SUBLW 02
748 008C: BTFSS 03.2 194 005D: BTFSS 03.2
749 008D: GOTO 096 195 005E: GOTO 05F
750 .................... { 196 .................... {
751 .................... buffer[0]=make8(count,0); 197 .................... /* buffer[0]=make8(anemo,0);
752 008E: MOVF 2B,W -  
753 008F: MOVWF 2F -  
754 .................... buffer[1]=make8(count,1); 198 .................... buffer[1]=make8(anemo,1);
755 0090: MOVF 2C,W -  
756 0091: MOVWF 30 -  
757 .................... buffer[2]=make8(count,2); 199 .................... buffer[2]=make8(rain,0);
758 0092: MOVF 2D,W -  
759 0093: MOVWF 31 -  
760 .................... buffer[3]=make8(count,3); 200 .................... buffer[3]=make8(rain,1);
761 0094: MOVF 2E,W -  
762 0095: MOVWF 32 -  
763 .................... } 201 .................... */ }
764 .................... } 202 .................... }
765 .................... if(state == 2) //Second received byte is data 203 .................... if(state == 2) //Second received byte is data
766 0096: MOVF 4A,W 204 005F: MOVF 3D,W
767 0097: SUBLW 02 205 0060: SUBLW 02
768 0098: BTFSS 03.2 206 0061: BTFSS 03.2
769 0099: GOTO 0A0 207 0062: GOTO 069
770 .................... buffer[address] = incoming; 208 .................... buffer[address] = incoming;
771 009A: MOVLW 2F 209 0063: MOVLW 2D
772 009B: ADDWF 3F,W 210 0064: ADDWF 35,W
773 009C: MOVWF 04 211 0065: MOVWF 04
774 009D: BCF 03.7 212 0066: BCF 03.7
775 009E: MOVF 49,W 213 0067: MOVF 3C,W
776 009F: MOVWF 00 214 0068: MOVWF 00
777 .................... -  
778 .................... -  
779 .................... } 215 .................... }
780 .................... if(state == 0x80) //Master is requesting data 216 .................... if(state == 0x80) //Master is requesting data
781 00A0: MOVF 4A,W 217 0069: MOVF 3D,W
782 00A1: SUBLW 80 218 006A: SUBLW 80
783 00A2: BTFSS 03.2 219 006B: BTFSS 03.2
784 00A3: GOTO 0B7 220 006C: GOTO 085
785 .................... { 221 .................... {
786 .................... i2c_write(buffer[address]); 222 .................... if(address <= buf_len) i2c_write(buffer[address]);
-   223 006D: MOVF 35,W
-   224 006E: SUBLW 08
-   225 006F: BTFSS 03.0
-   226 0070: GOTO 07A
787 00A4: MOVLW 2F 227 0071: MOVLW 2D
788 00A5: ADDWF 3F,W 228 0072: ADDWF 35,W
789 00A6: MOVWF 04 229 0073: MOVWF 04
790 00A7: BCF 03.7 230 0074: BCF 03.7
791 00A8: MOVF 00,W 231 0075: MOVF 00,W
-   232 0076: MOVWF 3E
-   233 0077: MOVWF 3F
-   234 0078: CALL 031
-   235 .................... else i2c_write(ID[address - buf_len]);
-   236 0079: GOTO 085
-   237 007A: MOVLW 08
-   238 007B: SUBWF 35,W
-   239 007C: ADDWF 00,W
792 00A9: MOVWF 4B 240 007D: MOVWF 04
-   241 007E: BCF 03.7
-   242 007F: BTFSC 56.0
-   243 0080: BSF 03.7
793 00AA: MOVF 4B,W 244 0081: MOVF 00,W
-   245 0082: MOVWF 3E
794 00AB: MOVWF 4C 246 0083: MOVWF 3F
-   247 0084: CALL 031
795 .................... } 248 .................... }
796 .................... } 249 .................... }
797 .................... 250 ....................
798 .................... 251 ....................
799 * -  
800 00B7: BCF 0C.3 -  
801 00B8: BCF 0A.3 -  
802 00B9: BCF 0A.4 252 ....................
803 00BA: GOTO 027 -  
804 .................... #int_EXT // Interrupt from 1PPS 253 .................... /*#int_EXT // Interrupt from 1PPS
805 .................... void EXT_isr(void) 254 .................... void EXT_isr(void)
806 .................... { 255 .................... {
807 .................... unsigned int16 countH; 256 .................... unsigned int16 countH;
808 .................... unsigned int8 countL; 257 .................... unsigned int8 countL;
809 .................... char countS[10], a[4], b[4], c[4]; // strings for printing results 258 .................... char countS[10], a[4], b[4], c[4]; // strings for printing results
810 .................... 259 ....................
811 .................... countL=0; 260 .................... countL=0;
812 * -  
813 0145: CLRF 4B -  
814 .................... countH=get_timer1(); // read internal counter 261 .................... countH=get_timer1(); // read internal counter
815 0146: MOVF 0F,W -  
816 0147: MOVWF 7A -  
817 0148: MOVF 0E,W -  
818 0149: MOVWF 77 -  
819 014A: MOVF 0F,W -  
820 014B: SUBWF 7A,W -  
821 014C: BTFSS 03.2 -  
822 014D: GOTO 146 -  
823 014E: MOVF 77,W -  
824 014F: MOVWF 49 -  
825 0150: MOVF 7A,W -  
826 0151: MOVWF 4A -  
827 .................... output_low(SEL0); 262 .................... output_low(SEL0);
828 0152: BSF 03.5 -  
829 0153: BCF 09.0 -  
830 0154: BCF 03.5 -  
831 0155: BCF 09.0 -  
832 .................... output_low(SEL1); 263 .................... output_low(SEL1);
833 0156: BSF 03.5 -  
834 0157: BCF 09.1 -  
835 0158: BCF 03.5 -  
836 0159: BCF 09.1 -  
837 .................... countL=input(CLKI); // read bit 0 of external counter 264 .................... countL=input(CLKI); // read bit 0 of external counter
838 015A: BSF 28.0 -  
839 015B: MOVF 28,W -  
840 015C: BSF 03.5 -  
841 015D: MOVWF 07 -  
842 015E: BCF 03.5 -  
843 015F: CLRF 4B -  
844 0160: BTFSC 07.0 -  
845 0161: INCF 4B,F -  
846 .................... output_high(SEL0); 265 .................... output_high(SEL0);
847 0162: BSF 03.5 -  
848 0163: BCF 09.0 -  
849 0164: BCF 03.5 -  
850 0165: BSF 09.0 -  
851 .................... output_low(SEL1); 266 .................... output_low(SEL1);
852 0166: BSF 03.5 -  
853 0167: BCF 09.1 -  
854 0168: BCF 03.5 -  
855 0169: BCF 09.1 -  
856 .................... countL|=input(CLKI)<<1; // read bit 1 of external counter 267 .................... countL|=input(CLKI)<<1; // read bit 1 of external counter
857 016A: BSF 28.0 -  
858 016B: MOVF 28,W -  
859 016C: BSF 03.5 -  
860 016D: MOVWF 07 -  
861 016E: MOVLW 00 -  
862 016F: BCF 03.5 -  
863 0170: BTFSC 07.0 -  
864 0171: MOVLW 01 -  
865 0172: MOVWF 77 -  
866 0173: BCF 03.0 -  
867 0174: RLF 77,F -  
868 0175: MOVF 77,W -  
869 0176: IORWF 4B,F -  
870 .................... output_low(SEL0); 268 .................... output_low(SEL0);
871 0177: BSF 03.5 -  
872 0178: BCF 09.0 -  
873 0179: BCF 03.5 -  
874 017A: BCF 09.0 -  
875 .................... output_high(SEL1); 269 .................... output_high(SEL1);
876 017B: BSF 03.5 -  
877 017C: BCF 09.1 -  
878 017D: BCF 03.5 -  
879 017E: BSF 09.1 -  
880 .................... countL|=input(CLKI)<<2; // read bit 2 of external counter 270 .................... countL|=input(CLKI)<<2; // read bit 2 of external counter
881 017F: BSF 28.0 -  
882 0180: MOVF 28,W -  
883 0181: BSF 03.5 -  
884 0182: MOVWF 07 -  
885 0183: MOVLW 00 -  
886 0184: BCF 03.5 -  
887 0185: BTFSC 07.0 -  
888 0186: MOVLW 01 -  
889 0187: MOVWF 77 -  
890 0188: RLF 77,F -  
891 0189: RLF 77,F -  
892 018A: MOVLW FC -  
893 018B: ANDWF 77,F -  
894 018C: MOVF 77,W -  
895 018D: IORWF 4B,F -  
896 .................... output_high(SEL0); 271 .................... output_high(SEL0);
897 018E: BSF 03.5 -  
898 018F: BCF 09.0 -  
899 0190: BCF 03.5 -  
900 0191: BSF 09.0 -  
901 .................... output_high(SEL1); 272 .................... output_high(SEL1);
902 0192: BSF 03.5 -  
903 0193: BCF 09.1 -  
904 0194: BCF 03.5 -  
905 0195: BSF 09.1 -  
906 .................... countL|=input(CLKI)<<3; // read bit 3 of external counter 273 .................... countL|=input(CLKI)<<3; // read bit 3 of external counter
907 0196: BSF 28.0 -  
908 0197: MOVF 28,W -  
909 0198: BSF 03.5 -  
910 0199: MOVWF 07 -  
911 019A: MOVLW 00 -  
912 019B: BCF 03.5 -  
913 019C: BTFSC 07.0 -  
914 019D: MOVLW 01 -  
915 019E: MOVWF 77 -  
916 019F: RLF 77,F -  
917 01A0: RLF 77,F -  
918 01A1: RLF 77,F -  
919 01A2: MOVLW F8 -  
920 01A3: ANDWF 77,F -  
921 01A4: MOVF 77,W -  
922 01A5: IORWF 4B,F -  
923 .................... 274 ....................
924 .................... output_low(MR); // External counter Master Reset 275 .................... output_low(MR); // External counter Master Reset
925 01A6: BSF 03.5 -  
926 01A7: BCF 09.2 -  
927 01A8: BCF 03.5 -  
928 01A9: BCF 09.2 -  
929 .................... output_high(MR); 276 .................... output_high(MR);
930 01AA: BSF 03.5 -  
931 01AB: BCF 09.2 -  
932 01AC: BCF 03.5 -  
933 01AD: BSF 09.2 -  
934 .................... 277 ....................
935 .................... set_timer1(0); // Internal counter reset 278 .................... set_timer1(0); // Internal counter reset
936 01AE: CLRF 0F -  
937 01AF: CLRF 0E -  
938 .................... 279 ....................
939 .................... count=((unsigned int32)of<<20)+((unsigned int32)countH<<4)+(unsigned int32)countL; // concatenate 280 .................... count=((unsigned int32)of<<20)+((unsigned int32)countH<<4)+(unsigned int32)countL; // concatenate
940 01B0: CLRF 65 -  
941 01B1: CLRF 64 -  
942 01B2: MOVF 41,W -  
943 01B3: MOVWF 63 -  
944 01B4: MOVF 40,W -  
945 01B5: MOVWF 62 -  
946 01B6: MOVF 41,W -  
947 01B7: MOVWF 65 -  
948 01B8: MOVF 40,W -  
949 01B9: MOVWF 64 -  
950 01BA: CLRF 62 -  
951 01BB: CLRF 63 -  
952 01BC: RLF 64,F -  
953 01BD: RLF 65,F -  
954 01BE: RLF 64,F -  
955 01BF: RLF 65,F -  
956 01C0: RLF 64,F -  
957 01C1: RLF 65,F -  
958 01C2: RLF 64,F -  
959 01C3: RLF 65,F -  
960 01C4: MOVLW F0 -  
961 01C5: ANDWF 64,F -  
962 01C6: CLRF 6A -  
963 01C7: CLRF 69 -  
964 01C8: RLF 49,W -  
965 01C9: MOVWF 77 -  
966 01CA: RLF 4A,W -  
967 01CB: MOVWF 78 -  
968 01CC: RLF 69,W -  
969 01CD: MOVWF 79 -  
970 01CE: RLF 6A,W -  
971 01CF: MOVWF 7A -  
972 01D0: RLF 77,F -  
973 01D1: RLF 78,F -  
974 01D2: RLF 79,F -  
975 01D3: RLF 7A,F -  
976 01D4: RLF 77,F -  
977 01D5: RLF 78,F -  
978 01D6: RLF 79,F -  
979 01D7: RLF 7A,F -  
980 01D8: RLF 77,F -  
981 01D9: RLF 78,F -  
982 01DA: RLF 79,F -  
983 01DB: RLF 7A,F -  
984 01DC: MOVLW F0 -  
985 01DD: ANDWF 77,F -  
986 01DE: MOVF 77,W -  
987 01DF: ADDWF 62,F -  
988 01E0: MOVF 78,W -  
989 01E1: BTFSC 03.0 -  
990 01E2: INCFSZ 78,W -  
991 01E3: ADDWF 63,F -  
992 01E4: MOVF 79,W -  
993 01E5: BTFSC 03.0 -  
994 01E6: INCFSZ 79,W -  
995 01E7: ADDWF 64,F -  
996 01E8: MOVF 7A,W -  
997 01E9: BTFSC 03.0 -  
998 01EA: INCFSZ 7A,W -  
999 01EB: ADDWF 65,F -  
1000 01EC: CLRF 78 -  
1001 01ED: CLRF 79 -  
1002 01EE: CLRF 7A -  
1003 01EF: MOVF 4B,W -  
1004 01F0: ADDWF 62,W -  
1005 01F1: MOVWF 2B -  
1006 01F2: MOVF 63,W -  
1007 01F3: MOVWF 2C -  
1008 01F4: MOVF 78,W -  
1009 01F5: BTFSC 03.0 -  
1010 01F6: INCFSZ 78,W -  
1011 01F7: ADDWF 2C,F -  
1012 01F8: MOVF 64,W -  
1013 01F9: MOVWF 2D -  
1014 01FA: MOVF 79,W -  
1015 01FB: BTFSC 03.0 -  
1016 01FC: INCFSZ 79,W -  
1017 01FD: ADDWF 2D,F -  
1018 01FE: MOVF 65,W -  
1019 01FF: MOVWF 2E -  
1020 0200: MOVF 7A,W -  
1021 0201: BTFSC 03.0 -  
1022 0202: INCFSZ 7A,W -  
1023 0203: ADDWF 2E,F -  
1024 .................... 281 ....................
1025 .................... sprintf(countS,"%09Lu", count); // engeneering values conversion 282 .................... sprintf(countS,"%09Lu", count); // engeneering values conversion
1026 0204: CLRF 44 -  
1027 0205: MOVLW 4C -  
1028 0206: MOVWF 43 -  
1029 0207: MOVLW 49 -  
1030 0208: MOVWF 04 -  
1031 0209: MOVF 2E,W -  
1032 020A: MOVWF 65 -  
1033 020B: MOVF 2D,W -  
1034 020C: MOVWF 64 -  
1035 020D: MOVF 2C,W -  
1036 020E: MOVWF 63 -  
1037 020F: MOVF 2B,W -  
1038 0210: MOVWF 62 -  
1039 .................... strncpy(a, countS, 3); a[3]='\0'; 283 .................... strncpy(a, countS, 3); a[3]='\0';
1040 * -  
1041 027A: CLRF 63 -  
1042 027B: MOVLW 56 -  
1043 027C: MOVWF 62 -  
1044 027D: CLRF 65 -  
1045 027E: MOVLW 4C -  
1046 027F: MOVWF 64 -  
1047 0280: MOVLW 03 -  
1048 0281: MOVWF 66 -  
1049 0282: CALL 101 -  
1050 0283: CLRF 59 -  
1051 .................... strncpy(b, &countS[3], 3); b[3]='\0'; 284 .................... strncpy(b, &countS[3], 3); b[3]='\0';
1052 0284: CLRF 63 -  
1053 0285: MOVLW 5A -  
1054 0286: MOVWF 62 -  
1055 0287: CLRF 65 -  
1056 0288: MOVLW 4F -  
1057 0289: MOVWF 64 -  
1058 028A: MOVLW 03 -  
1059 028B: MOVWF 66 -  
1060 028C: CALL 101 -  
1061 028D: CLRF 5D -  
1062 .................... strncpy(c, &countS[6], 3); c[3]='\0'; 285 .................... strncpy(c, &countS[6], 3); c[3]='\0';
1063 028E: CLRF 63 -  
1064 028F: MOVLW 5E -  
1065 0290: MOVWF 62 -  
1066 0291: CLRF 65 -  
1067 0292: MOVLW 52 -  
1068 0293: MOVWF 64 -  
1069 0294: MOVLW 03 -  
1070 0295: MOVWF 66 -  
1071 0296: CALL 101 -  
1072 0297: CLRF 61 -  
1073 .................... 286 ....................
1074 .................... printf("%s\r\n", countS); // output to RS232 287 .................... printf("%s\r\n", countS); // output to RS232
1075 0298: MOVLW 4C -  
1076 0299: MOVWF 04 -  
1077 029A: BCF 03.7 -  
1078 * -  
1079 02B1: MOVLW 0D -  
1080 02B2: BTFSS 0C.4 -  
1081 02B3: GOTO 2B2 -  
1082 02B4: MOVWF 19 -  
1083 02B5: MOVLW 0A -  
1084 02B6: BTFSS 0C.4 -  
1085 02B7: GOTO 2B6 -  
1086 02B8: MOVWF 19 -  
1087 .................... 288 ....................
1088 .................... output_toggle(BEEP); // cvak... 289 .................... output_toggle(BEEP); // cvak...
1089 02B9: BCF 28.3 -  
1090 02BA: MOVF 28,W -  
1091 02BB: BSF 03.5 -  
1092 02BC: MOVWF 07 -  
1093 02BD: MOVLW 08 -  
1094 02BE: BCF 03.5 -  
1095 02BF: XORWF 07,F -  
1096 .................... 290 ....................
1097 .................... of=0; // reset overflow counter 291 .................... of=0; // reset overflow counter
1098 02C0: CLRF 41 -  
1099 02C1: CLRF 40 -  
1100 .................... } 292 .................... }
1101 .................... 293 ....................
1102 02C2: BCF 0B.1 -  
1103 02C3: BCF 0A.3 -  
1104 02C4: BCF 0A.4 -  
1105 02C5: GOTO 027 -  
1106 .................... #int_TIMER1 // Interrupf from overflow 294 .................... #int_TIMER1 // Interrupf from overflow
1107 .................... void TIMER1_isr(void) 295 .................... void TIMER1_isr(void)
1108 .................... { 296 .................... {
1109 .................... of++; 297 .................... of++;
1110 02C6: INCF 40,F -  
1111 02C7: BTFSC 03.2 -  
1112 02C8: INCF 41,F -  
1113 .................... } 298 .................... }
1114 .................... 299 ....................
1115 .................... 300 ....................
1116 .................... /*#int_TIMER2 // every 10 ms 301 .................... /*#int_TIMER2 // every 10 ms
1117 .................... void TIMER2_isr(void) 302 .................... void TIMER2_isr(void)
Line 1121... Line 306...
1121 .................... set_timer1(0); 306 .................... set_timer1(0);
1122 .................... output_high(CE); 307 .................... output_high(CE);
1123 .................... }*/ 308 .................... }*/
1124 .................... 309 ....................
1125 .................... 310 ....................
1126 02C9: BCF 0C.0 311 0085: BCF 0C.3
1127 02CA: BCF 0A.3 312 0086: BCF 0A.3
1128 02CB: BCF 0A.4 313 0087: BCF 0A.4
1129 02CC: GOTO 027 314 0088: GOTO 01D
1130 .................... void main() 315 .................... void main()
1131 .................... { 316 .................... {
1132 * 317 *
1133 0332: CLRF 04 318 0111: CLRF 04
1134 0333: BCF 03.7 319 0112: BCF 03.7
1135 0334: MOVLW 1F 320 0113: MOVLW 1F
1136 0335: ANDWF 03,F 321 0114: ANDWF 03,F
1137 0336: BSF 03.5 322 0115: BSF 03.5
1138 0337: BSF 03.6 323 0116: BSF 03.6
1139 0338: BSF 07.3 324 0117: BSF 07.3
1140 0339: MOVLW 08 325 0118: MOVLW 08
1141 033A: BCF 03.6 326 0119: BCF 03.6
1142 033B: MOVWF 19 327 011A: MOVWF 19
1143 033C: MOVLW 02 328 011B: MOVLW 02
1144 033D: MOVWF 1A 329 011C: MOVWF 1A
1145 033E: MOVLW A6 330 011D: MOVLW A6
1146 033F: MOVWF 18 331 011E: MOVWF 18
1147 0340: MOVLW 90 332 011F: MOVLW 90
1148 0341: BCF 03.5 333 0120: BCF 03.5
1149 0342: MOVWF 18 334 0121: MOVWF 18
1150 0343: BSF 28.3 335 0122: BSF 28.3
1151 0344: MOVF 28,W 336 0123: MOVF 28,W
1152 0345: BSF 03.5 337 0124: BSF 03.5
1153 0346: MOVWF 07 338 0125: MOVWF 07
1154 0347: BCF 03.5 339 0126: BCF 03.5
1155 0348: BSF 28.4 340 0127: BSF 28.4
1156 0349: MOVF 28,W 341 0128: MOVF 28,W
1157 034A: BSF 03.5 342 0129: BSF 03.5
1158 034B: MOVWF 07 343 012A: MOVWF 07
1159 034C: MOVLW A0 344 012B: MOVLW A2
1160 034D: MOVWF 13 345 012C: MOVWF 13
1161 034E: MOVLW 36 346 012D: MOVLW 36
1162 034F: BCF 03.5 347 012E: BCF 03.5
1163 0350: MOVWF 14 348 012F: MOVWF 14
-   349 0130: CLRF 35
1164 0351: CLRF 41 350 0131: CLRF 37
1165 0352: CLRF 40 351 0132: CLRF 36
1166 0353: BSF 03.5 352 0133: BSF 03.5
1167 0354: BSF 03.6 353 0134: BSF 03.6
1168 0355: MOVF 09,W 354 0135: MOVF 09,W
1169 0356: ANDLW C0 355 0136: ANDLW C0
1170 0357: MOVWF 09 356 0137: MOVWF 09
1171 0358: BCF 03.6 357 0138: BCF 03.6
1172 0359: BCF 1F.4 358 0139: BCF 1F.4
1173 035A: BCF 1F.5 359 013A: BCF 1F.5
1174 035B: MOVLW 00 360 013B: MOVLW 00
1175 035C: BSF 03.6 361 013C: BSF 03.6
1176 035D: MOVWF 08 362 013D: MOVWF 08
1177 035E: BCF 03.5 363 013E: BCF 03.5
1178 035F: CLRF 07 364 013F: CLRF 07
1179 0360: CLRF 08 365 0140: CLRF 08
1180 0361: CLRF 09 366 0141: CLRF 09
1181 .................... setup_adc_ports(NO_ANALOGS|VSS_VDD); 367 .................... /* setup_adc_ports(NO_ANALOGS|VSS_VDD);
1182 * -  
1183 036C: BSF 03.5 -  
1184 036D: BSF 03.6 -  
1185 036E: MOVF 09,W -  
1186 036F: ANDLW C0 -  
1187 0370: MOVWF 09 -  
1188 0371: BCF 03.6 -  
1189 0372: BCF 1F.4 -  
1190 0373: BCF 1F.5 -  
1191 0374: MOVLW 00 -  
1192 0375: BSF 03.6 -  
1193 0376: MOVWF 08 -  
1194 .................... setup_adc(ADC_OFF); 368 .................... setup_adc(ADC_OFF);
1195 0377: BCF 03.5 -  
1196 0378: BCF 03.6 -  
1197 0379: BCF 1F.0 -  
1198 .................... setup_spi(SPI_SS_DISABLED); 369 .................... // setup_spi(SPI_SS_DISABLED);
1199 037A: BCF 14.5 -  
1200 037B: BCF 28.5 -  
1201 037C: MOVF 28,W -  
1202 037D: BSF 03.5 -  
1203 037E: MOVWF 07 -  
1204 037F: BCF 03.5 -  
1205 0380: BSF 28.4 -  
1206 0381: MOVF 28,W -  
1207 0382: BSF 03.5 -  
1208 0383: MOVWF 07 -  
1209 0384: BCF 03.5 -  
1210 0385: BCF 28.3 -  
1211 0386: MOVF 28,W -  
1212 0387: BSF 03.5 -  
1213 0388: MOVWF 07 -  
1214 0389: MOVLW 01 -  
1215 038A: BCF 03.5 -  
1216 038B: MOVWF 14 -  
1217 038C: MOVLW 00 -  
1218 038D: BSF 03.5 -  
1219 038E: MOVWF 14 -  
1220 .................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); 370 .................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
1221 038F: MOVF 01,W -  
1222 0390: ANDLW C7 -  
1223 0391: IORLW 08 -  
1224 0392: MOVWF 01 -  
1225 .................... // setup_wdt(WDT_144MS); 371 .................... // setup_wdt(WDT_144MS);
1226 .................... setup_timer_1(T1_EXTERNAL|T1_DIV_BY_1); 372 .................... setup_timer_1(T1_EXTERNAL|T1_DIV_BY_1);
1227 0393: MOVLW 07 -  
1228 0394: BCF 03.5 -  
1229 0395: MOVWF 10 -  
1230 .................... setup_timer_2(T2_DIV_BY_16,196,16); 373 .................... setup_timer_2(T2_DIV_BY_16,196,16);
1231 0396: MOVLW 78 -  
1232 0397: MOVWF 78 -  
1233 0398: IORLW 06 -  
1234 0399: MOVWF 12 -  
1235 039A: MOVLW C4 -  
1236 039B: BSF 03.5 -  
1237 039C: MOVWF 12 -  
1238 .................... setup_ccp1(CCP_OFF); 374 .................... setup_ccp1(CCP_OFF);
1239 039D: BCF 03.5 -  
1240 039E: BSF 28.2 -  
1241 039F: MOVF 28,W -  
1242 03A0: BSF 03.5 -  
1243 03A1: MOVWF 07 -  
1244 03A2: BCF 03.5 -  
1245 03A3: CLRF 17 -  
1246 03A4: BSF 03.5 -  
1247 03A5: CLRF 1B -  
1248 03A6: CLRF 1C -  
1249 03A7: MOVLW 01 -  
1250 03A8: MOVWF 1D -  
1251 .................... setup_comparator(NC_NC_NC_NC); 375 .................... setup_comparator(NC_NC_NC_NC);
1252 03A9: BCF 03.5 -  
1253 03AA: BSF 03.6 -  
1254 03AB: CLRF 07 -  
1255 03AC: CLRF 08 -  
1256 03AD: CLRF 09 -  
1257 .................... setup_vref(FALSE); 376 .................... setup_vref(FALSE);
-   377 ....................
-   378 .................... */
-   379 ....................
-   380 .................... setup_adc_ports(NO_ANALOGS|VSS_VDD);
-   381 *
1258 03AE: BSF 03.5 382 0148: BSF 03.5
-   383 0149: BSF 03.6
-   384 014A: MOVF 09,W
-   385 014B: ANDLW C0
-   386 014C: MOVWF 09
1259 03AF: BCF 03.6 387 014D: BCF 03.6
-   388 014E: BCF 1F.4
-   389 014F: BCF 1F.5
1260 03B0: CLRF 17 390 0150: MOVLW 00
-   391 0151: BSF 03.6
-   392 0152: MOVWF 08
1261 .................... 393 .................... // setup_adc(ADC_CLOCK_DIV_2);
1262 .................... delay_ms(1000); 394 .................... setup_adc(ADC_OFF);
-   395 0153: BCF 03.5
1263 03B1: MOVLW 04 396 0154: BCF 03.6
-   397 0155: BCF 1F.0
-   398 .................... // setup_spi(SPI_SS_DISABLED); //must not be set if I2C are in use!
-   399 .................... setup_timer_0(RTCC_EXT_L_TO_H|RTCC_DIV_1);
1264 03B2: BCF 03.5 400 0156: BSF 03.5
-   401 0157: MOVF 01,W
-   402 0158: ANDLW C7
-   403 0159: IORLW 28
1265 03B3: MOVWF 46 404 015A: MOVWF 01
-   405 .................... // setup_timer_0(RTCC_INTERNAL);setup_wdt(WDT_144MS);
-   406 .................... setup_timer_1(T1_EXTERNAL|T1_DIV_BY_1|T1_CLK_OUT);
1266 03B4: MOVLW FA 407 015B: MOVLW 0F
-   408 015C: BCF 03.5
1267 03B5: MOVWF 47 409 015D: MOVWF 10
-   410 .................... // setup_timer_2(T2_DISABLED,0,1);
-   411 .................... setup_comparator(NC_NC_NC_NC);
-   412 015E: BSF 03.6
-   413 015F: CLRF 07
-   414 0160: CLRF 08
-   415 0161: CLRF 09
-   416 .................... setup_vref(FALSE);
-   417 0162: BSF 03.5
-   418 0163: BCF 03.6
-   419 0164: CLRF 17
-   420 .................... // setup_oscillator(OSC_8MHZ|OSC_INTRC);
-   421 ....................
-   422 .................... // ext_int_edge( L_TO_H ); // set 1PPS active edge
-   423 .................... // enable_interrupts(INT_TIMER1);
-   424 .................... // enable_interrupts(INT_EXT);
-   425 .................... enable_interrupts(INT_SSP);
-   426 0165: BSF 0C.3
-   427 .................... // enable_interrupts(INT_TIMER2);
-   428 .................... enable_interrupts(GLOBAL);
1268 03B6: GOTO 2D2 429 0166: MOVLW C0
1269 03B7: DECFSZ 46,F 430 0167: BCF 03.5
1270 03B8: GOTO 3B4 431 0168: IORWF 0B,F
-   432 ....................
-   433 ....................
-   434 .................... /* delay_ms(1000);
1271 .................... int n; 435 .................... int n;
1272 .................... for (n=0;n<40;n++) putc(cmd[n]); // setup GPS 436 .................... for (n=0;n<40;n++) putc(cmd[n]); // setup GPS
1273 03B9: CLRF 45 -  
1274 03BA: MOVF 45,W -  
1275 03BB: SUBLW 27 -  
1276 03BC: BTFSS 03.0 437 ....................
1277 03BD: GOTO 3C5 -  
1278 03BE: MOVF 45,W -  
1279 03BF: CALL 041 -  
1280 03C0: BTFSS 0C.4 438 .................... */
1281 03C1: GOTO 3C0 -  
1282 03C2: MOVWF 19 -  
1283 03C3: INCF 45,F -  
1284 03C4: GOTO 3BA -  
1285 .................... 439 ....................
1286 .................... printf("cvak...\r\n"); 440 .................... printf("cvak...\r\n");
1287 03C5: MOVLW CD 441 0169: MOVLW 89
1288 03C6: BSF 03.6 442 016A: BSF 03.6
1289 03C7: MOVWF 0D 443 016B: MOVWF 0D
1290 03C8: MOVLW 02 444 016C: MOVLW 00
1291 03C9: MOVWF 0F 445 016D: MOVWF 0F
1292 03CA: BCF 03.6 446 016E: BCF 03.6
1293 03CB: GOTO 2E8 447 016F: GOTO 08E
1294 .................... 448 ....................
1295 .................... ext_int_edge( L_TO_H ); // set 1PPS active edge -  
1296 03CC: BSF 03.5 -  
1297 03CD: BSF 01.6 449 ....................
1298 .................... enable_interrupts(INT_TIMER1); 450 .................... buffer[2]=0;
1299 03CE: BSF 0C.0 451 0170: CLRF 2F
1300 .................... enable_interrupts(INT_EXT); 452 .................... buffer[3]=0;
1301 03CF: BCF 03.5 -  
1302 03D0: BSF 0B.4 453 0171: CLRF 30
1303 .................... enable_interrupts(INT_SSP); 454 .................... buffer[4]=0;
1304 03D1: BSF 03.5 -  
1305 03D2: BSF 0C.3 455 0172: CLRF 31
1306 .................... // enable_interrupts(INT_TIMER2); -  
1307 .................... enable_interrupts(GLOBAL); 456 .................... buffer[5]=0;
1308 03D3: MOVLW C0 457 0173: CLRF 32
1309 03D4: BCF 03.5 -  
1310 03D5: IORWF 0B,F -  
1311 .................... 458 ....................
1312 .................... while(true) 459 .................... while(true)
1313 .................... { 460 .................... {
1314 .................... /* output_high(LED); 461 .................... // output_high(LED);
1315 .................... delay_ms(999); 462 .................... delay_ms(1000);
-   463 0174: MOVLW 04
-   464 0175: MOVWF 39
-   465 0176: MOVLW FA
-   466 0177: MOVWF 3A
-   467 0178: GOTO 0D8
-   468 0179: DECFSZ 39,F
-   469 017A: GOTO 176
1316 .................... output_low(LED); 470 .................... // output_low(LED);
1317 .................... delay_ms(999); 471 .................... // delay_ms(999);
1318 .................... printf("%X %X %X %X\r\n", buffer[0],buffer[1],buffer[2],buffer[3]); 472 .................... printf("%X %X %X %X\r\n", buffer[0],buffer[1],buffer[2],buffer[3]);
-   473 017B: MOVF 2D,W
-   474 017C: MOVWF 39
-   475 017D: MOVLW 37
-   476 017E: MOVWF 3A
-   477 017F: CALL 0EE
-   478 0180: MOVLW 20
-   479 0181: BTFSS 0C.4
-   480 0182: GOTO 181
-   481 0183: MOVWF 19
-   482 0184: MOVF 2E,W
-   483 0185: MOVWF 39
-   484 0186: MOVLW 37
-   485 0187: MOVWF 3A
-   486 0188: CALL 0EE
-   487 0189: MOVLW 20
-   488 018A: BTFSS 0C.4
-   489 018B: GOTO 18A
-   490 018C: MOVWF 19
-   491 018D: MOVF 2F,W
-   492 018E: MOVWF 39
-   493 018F: MOVLW 37
-   494 0190: MOVWF 3A
-   495 0191: CALL 0EE
-   496 0192: MOVLW 20
-   497 0193: BTFSS 0C.4
-   498 0194: GOTO 193
-   499 0195: MOVWF 19
-   500 0196: MOVF 30,W
-   501 0197: MOVWF 39
-   502 0198: MOVLW 37
-   503 0199: MOVWF 3A
-   504 019A: CALL 0EE
-   505 019B: MOVLW 0D
-   506 019C: BTFSS 0C.4
-   507 019D: GOTO 19C
-   508 019E: MOVWF 19
-   509 019F: MOVLW 0A
-   510 01A0: BTFSS 0C.4
-   511 01A1: GOTO 1A0
-   512 01A2: MOVWF 19
1319 .................... */ 513 ....................
1320 .................... } 514 .................... }
1321 03D6: GOTO 3D6 515 01A3: GOTO 174
1322 .................... } 516 .................... }
1323 03D7: SLEEP 517 01A4: SLEEP
1324   518  
1325 Configuration Fuses: 519 Configuration Fuses:
1326 Word 1: 2CF2 HS NOWDT NOPUT MCLR NOPROTECT NOCPD NOBROWNOUT IESO FCMEN NOLVP NODEBUG 520 Word 1: 2CF2 HS NOWDT NOPUT MCLR NOPROTECT NOCPD NOBROWNOUT IESO FCMEN NOLVP NODEBUG
1327 Word 2: 3FFF NOWRT BORV40 521 Word 2: 3FFF NOWRT BORV40