Subversion Repositories svnkaklik

Rev

Rev 2 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
66 kaklik 1
CCS PCM C Compiler, Version 3.245, 27853               05-XI-06 20:45
2 kaklik 2
 
66 kaklik 3
               Filename: D:\KAKLIK\projekty\roboti\istrobot\3Orbis\cidla\cidla.lst
2 kaklik 4
 
5
               ROM used: 548 words (13%)
6
                         Largest free fragment is 2048
7
               RAM used: 12 (7%) at main() level
8
                         17 (10%) worst case
9
               Stack:    2 locations
10
 
11
*
12
0000:  MOVLW  00
13
0001:  MOVWF  0A
14
0002:  GOTO   0B1
15
0003:  NOP
16
.................... #include ".\cidla.h" 
17
.................... #include <16F88.h> 
18
.................... //////// Standard Header file for the PIC16F88 device //////////////// 
19
.................... #device PIC16F88 
20
.................... #list 
21
....................  
22
.................... #device adc=8 
23
.................... #fuses NOWDT,INTRC_IO, NOPUT, MCLR, NOBROWNOUT, NOLVP, NOCPD, NOWRT, NODEBUG, NOPROTECT, NOFCMEN, NOIESO 
24
.................... #use delay(clock=4000000,RESTART_WDT) 
25
*
26
002A:  MOVLW  27
27
002B:  MOVWF  04
28
002C:  MOVF   00,W
29
002D:  BTFSC  03.2
30
002E:  GOTO   040
31
002F:  MOVLW  01
32
0030:  MOVWF  78
33
0031:  MOVLW  BF
34
0032:  MOVWF  77
35
0033:  CLRWDT
36
0034:  DECFSZ 77,F
37
0035:  GOTO   033
38
0036:  DECFSZ 78,F
39
0037:  GOTO   031
40
0038:  MOVLW  4A
41
0039:  MOVWF  77
42
003A:  DECFSZ 77,F
43
003B:  GOTO   03A
44
003C:  NOP
45
003D:  CLRWDT
46
003E:  DECFSZ 00,F
47
003F:  GOTO   02F
48
0040:  RETLW  00
49
....................  
50
....................  
51
.................... //#include <stdlib.h> 
52
....................  
53
.................... #use rs232(baud=9600,parity=N,xmit=PIN_B3,bits=8,restart_wdt) 
54
0041:  BSF    03.5
55
0042:  BCF    06.3
56
0043:  BCF    03.5
57
0044:  BCF    06.3
58
0045:  MOVLW  08
59
0046:  MOVWF  78
60
0047:  NOP
61
0048:  NOP
62
0049:  NOP
63
004A:  BSF    78.7
64
004B:  GOTO   05B
65
004C:  BCF    78.7
66
004D:  RRF    29,F
67
004E:  BTFSC  03.0
68
004F:  BSF    06.3
69
0050:  BTFSS  03.0
70
0051:  BCF    06.3
71
0052:  BSF    78.6
72
0053:  GOTO   05B
73
0054:  BCF    78.6
74
0055:  DECFSZ 78,F
75
0056:  GOTO   04D
76
0057:  NOP
77
0058:  NOP
78
0059:  NOP
79
005A:  BSF    06.3
80
005B:  MOVLW  1C
81
005C:  MOVWF  04
82
005D:  DECFSZ 04,F
83
005E:  GOTO   05D
84
005F:  NOP
85
0060:  NOP
86
0061:  CLRWDT
87
0062:  BTFSC  78.7
88
0063:  GOTO   04C
89
0064:  BTFSC  78.6
90
0065:  GOTO   054
91
0066:  RETLW  00
92
....................  
93
.................... #define IRRX      PIN_B0 
94
....................  
95
.................... #define  TRESHOLD_MAX   70    // rozhodovaci uroven  pro cidla cerna/bila 
96
.................... #define  TRESHOLD_MIN   50 
97
.................... #define  CIHLA          10    // doba, po kterou musi byt detekovana cihla 
98
....................  
99
.................... unsigned int8 last_radius;    // rozsah 
100
.................... unsigned int8 last_cidla;     // co cidla videla minule 
101
.................... unsigned int8 shure;          // citac doby, po kterou musi byt detekovana cihla 
102
....................  
103
.................... //tuning 
104
.................... /*#define  PULZACE  3  // urcuje rychlost pulzovani pomoci PWM 
105
....................  
106
.................... //Vystup PWM je na PIN_B3 
107
.................... //////////////////////////////////////////////////////////////////////////////// 
108
.................... void pulzovani()  // postupne rozsvecuje a zhasina podsvetleni 
109
.................... { 
110
.................... unsigned int8 i,n; 
111
....................    for(n=0;n<=3;n++) 
112
....................    { 
113
....................       for(i=0;i<255;i++) {set_pwm1_duty(i); Delay_ms(PULZACE);} // rozsvecovani 
114
....................       for(i=255;i>0;i--) {set_pwm1_duty(i); Delay_ms(PULZACE);} // zhasinani 
115
....................    } 
116
.................... } 
117
.................... */ 
118
.................... //////////////////////////////////////////////////////////////////////////////// 
119
.................... void main() 
120
.................... { 
121
*
122
00B1:  CLRF   04
123
00B2:  MOVLW  1F
124
00B3:  ANDWF  03,F
125
00B4:  MOVLW  60
126
00B5:  BSF    03.5
127
00B6:  MOVWF  0F
128
00B7:  BCF    06.3
129
00B8:  BCF    03.5
130
00B9:  BSF    06.3
131
00BA:  BSF    03.5
132
00BB:  BCF    1F.4
133
00BC:  BCF    1F.5
134
00BD:  MOVF   1B,W
135
00BE:  ANDLW  80
136
00BF:  MOVWF  1B
137
00C0:  MOVLW  07
138
00C1:  MOVWF  1C
139
....................    int8 cidla; 
140
....................    unsigned int8 a; 
141
....................    unsigned int8 n; 
142
....................  
143
....................    setup_adc_ports(sAN0|sAN1|sAN2|sAN3|sAN4|sAN5|sAN6|VSS_VDD); 
144
00C2:  BCF    1F.4
145
00C3:  BCF    1F.5
146
00C4:  MOVF   1B,W
147
00C5:  ANDLW  80
148
00C6:  IORLW  7F
149
00C7:  MOVWF  1B
150
....................    setup_adc(ADC_CLOCK_INTERNAL); 
151
00C8:  BCF    1F.6
152
00C9:  BCF    03.5
153
00CA:  BSF    1F.6
154
00CB:  BSF    1F.7
155
00CC:  BSF    03.5
156
00CD:  BCF    1F.7
157
00CE:  BCF    03.5
158
00CF:  BSF    1F.0
159
....................    setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); 
160
00D0:  BSF    03.5
161
00D1:  MOVF   01,W
162
00D2:  ANDLW  C7
163
00D3:  IORLW  08
164
00D4:  MOVWF  01
165
....................    setup_timer_1(T1_DISABLED); 
166
00D5:  BCF    03.5
167
00D6:  CLRF   10
168
....................    setup_timer_2(T2_DISABLED,0,1); 
169
00D7:  MOVLW  00
170
00D8:  MOVWF  78
171
00D9:  MOVWF  12
172
00DA:  MOVLW  00
173
00DB:  BSF    03.5
174
00DC:  MOVWF  12
175
....................    setup_comparator(NC_NC_NC_NC); 
176
00DD:  MOVLW  07
177
00DE:  MOVWF  1C
178
00DF:  MOVF   05,W
179
00E0:  CLRWDT
180
00E1:  MOVLW  02
181
00E2:  MOVWF  77
182
00E3:  DECFSZ 77,F
183
00E4:  GOTO   0E3
184
00E5:  NOP
185
00E6:  NOP
186
00E7:  MOVF   1C,W
187
00E8:  BCF    03.5
188
00E9:  BCF    0D.6
189
....................    setup_vref(FALSE); 
190
00EA:  BSF    03.5
191
00EB:  CLRF   1D
192
....................  
193
....................    Delay_ms(500); 
194
00EC:  MOVLW  02
195
00ED:  BCF    03.5
196
00EE:  MOVWF  26
197
00EF:  MOVLW  FA
198
00F0:  MOVWF  27
199
00F1:  CALL   02A
200
00F2:  DECFSZ 26,F
201
00F3:  GOTO   0EF
202
....................    setup_spi(SPI_SLAVE|SPI_H_TO_L|SPI_SS_DISABLED); 
203
00F4:  BCF    14.5
204
00F5:  BSF    03.5
205
00F6:  BCF    06.2
206
00F7:  BSF    06.1
207
00F8:  BSF    06.4
208
00F9:  MOVLW  35
209
00FA:  BCF    03.5
210
00FB:  MOVWF  14
211
00FC:  MOVLW  40
212
00FD:  BSF    03.5
213
00FE:  MOVWF  14
214
....................     
215
....................    // diagnostika 
216
....................    printf("\n\r"); 
217
00FF:  BCF    03.5
218
0100:  CLRF   26
219
0101:  MOVF   26,W
220
0102:  CALL   004
221
0103:  IORLW  00
222
0104:  BTFSC  03.2
223
0105:  GOTO   10A
224
0106:  INCF   26,F
225
0107:  MOVWF  29
226
0108:  CALL   041
227
0109:  GOTO   101
228
....................    Delay_ms(100); 
229
010A:  MOVLW  64
230
010B:  MOVWF  27
231
010C:  CALL   02A
232
....................    printf("***\n\r"); 
233
010D:  CLRF   26
234
010E:  MOVF   26,W
235
010F:  CALL   00B
236
0110:  IORLW  00
237
0111:  BTFSC  03.2
238
0112:  GOTO   117
239
0113:  INCF   26,F
240
0114:  MOVWF  29
241
0115:  CALL   041
242
0116:  GOTO   10E
243
....................    Delay_ms(100); 
244
0117:  MOVLW  64
245
0118:  MOVWF  27
246
0119:  CALL   02A
247
....................    for (n=0; n<=6; n++) 
248
011A:  CLRF   25
249
011B:  MOVF   25,W
250
011C:  SUBLW  06
251
011D:  BTFSS  03.0
252
011E:  GOTO   157
253
....................    { 
254
....................       set_adc_channel(n); 
255
011F:  RLF    25,W
256
0120:  MOVWF  77
257
0121:  RLF    77,F
258
0122:  RLF    77,F
259
0123:  MOVLW  F8
260
0124:  ANDWF  77,F
261
0125:  MOVF   1F,W
262
0126:  ANDLW  C7
263
0127:  IORWF  77,W
264
0128:  MOVWF  1F
265
....................       Delay_ms(100); 
266
0129:  MOVLW  64
267
012A:  MOVWF  27
268
012B:  CALL   02A
269
....................       a=read_adc(); 
270
012C:  BSF    1F.2
271
012D:  BTFSC  1F.2
272
012E:  GOTO   12D
273
012F:  MOVF   1E,W
274
0130:  MOVWF  24
275
....................       printf("sensor %u - %u\n\r",n,a); 
276
0131:  CLRF   26
277
0132:  MOVF   26,W
278
0133:  CALL   015
279
0134:  INCF   26,F
280
0135:  MOVWF  77
281
0136:  MOVWF  29
282
0137:  CALL   041
283
0138:  MOVLW  07
284
0139:  SUBWF  26,W
285
013A:  BTFSS  03.2
286
013B:  GOTO   132
287
013C:  MOVF   25,W
288
013D:  MOVWF  27
289
013E:  MOVLW  1B
290
013F:  MOVWF  28
291
0140:  CALL   07C
292
0141:  MOVLW  20
293
0142:  MOVWF  29
294
0143:  CALL   041
295
0144:  MOVLW  2D
296
0145:  MOVWF  29
297
0146:  CALL   041
298
0147:  MOVLW  20
299
0148:  MOVWF  29
300
0149:  CALL   041
301
014A:  MOVF   24,W
302
014B:  MOVWF  27
303
014C:  MOVLW  1B
304
014D:  MOVWF  28
305
014E:  CALL   07C
306
014F:  MOVLW  0A
307
0150:  MOVWF  29
308
0151:  CALL   041
309
0152:  MOVLW  0D
310
0153:  MOVWF  29
311
0154:  CALL   041
312
....................    } 
313
0155:  INCF   25,F
314
0156:  GOTO   11B
315
....................  
316
....................    shure=0; 
317
0157:  CLRF   22
318
....................    while(true) 
319
....................    { 
320
....................       set_adc_channel(0); 
321
0158:  MOVLW  00
322
0159:  MOVWF  78
323
015A:  MOVF   1F,W
324
015B:  ANDLW  C7
325
015C:  IORWF  78,W
326
015D:  MOVWF  1F
327
....................       cidla=0; 
328
015E:  CLRF   23
329
....................       Delay_us(10); 
330
015F:  CLRWDT
331
0160:  MOVLW  02
332
0161:  MOVWF  77
333
0162:  DECFSZ 77,F
334
0163:  GOTO   162
335
0164:  NOP
336
0165:  NOP
337
....................       a=read_adc(); 
338
0166:  BSF    1F.2
339
0167:  BTFSC  1F.2
340
0168:  GOTO   167
341
0169:  MOVF   1E,W
342
016A:  MOVWF  24
343
....................  
344
....................       set_adc_channel(1); 
345
016B:  MOVLW  08
346
016C:  MOVWF  78
347
016D:  MOVF   1F,W
348
016E:  ANDLW  C7
349
016F:  IORWF  78,W
350
0170:  MOVWF  1F
351
....................       if(a<TRESHOLD_MAX)         //hystereze cidel 
352
0171:  MOVF   24,W
353
0172:  SUBLW  45
354
0173:  BTFSS  03.0
355
0174:  GOTO   17E
356
....................       { 
357
....................          if(a>TRESHOLD_MIN) 
358
0175:  MOVF   24,W
359
0176:  SUBLW  32
360
0177:  BTFSC  03.0
361
0178:  GOTO   17D
362
....................          { 
363
....................             cidla |= (last_cidla & 0b00000001); 
364
0179:  MOVF   21,W
365
017A:  ANDLW  01
366
017B:  IORWF  23,F
367
....................          } 
368
....................          else cidla |= 0b00000001; 
369
017C:  GOTO   17E
370
017D:  BSF    23.0
371
....................       } 
372
....................  
373
....................       a=read_adc(); 
374
017E:  BSF    1F.2
375
017F:  BTFSC  1F.2
376
0180:  GOTO   17F
377
0181:  MOVF   1E,W
378
0182:  MOVWF  24
379
....................  
380
....................       set_adc_channel(2); 
381
0183:  MOVLW  10
382
0184:  MOVWF  78
383
0185:  MOVF   1F,W
384
0186:  ANDLW  C7
385
0187:  IORWF  78,W
386
0188:  MOVWF  1F
387
....................       if(a<TRESHOLD_MAX) 
388
0189:  MOVF   24,W
389
018A:  SUBLW  45
390
018B:  BTFSS  03.0
391
018C:  GOTO   196
392
....................       { 
393
....................          if(a>TRESHOLD_MIN) 
394
018D:  MOVF   24,W
395
018E:  SUBLW  32
396
018F:  BTFSC  03.0
397
0190:  GOTO   195
398
....................          { 
399
....................             cidla |= (last_cidla & 0b00000010); 
400
0191:  MOVF   21,W
401
0192:  ANDLW  02
402
0193:  IORWF  23,F
403
....................          } 
404
....................          else cidla |= 0b00000010; 
405
0194:  GOTO   196
406
0195:  BSF    23.1
407
....................       } 
408
....................  
409
....................       a=read_adc(); 
410
0196:  BSF    1F.2
411
0197:  BTFSC  1F.2
412
0198:  GOTO   197
413
0199:  MOVF   1E,W
414
019A:  MOVWF  24
415
....................  
416
....................       set_adc_channel(3); 
417
019B:  MOVLW  18
418
019C:  MOVWF  78
419
019D:  MOVF   1F,W
420
019E:  ANDLW  C7
421
019F:  IORWF  78,W
422
01A0:  MOVWF  1F
423
....................       if(a<TRESHOLD_MAX) 
424
01A1:  MOVF   24,W
425
01A2:  SUBLW  45
426
01A3:  BTFSS  03.0
427
01A4:  GOTO   1AE
428
....................       { 
429
....................          if(a>TRESHOLD_MIN) 
430
01A5:  MOVF   24,W
431
01A6:  SUBLW  32
432
01A7:  BTFSC  03.0
433
01A8:  GOTO   1AD
434
....................          { 
435
....................             cidla |= (last_cidla & 0b00000100); 
436
01A9:  MOVF   21,W
437
01AA:  ANDLW  04
438
01AB:  IORWF  23,F
439
....................          } 
440
....................          else cidla |= 0b00000100; 
441
01AC:  GOTO   1AE
442
01AD:  BSF    23.2
443
....................       } 
444
....................  
445
....................       a=read_adc(); 
446
01AE:  BSF    1F.2
447
01AF:  BTFSC  1F.2
448
01B0:  GOTO   1AF
449
01B1:  MOVF   1E,W
450
01B2:  MOVWF  24
451
....................  
452
....................       set_adc_channel(4); 
453
01B3:  MOVLW  20
454
01B4:  MOVWF  78
455
01B5:  MOVF   1F,W
456
01B6:  ANDLW  C7
457
01B7:  IORWF  78,W
458
01B8:  MOVWF  1F
459
....................       if(a<TRESHOLD_MAX) 
460
01B9:  MOVF   24,W
461
01BA:  SUBLW  45
462
01BB:  BTFSS  03.0
463
01BC:  GOTO   1C6
464
....................       { 
465
....................          if(a>TRESHOLD_MIN) 
466
01BD:  MOVF   24,W
467
01BE:  SUBLW  32
468
01BF:  BTFSC  03.0
469
01C0:  GOTO   1C5
470
....................          { 
471
....................             cidla |= (last_cidla & 0b00001000); 
472
01C1:  MOVF   21,W
473
01C2:  ANDLW  08
474
01C3:  IORWF  23,F
475
....................          } 
476
....................          else cidla |= 0b00001000; 
477
01C4:  GOTO   1C6
478
01C5:  BSF    23.3
479
....................       } 
480
....................       a=read_adc(); 
481
01C6:  BSF    1F.2
482
01C7:  BTFSC  1F.2
483
01C8:  GOTO   1C7
484
01C9:  MOVF   1E,W
485
01CA:  MOVWF  24
486
....................  
487
....................       set_adc_channel(5); 
488
01CB:  MOVLW  28
489
01CC:  MOVWF  78
490
01CD:  MOVF   1F,W
491
01CE:  ANDLW  C7
492
01CF:  IORWF  78,W
493
01D0:  MOVWF  1F
494
....................  
495
....................       if(a<TRESHOLD_MAX) 
496
01D1:  MOVF   24,W
497
01D2:  SUBLW  45
498
01D3:  BTFSS  03.0
499
01D4:  GOTO   1DE
500
....................       { 
501
....................          if(a>TRESHOLD_MIN) 
502
01D5:  MOVF   24,W
503
01D6:  SUBLW  32
504
01D7:  BTFSC  03.0
505
01D8:  GOTO   1DD
506
....................          { 
507
....................             cidla |= (last_cidla & 0b00010000); 
508
01D9:  MOVF   21,W
509
01DA:  ANDLW  10
510
01DB:  IORWF  23,F
511
....................          } 
512
....................          else cidla |= 0b00010000; 
513
01DC:  GOTO   1DE
514
01DD:  BSF    23.4
515
....................       } 
516
....................       a=read_adc(); 
517
01DE:  BSF    1F.2
518
01DF:  BTFSC  1F.2
519
01E0:  GOTO   1DF
520
01E1:  MOVF   1E,W
521
01E2:  MOVWF  24
522
....................  
523
....................       set_adc_channel(6); 
524
01E3:  MOVLW  30
525
01E4:  MOVWF  78
526
01E5:  MOVF   1F,W
527
01E6:  ANDLW  C7
528
01E7:  IORWF  78,W
529
01E8:  MOVWF  1F
530
....................       if(a<TRESHOLD_MAX) 
531
01E9:  MOVF   24,W
532
01EA:  SUBLW  45
533
01EB:  BTFSS  03.0
534
01EC:  GOTO   1F6
535
....................       { 
536
....................          if(a>TRESHOLD_MIN) 
537
01ED:  MOVF   24,W
538
01EE:  SUBLW  32
539
01EF:  BTFSC  03.0
540
01F0:  GOTO   1F5
541
....................          { 
542
....................             cidla |= (last_cidla & 0b00100000); 
543
01F1:  MOVF   21,W
544
01F2:  ANDLW  20
545
01F3:  IORWF  23,F
546
....................          } 
547
....................          else cidla |= 0b00100000; 
548
01F4:  GOTO   1F6
549
01F5:  BSF    23.5
550
....................       } 
551
....................       a=read_adc(); 
552
01F6:  BSF    1F.2
553
01F7:  BTFSC  1F.2
554
01F8:  GOTO   1F7
555
01F9:  MOVF   1E,W
556
01FA:  MOVWF  24
557
....................  
558
....................       if(a<TRESHOLD_MAX) 
559
01FB:  MOVF   24,W
560
01FC:  SUBLW  45
561
01FD:  BTFSS  03.0
562
01FE:  GOTO   208
563
....................       { 
564
....................          if(a>TRESHOLD_MIN) 
565
01FF:  MOVF   24,W
566
0200:  SUBLW  32
567
0201:  BTFSC  03.0
568
0202:  GOTO   207
569
....................          { 
570
....................             cidla |=(last_cidla & 0b01000000); 
571
0203:  MOVF   21,W
572
0204:  ANDLW  40
573
0205:  IORWF  23,F
574
....................          } 
575
....................          else cidla |= 0b01000000; 
576
0206:  GOTO   208
577
0207:  BSF    23.6
578
....................       } 
579
....................  
580
....................       last_cidla=cidla; 
581
0208:  MOVF   23,W
582
0209:  MOVWF  21
583
....................  
584
....................       if (!input(IRRX)) {if (shure<255) shure++;} else {shure=0;}; 
585
020A:  BSF    03.5
586
020B:  BSF    06.0
587
020C:  BCF    03.5
588
020D:  BTFSC  06.0
589
020E:  GOTO   214
590
020F:  INCFSZ 22,W
591
0210:  GOTO   212
592
0211:  GOTO   213
593
0212:  INCF   22,F
594
0213:  GOTO   215
595
0214:  CLRF   22
596
....................       if (shure>CIHLA) cidla|=0b10000000; 
597
0215:  MOVF   22,W
598
0216:  SUBLW  0A
599
0217:  BTFSS  03.0
600
0218:  BSF    23.7
601
....................  
602
....................       cidla=~cidla; 
603
0219:  COMF   23,F
604
....................       spi_write(cidla); 
605
021A:  MOVF   23,W
606
021B:  MOVWF  13
607
021C:  BSF    03.5
608
021D:  BTFSC  14.0
609
021E:  GOTO   221
610
021F:  BCF    03.5
611
0220:  GOTO   21C
612
....................    } 
613
0221:  BCF    03.5
614
0222:  GOTO   158
615
.................... } 
616
0223:  SLEEP
617
 
618
Configuration Fuses:
619
   Word  1: 3F38   NOWDT NOPUT MCLR NOBROWNOUT NOLVP NOCPD NOWRT NODEBUG CCPB0 NOPROTECT INTRC_IO
620
   Word  2: 3FFC   NOFCMEN NOIESO