Subversion Repositories svnkaklik

Rev

Details | Last modification | View Log

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