Rev Author Line No. Line
3275 kaklik 1 CCS PCM C Compiler, Version 4.106, 47914 26-VIII-13 18:26
3095 jacho 2  
3275 kaklik 3 Filename: Z:\home\kaklik\svnMLAB\Modules\Sensors\LTS01A\SW\PIC16F887\main.lst
3095 jacho 4  
3275 kaklik 5 ROM used: 1029 words (13%)
3095 jacho 6 Largest free fragment is 2048
7 RAM used: 10 (3%) at main() level
3275 kaklik 8 36 (10%) worst case
3095 jacho 9 Stack: 2 locations
10  
11 *
3275 kaklik 12 0000: MOVLW 03
3095 jacho 13 0001: MOVWF 0A
3275 kaklik 14 0002: GOTO 35C
3095 jacho 15 0003: NOP
3275 kaklik 16 .................... #include "main.h"
3095 jacho 17 .................... #include <16F887.h>
18 .................... //////// Standard Header file for the PIC16F887 device ////////////////
19 .................... #device PIC16F887
20 .................... #list
21 ....................
22 .................... #device adc=8
23 ....................
24 .................... #FUSES NOWDT //No Watch Dog Timer
25 .................... #FUSES INTRC //Internal RC Osc
26 .................... #FUSES NOPUT //No Power Up Timer
27 .................... #FUSES MCLR //Master Clear pin enabled
28 .................... #FUSES NOPROTECT //Code not protected from reading
29 .................... #FUSES NOCPD //No EE protection
30 .................... #FUSES NOBROWNOUT //No brownout reset
31 .................... #FUSES IESO //Internal External Switch Over mode enabled
32 .................... #FUSES FCMEN //Fail-safe clock monitor enabled
33 .................... #FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
34 .................... #FUSES NODEBUG //No Debug mode for ICD
35 .................... #FUSES NOWRT //Program memory not write protected
36 .................... #FUSES BORV40 //Brownout reset at 4.0V
37 ....................
38 .................... #use delay(clock=8000000)
39 *
3275 kaklik 40 0346: MOVLW 22
41 0347: MOVWF 04
42 0348: BCF 03.7
43 0349: MOVF 00,W
44 034A: BTFSC 03.2
45 034B: GOTO 359
46 034C: MOVLW 02
47 034D: MOVWF 78
48 034E: CLRF 77
49 034F: DECFSZ 77,F
50 0350: GOTO 34F
51 0351: DECFSZ 78,F
52 0352: GOTO 34E
53 0353: MOVLW 97
54 0354: MOVWF 77
55 0355: DECFSZ 77,F
56 0356: GOTO 355
57 0357: DECFSZ 00,F
58 0358: GOTO 34C
59 0359: BCF 0A.3
60 035A: BCF 0A.4
61 035B: GOTO 401 (RETURN)
3095 jacho 62 ....................
63 ....................
64 ....................
3275 kaklik 65 .................... #define S_SDA PIN_C4
66 .................... #define S_SCL PIN_C3
3095 jacho 67 .................... #use i2c(master, sda=S_SDA, scl=S_SCL)
68 *
3275 kaklik 69 006F: MOVLW 08
70 0070: MOVWF 78
71 0071: NOP
72 0072: BCF 07.3
73 0073: BCF 20.3
74 0074: MOVF 20,W
75 0075: BSF 03.5
76 0076: MOVWF 07
77 0077: NOP
78 0078: BCF 03.5
79 0079: RLF 23,F
80 007A: BCF 07.4
81 007B: BTFSS 03.0
82 007C: GOTO 083
83 007D: BSF 20.4
84 007E: MOVF 20,W
85 007F: BSF 03.5
86 0080: MOVWF 07
87 0081: GOTO 087
88 0082: BCF 03.5
89 0083: BCF 20.4
90 0084: MOVF 20,W
91 0085: BSF 03.5
92 0086: MOVWF 07
93 0087: NOP
94 0088: BCF 03.5
95 0089: BSF 20.3
96 008A: MOVF 20,W
97 008B: BSF 03.5
98 008C: MOVWF 07
99 008D: BCF 03.5
100 008E: BTFSS 07.3
101 008F: GOTO 08E
102 0090: DECFSZ 78,F
103 0091: GOTO 071
104 0092: NOP
105 0093: BCF 07.3
106 0094: BCF 20.3
107 0095: MOVF 20,W
108 0096: BSF 03.5
109 0097: MOVWF 07
110 0098: NOP
111 0099: BCF 03.5
112 009A: BSF 20.4
113 009B: MOVF 20,W
114 009C: BSF 03.5
115 009D: MOVWF 07
116 009E: NOP
117 009F: NOP
3095 jacho 118 00A0: BCF 03.5
3275 kaklik 119 00A1: BSF 20.3
3095 jacho 120 00A2: MOVF 20,W
121 00A3: BSF 03.5
122 00A4: MOVWF 07
3275 kaklik 123 00A5: BCF 03.5
124 00A6: BTFSS 07.3
125 00A7: GOTO 0A6
126 00A8: CLRF 78
127 00A9: NOP
128 00AA: BTFSC 07.4
129 00AB: BSF 78.0
130 00AC: BCF 07.3
131 00AD: BCF 20.3
132 00AE: MOVF 20,W
133 00AF: BSF 03.5
134 00B0: MOVWF 07
135 00B1: BCF 03.5
136 00B2: BCF 07.4
137 00B3: BCF 20.4
138 00B4: MOVF 20,W
139 00B5: BSF 03.5
140 00B6: MOVWF 07
3095 jacho 141 00B7: BCF 03.5
3275 kaklik 142 00B8: RETURN
143 00B9: MOVLW 08
144 00BA: MOVWF 24
145 00BB: MOVF 77,W
146 00BC: MOVWF 25
147 00BD: BSF 20.4
148 00BE: MOVF 20,W
149 00BF: BSF 03.5
150 00C0: MOVWF 07
151 00C1: NOP
152 00C2: BCF 03.5
153 00C3: BSF 20.3
154 00C4: MOVF 20,W
155 00C5: BSF 03.5
156 00C6: MOVWF 07
157 00C7: BCF 03.5
158 00C8: BTFSS 07.3
159 00C9: GOTO 0C8
160 00CA: BTFSC 07.4
161 00CB: BSF 03.0
162 00CC: BTFSS 07.4
163 00CD: BCF 03.0
164 00CE: RLF 78,F
165 00CF: NOP
166 00D0: BCF 20.3
167 00D1: MOVF 20,W
168 00D2: BSF 03.5
169 00D3: MOVWF 07
170 00D4: BCF 03.5
171 00D5: BCF 07.3
172 00D6: DECFSZ 24,F
173 00D7: GOTO 0BD
174 00D8: BSF 20.4
175 00D9: MOVF 20,W
176 00DA: BSF 03.5
177 00DB: MOVWF 07
178 00DC: NOP
179 00DD: BCF 03.5
180 00DE: BCF 07.4
181 00DF: MOVF 25,W
182 00E0: BTFSC 03.2
183 00E1: GOTO 0E7
184 00E2: BCF 20.4
185 00E3: MOVF 20,W
186 00E4: BSF 03.5
187 00E5: MOVWF 07
188 00E6: BCF 03.5
189 00E7: NOP
190 00E8: BSF 20.3
191 00E9: MOVF 20,W
192 00EA: BSF 03.5
193 00EB: MOVWF 07
194 00EC: BCF 03.5
195 00ED: BTFSS 07.3
196 00EE: GOTO 0ED
197 00EF: NOP
198 00F0: BCF 07.3
199 00F1: BCF 20.3
200 00F2: MOVF 20,W
201 00F3: BSF 03.5
202 00F4: MOVWF 07
203 00F5: NOP
204 00F6: BCF 03.5
205 00F7: BCF 07.4
206 00F8: BCF 20.4
207 00F9: MOVF 20,W
208 00FA: BSF 03.5
209 00FB: MOVWF 07
210 00FC: BCF 03.5
211 00FD: RETURN
212 .................... #use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
3095 jacho 213 ....................
3275 kaklik 214 .................... #include "../LTS01.h"
3180 jacho 215 .................... //Adresa pro VDD, VDD, VDD W 0x9E R 0x9F
216 .................... //Adresa pro GND GND GND W 0x90 R 0x91
3095 jacho 217 ....................
3275 kaklik 218 .................... #define LTS01A_address 0x90
219 ....................
220 .................... #include "LTS01.c"
221 .................... float LTS01_get_temp()
222 .................... {
223 .................... int8 MSB, LSB;
224 ....................
225 .................... i2c_start();
226 *
227 0173: BSF 20.4
228 0174: MOVF 20,W
229 0175: BSF 03.5
230 0176: MOVWF 07
231 0177: NOP
232 0178: BCF 03.5
233 0179: BSF 20.3
234 017A: MOVF 20,W
235 017B: BSF 03.5
236 017C: MOVWF 07
237 017D: NOP
238 017E: BCF 03.5
239 017F: BCF 07.4
240 0180: BCF 20.4
241 0181: MOVF 20,W
242 0182: BSF 03.5
243 0183: MOVWF 07
244 0184: NOP
245 0185: BCF 03.5
246 0186: BCF 07.3
247 0187: BCF 20.3
248 0188: MOVF 20,W
249 0189: BSF 03.5
250 018A: MOVWF 07
251 .................... I2C_Write(LTS01A_address);
252 018B: MOVLW 90
253 018C: BCF 03.5
254 018D: MOVWF 23
255 018E: CALL 06F
256 .................... I2C_write(0x00);
257 018F: CLRF 23
258 0190: CALL 06F
259 .................... i2c_stop();
260 0191: BCF 20.4
261 0192: MOVF 20,W
262 0193: BSF 03.5
263 0194: MOVWF 07
264 0195: NOP
265 0196: BCF 03.5
266 0197: BSF 20.3
267 0198: MOVF 20,W
268 0199: BSF 03.5
269 019A: MOVWF 07
270 019B: BCF 03.5
271 019C: BTFSS 07.3
272 019D: GOTO 19C
273 019E: NOP
274 019F: GOTO 1A0
275 01A0: NOP
276 01A1: BSF 20.4
277 01A2: MOVF 20,W
278 01A3: BSF 03.5
279 01A4: MOVWF 07
280 01A5: NOP
281 .................... i2c_start();
282 01A6: BCF 03.5
283 01A7: BSF 20.4
284 01A8: MOVF 20,W
285 01A9: BSF 03.5
286 01AA: MOVWF 07
287 01AB: NOP
288 01AC: BCF 03.5
289 01AD: BSF 20.3
290 01AE: MOVF 20,W
291 01AF: BSF 03.5
292 01B0: MOVWF 07
293 01B1: NOP
294 01B2: BCF 03.5
295 01B3: BCF 07.4
296 01B4: BCF 20.4
297 01B5: MOVF 20,W
298 01B6: BSF 03.5
299 01B7: MOVWF 07
300 01B8: NOP
301 01B9: BCF 03.5
302 01BA: BCF 07.3
303 01BB: BCF 20.3
304 01BC: MOVF 20,W
305 01BD: BSF 03.5
306 01BE: MOVWF 07
307 .................... I2C_Write(LTS01A_address+1);
308 01BF: MOVLW 91
309 01C0: BCF 03.5
310 01C1: MOVWF 23
311 01C2: CALL 06F
312 .................... MSB=i2c_read(1);
313 01C3: MOVLW 01
314 01C4: MOVWF 77
315 01C5: CALL 0B9
316 01C6: MOVF 78,W
317 01C7: MOVWF 21
318 .................... LSB=i2c_read(0);
319 01C8: CLRF 77
320 01C9: CALL 0B9
321 01CA: MOVF 78,W
322 01CB: MOVWF 22
323 .................... i2c_stop();
324 01CC: BCF 20.4
325 01CD: MOVF 20,W
326 01CE: BSF 03.5
327 01CF: MOVWF 07
328 01D0: NOP
329 01D1: BCF 03.5
330 01D2: BSF 20.3
331 01D3: MOVF 20,W
332 01D4: BSF 03.5
333 01D5: MOVWF 07
334 01D6: BCF 03.5
335 01D7: BTFSS 07.3
336 01D8: GOTO 1D7
337 01D9: NOP
338 01DA: GOTO 1DB
339 01DB: NOP
340 01DC: BSF 20.4
341 01DD: MOVF 20,W
342 01DE: BSF 03.5
343 01DF: MOVWF 07
344 01E0: NOP
345 ....................
346 .................... return (MAKE16(MSB,LSB) * 0.00390625 );
347 01E1: BCF 03.5
348 01E2: MOVF 21,W
349 01E3: MOVWF 24
350 01E4: MOVF 22,W
351 01E5: MOVWF 23
352 01E6: MOVF 24,W
353 01E7: MOVWF 26
354 01E8: MOVF 23,W
355 01E9: MOVWF 25
356 *
357 0206: MOVF 7A,W
358 0207: MOVWF 35
359 0208: MOVF 79,W
360 0209: MOVWF 34
361 020A: MOVF 78,W
362 020B: MOVWF 33
363 020C: MOVF 77,W
364 020D: MOVWF 32
365 020E: CLRF 39
366 020F: CLRF 38
367 0210: CLRF 37
368 0211: MOVLW 77
369 0212: MOVWF 36
370 0213: CALL 0FE
371 .................... }
372 0214: BCF 0A.3
373 0215: BCF 0A.4
374 0216: GOTO 3D3 (RETURN)
375 ....................
376 ....................
377 ....................
378 ....................
3095 jacho 379 .................... void main()
380 .................... {
381 *
3275 kaklik 382 035C: CLRF 04
383 035D: BCF 03.7
384 035E: MOVLW 1F
385 035F: ANDWF 03,F
386 0360: MOVLW 71
387 0361: BSF 03.5
388 0362: MOVWF 0F
389 0363: MOVF 0F,W
390 0364: BSF 03.6
391 0365: BCF 07.3
392 0366: MOVLW 0C
393 0367: BCF 03.6
394 0368: MOVWF 19
395 0369: MOVLW A2
396 036A: MOVWF 18
397 036B: MOVLW 90
398 036C: BCF 03.5
399 036D: MOVWF 18
400 036E: BSF 03.5
401 036F: BSF 03.6
402 0370: MOVF 09,W
403 0371: ANDLW C0
404 0372: MOVWF 09
405 0373: BCF 03.6
406 0374: BCF 1F.4
407 0375: BCF 1F.5
408 0376: MOVLW 00
409 0377: BSF 03.6
410 0378: MOVWF 08
411 0379: BCF 03.5
412 037A: CLRF 07
413 037B: CLRF 08
414 037C: CLRF 09
3095 jacho 415 ....................
416 .................... setup_adc_ports(NO_ANALOGS|VSS_VDD);
417 *
3275 kaklik 418 0380: BSF 03.5
419 0381: BSF 03.6
420 0382: MOVF 09,W
421 0383: ANDLW C0
422 0384: MOVWF 09
423 0385: BCF 03.6
424 0386: BCF 1F.4
425 0387: BCF 1F.5
426 0388: MOVLW 00
427 0389: BSF 03.6
428 038A: MOVWF 08
3095 jacho 429 .................... setup_adc(ADC_CLOCK_DIV_2);
3275 kaklik 430 038B: BCF 03.5
431 038C: BCF 03.6
432 038D: BCF 1F.6
433 038E: BCF 1F.7
434 038F: BSF 03.5
435 0390: BCF 1F.7
436 0391: BCF 03.5
437 0392: BSF 1F.0
3095 jacho 438 .................... setup_spi(SPI_SS_DISABLED);
3275 kaklik 439 0393: BCF 14.5
440 0394: BCF 20.5
441 0395: MOVF 20,W
442 0396: BSF 03.5
443 0397: MOVWF 07
444 0398: BCF 03.5
445 0399: BSF 20.4
446 039A: MOVF 20,W
447 039B: BSF 03.5
448 039C: MOVWF 07
449 039D: BCF 03.5
450 039E: BCF 20.3
451 039F: MOVF 20,W
452 03A0: BSF 03.5
453 03A1: MOVWF 07
454 03A2: MOVLW 01
455 03A3: BCF 03.5
456 03A4: MOVWF 14
457 03A5: MOVLW 00
458 03A6: BSF 03.5
459 03A7: MOVWF 14
3095 jacho 460 .................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
3275 kaklik 461 03A8: MOVF 01,W
462 03A9: ANDLW C7
463 03AA: IORLW 08
464 03AB: MOVWF 01
3095 jacho 465 .................... setup_timer_1(T1_DISABLED);
3275 kaklik 466 03AC: BCF 03.5
467 03AD: CLRF 10
3095 jacho 468 .................... setup_timer_2(T2_DISABLED,0,1);
3275 kaklik 469 03AE: MOVLW 00
470 03AF: MOVWF 78
471 03B0: MOVWF 12
472 03B1: MOVLW 00
473 03B2: BSF 03.5
474 03B3: MOVWF 12
3095 jacho 475 .................... setup_ccp1(CCP_OFF);
3275 kaklik 476 03B4: BCF 03.5
477 03B5: BSF 20.2
478 03B6: MOVF 20,W
479 03B7: BSF 03.5
480 03B8: MOVWF 07
481 03B9: BCF 03.5
482 03BA: CLRF 17
483 03BB: BSF 03.5
484 03BC: CLRF 1B
485 03BD: CLRF 1C
486 03BE: MOVLW 01
487 03BF: MOVWF 1D
3095 jacho 488 .................... setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
3275 kaklik 489 03C0: BCF 03.5
490 03C1: BSF 03.6
491 03C2: CLRF 07
492 03C3: CLRF 08
493 03C4: CLRF 09
3095 jacho 494 ....................
3275 kaklik 495 .................... printf("Simple Thermomether with LTS01A sensor \r\n",);
496 03C5: MOVLW 04
497 03C6: MOVWF 0D
498 03C7: MOVLW 00
499 03C8: MOVWF 0F
500 03C9: BCF 03.6
501 03CA: CALL 027
502 .................... printf("(c) MLAB.cz 2013 JACHO \r\n",);
503 03CB: MOVLW 19
504 03CC: BSF 03.6
505 03CD: MOVWF 0D
506 03CE: MOVLW 00
507 03CF: MOVWF 0F
508 03D0: BCF 03.6
509 03D1: CALL 027
3095 jacho 510 ....................
511 .................... while(TRUE)
512 .................... {
3275 kaklik 513 .................... printf("T: %f\r\n", LTS01_get_temp());
514 03D2: GOTO 173
515 03D3: MOVF 77,W
516 03D4: MOVWF 21
517 03D5: MOVF 78,W
518 03D6: MOVWF 22
519 03D7: MOVF 79,W
520 03D8: MOVWF 23
521 03D9: MOVF 7A,W
522 03DA: MOVWF 24
523 03DB: MOVLW 54
524 03DC: BTFSS 0C.4
525 03DD: GOTO 3DC
526 03DE: MOVWF 19
527 03DF: MOVLW 3A
528 03E0: BTFSS 0C.4
529 03E1: GOTO 3E0
530 03E2: MOVWF 19
531 03E3: MOVLW 20
532 03E4: BTFSS 0C.4
533 03E5: GOTO 3E4
534 03E6: MOVWF 19
535 03E7: MOVLW 89
536 03E8: MOVWF 04
537 03E9: MOVF 24,W
538 03EA: MOVWF 28
539 03EB: MOVF 23,W
540 03EC: MOVWF 27
541 03ED: MOVF 22,W
542 03EE: MOVWF 26
543 03EF: MOVF 21,W
544 03F0: MOVWF 25
545 03F1: MOVLW 02
546 03F2: MOVWF 29
547 03F3: GOTO 259
548 03F4: MOVLW 0D
549 03F5: BTFSS 0C.4
550 03F6: GOTO 3F5
551 03F7: MOVWF 19
552 03F8: MOVLW 0A
553 03F9: BTFSS 0C.4
554 03FA: GOTO 3F9
555 03FB: MOVWF 19
556 .................... delay_ms(500);
557 03FC: MOVLW 02
558 03FD: MOVWF 21
559 03FE: MOVLW FA
560 03FF: MOVWF 22
561 0400: GOTO 346
562 0401: DECFSZ 21,F
563 0402: GOTO 3FE
3095 jacho 564 .................... }
3275 kaklik 565 0403: GOTO 3D2
3095 jacho 566 .................... }
567 ....................
3275 kaklik 568 0404: SLEEP
3095 jacho 569  
570 Configuration Fuses:
571 Word 1: 2CF5 INTRC NOWDT NOPUT MCLR NOPROTECT NOCPD NOBROWNOUT IESO FCMEN NOLVP NODEBUG
572 Word 2: 3FFF NOWRT BORV40