Subversion Repositories svnkaklik

Rev

Go to most recent revision | Details | Last modification | View Log

Rev Author Line No. Line
2 kaklik 1
CCS PCM C Compiler, Version 3.245, 27853               13-V-06 00:33
2
 
3
               Filename: D:\KAKLIK\roboti\istrobot\3Orbis\vystava\cidla\cidla.lst
4
 
5
               ROM used: 548 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
002A:  MOVLW  28
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    2A,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
.................... #define  SW2            PIN_A7 
99
....................  
100
....................  
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
....................    unsigned short int negace; 
145
....................  
146
....................    setup_adc_ports(sAN0|sAN1|sAN2|sAN3|sAN4|sAN5|sAN6|VSS_VDD); 
147
00C2:  BCF    1F.4
148
00C3:  BCF    1F.5
149
00C4:  MOVF   1B,W
150
00C5:  ANDLW  80
151
00C6:  IORLW  7F
152
00C7:  MOVWF  1B
153
....................    setup_adc(ADC_CLOCK_INTERNAL); 
154
00C8:  BCF    1F.6
155
00C9:  BCF    03.5
156
00CA:  BSF    1F.6
157
00CB:  BSF    1F.7
158
00CC:  BSF    03.5
159
00CD:  BCF    1F.7
160
00CE:  BCF    03.5
161
00CF:  BSF    1F.0
162
....................    setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); 
163
00D0:  BSF    03.5
164
00D1:  MOVF   01,W
165
00D2:  ANDLW  C7
166
00D3:  IORLW  08
167
00D4:  MOVWF  01
168
....................    setup_timer_1(T1_DISABLED); 
169
00D5:  BCF    03.5
170
00D6:  CLRF   10
171
....................    setup_timer_2(T2_DISABLED,0,1); 
172
00D7:  MOVLW  00
173
00D8:  MOVWF  78
174
00D9:  MOVWF  12
175
00DA:  MOVLW  00
176
00DB:  BSF    03.5
177
00DC:  MOVWF  12
178
....................    setup_comparator(NC_NC_NC_NC); 
179
00DD:  MOVLW  07
180
00DE:  MOVWF  1C
181
00DF:  MOVF   05,W
182
00E0:  CLRWDT
183
00E1:  MOVLW  02
184
00E2:  MOVWF  77
185
00E3:  DECFSZ 77,F
186
00E4:  GOTO   0E3
187
00E5:  NOP
188
00E6:  NOP
189
00E7:  MOVF   1C,W
190
00E8:  BCF    03.5
191
00E9:  BCF    0D.6
192
....................    setup_vref(FALSE); 
193
00EA:  BSF    03.5
194
00EB:  CLRF   1D
195
....................  
196
....................    Delay_ms(500); 
197
00EC:  MOVLW  02
198
00ED:  BCF    03.5
199
00EE:  MOVWF  27
200
00EF:  MOVLW  FA
201
00F0:  MOVWF  28
202
00F1:  CALL   02A
203
00F2:  DECFSZ 27,F
204
00F3:  GOTO   0EF
205
....................    setup_spi(SPI_SLAVE|SPI_H_TO_L|SPI_SS_DISABLED); 
206
00F4:  BCF    14.5
207
00F5:  BSF    03.5
208
00F6:  BCF    06.2
209
00F7:  BSF    06.1
210
00F8:  BSF    06.4
211
00F9:  MOVLW  35
212
00FA:  BCF    03.5
213
00FB:  MOVWF  14
214
00FC:  MOVLW  40
215
00FD:  BSF    03.5
216
00FE:  MOVWF  14
217
....................  
218
....................    // diagnostika 
219
....................    printf("\n\r"); 
220
00FF:  BCF    03.5
221
0100:  CLRF   27
222
0101:  MOVF   27,W
223
0102:  CALL   004
224
0103:  IORLW  00
225
0104:  BTFSC  03.2
226
0105:  GOTO   10A
227
0106:  INCF   27,F
228
0107:  MOVWF  2A
229
0108:  CALL   041
230
0109:  GOTO   101
231
....................    Delay_ms(100); 
232
010A:  MOVLW  64
233
010B:  MOVWF  28
234
010C:  CALL   02A
235
....................    printf("***\n\r"); 
236
010D:  CLRF   27
237
010E:  MOVF   27,W
238
010F:  CALL   00B
239
0110:  IORLW  00
240
0111:  BTFSC  03.2
241
0112:  GOTO   117
242
0113:  INCF   27,F
243
0114:  MOVWF  2A
244
0115:  CALL   041
245
0116:  GOTO   10E
246
....................    Delay_ms(100); 
247
0117:  MOVLW  64
248
0118:  MOVWF  28
249
0119:  CALL   02A
250
....................  
251
....................    for (n=0; n<=6; n++) 
252
011A:  CLRF   25
253
011B:  MOVF   25,W
254
011C:  SUBLW  06
255
011D:  BTFSS  03.0
256
011E:  GOTO   157
257
....................    { 
258
....................       set_adc_channel(n); 
259
011F:  RLF    25,W
260
0120:  MOVWF  77
261
0121:  RLF    77,F
262
0122:  RLF    77,F
263
0123:  MOVLW  F8
264
0124:  ANDWF  77,F
265
0125:  MOVF   1F,W
266
0126:  ANDLW  C7
267
0127:  IORWF  77,W
268
0128:  MOVWF  1F
269
....................       Delay_ms(100); 
270
0129:  MOVLW  64
271
012A:  MOVWF  28
272
012B:  CALL   02A
273
....................       a=read_adc(); 
274
012C:  BSF    1F.2
275
012D:  BTFSC  1F.2
276
012E:  GOTO   12D
277
012F:  MOVF   1E,W
278
0130:  MOVWF  24
279
....................       printf("sensor %u - %u\n\r",n,a); 
280
0131:  CLRF   27
281
0132:  MOVF   27,W
282
0133:  CALL   015
283
0134:  INCF   27,F
284
0135:  MOVWF  77
285
0136:  MOVWF  2A
286
0137:  CALL   041
287
0138:  MOVLW  07
288
0139:  SUBWF  27,W
289
013A:  BTFSS  03.2
290
013B:  GOTO   132
291
013C:  MOVF   25,W
292
013D:  MOVWF  28
293
013E:  MOVLW  1B
294
013F:  MOVWF  29
295
0140:  CALL   07C
296
0141:  MOVLW  20
297
0142:  MOVWF  2A
298
0143:  CALL   041
299
0144:  MOVLW  2D
300
0145:  MOVWF  2A
301
0146:  CALL   041
302
0147:  MOVLW  20
303
0148:  MOVWF  2A
304
0149:  CALL   041
305
014A:  MOVF   24,W
306
014B:  MOVWF  28
307
014C:  MOVLW  1B
308
014D:  MOVWF  29
309
014E:  CALL   07C
310
014F:  MOVLW  0A
311
0150:  MOVWF  2A
312
0151:  CALL   041
313
0152:  MOVLW  0D
314
0153:  MOVWF  2A
315
0154:  CALL   041
316
....................    } 
317
0155:  INCF   25,F
318
0156:  GOTO   11B
319
....................  
320
....................    shure=0; 
321
0157:  CLRF   22
322
.................... //   if(input(SW2)) negace = true; 
323
.................... //   else negace = false; 
324
....................    while(true) 
325
....................    { 
326
....................       set_adc_channel(0); 
327
0158:  MOVLW  00
328
0159:  MOVWF  78
329
015A:  MOVF   1F,W
330
015B:  ANDLW  C7
331
015C:  IORWF  78,W
332
015D:  MOVWF  1F
333
....................       cidla=0; 
334
015E:  CLRF   23
335
....................       Delay_us(10); 
336
015F:  CLRWDT
337
0160:  MOVLW  02
338
0161:  MOVWF  77
339
0162:  DECFSZ 77,F
340
0163:  GOTO   162
341
0164:  NOP
342
0165:  NOP
343
....................       a=read_adc(); 
344
0166:  BSF    1F.2
345
0167:  BTFSC  1F.2
346
0168:  GOTO   167
347
0169:  MOVF   1E,W
348
016A:  MOVWF  24
349
....................  
350
....................       set_adc_channel(1); 
351
016B:  MOVLW  08
352
016C:  MOVWF  78
353
016D:  MOVF   1F,W
354
016E:  ANDLW  C7
355
016F:  IORWF  78,W
356
0170:  MOVWF  1F
357
....................       if(a<TRESHOLD_MAX)         //hystereze cidel 
358
0171:  MOVF   24,W
359
0172:  SUBLW  45
360
0173:  BTFSS  03.0
361
0174:  GOTO   17E
362
....................       { 
363
....................          if(a>TRESHOLD_MIN) 
364
0175:  MOVF   24,W
365
0176:  SUBLW  32
366
0177:  BTFSC  03.0
367
0178:  GOTO   17D
368
....................          { 
369
....................             cidla |= (last_cidla & 0b00000001); 
370
0179:  MOVF   21,W
371
017A:  ANDLW  01
372
017B:  IORWF  23,F
373
....................          } 
374
....................          else cidla |= 0b00000001; 
375
017C:  GOTO   17E
376
017D:  BSF    23.0
377
....................       } 
378
....................  
379
....................       a=read_adc(); 
380
017E:  BSF    1F.2
381
017F:  BTFSC  1F.2
382
0180:  GOTO   17F
383
0181:  MOVF   1E,W
384
0182:  MOVWF  24
385
....................  
386
....................       set_adc_channel(2); 
387
0183:  MOVLW  10
388
0184:  MOVWF  78
389
0185:  MOVF   1F,W
390
0186:  ANDLW  C7
391
0187:  IORWF  78,W
392
0188:  MOVWF  1F
393
....................       if(a<TRESHOLD_MAX) 
394
0189:  MOVF   24,W
395
018A:  SUBLW  45
396
018B:  BTFSS  03.0
397
018C:  GOTO   196
398
....................       { 
399
....................          if(a>TRESHOLD_MIN) 
400
018D:  MOVF   24,W
401
018E:  SUBLW  32
402
018F:  BTFSC  03.0
403
0190:  GOTO   195
404
....................          { 
405
....................             cidla |= (last_cidla & 0b00000010); 
406
0191:  MOVF   21,W
407
0192:  ANDLW  02
408
0193:  IORWF  23,F
409
....................          } 
410
....................          else cidla |= 0b00000010; 
411
0194:  GOTO   196
412
0195:  BSF    23.1
413
....................       } 
414
....................  
415
....................       a=read_adc(); 
416
0196:  BSF    1F.2
417
0197:  BTFSC  1F.2
418
0198:  GOTO   197
419
0199:  MOVF   1E,W
420
019A:  MOVWF  24
421
....................  
422
....................       set_adc_channel(3); 
423
019B:  MOVLW  18
424
019C:  MOVWF  78
425
019D:  MOVF   1F,W
426
019E:  ANDLW  C7
427
019F:  IORWF  78,W
428
01A0:  MOVWF  1F
429
....................       if(a<TRESHOLD_MAX) 
430
01A1:  MOVF   24,W
431
01A2:  SUBLW  45
432
01A3:  BTFSS  03.0
433
01A4:  GOTO   1AE
434
....................       { 
435
....................          if(a>TRESHOLD_MIN) 
436
01A5:  MOVF   24,W
437
01A6:  SUBLW  32
438
01A7:  BTFSC  03.0
439
01A8:  GOTO   1AD
440
....................          { 
441
....................             cidla |= (last_cidla & 0b00000100); 
442
01A9:  MOVF   21,W
443
01AA:  ANDLW  04
444
01AB:  IORWF  23,F
445
....................          } 
446
....................          else cidla |= 0b00000100; 
447
01AC:  GOTO   1AE
448
01AD:  BSF    23.2
449
....................       } 
450
....................  
451
....................       a=read_adc(); 
452
01AE:  BSF    1F.2
453
01AF:  BTFSC  1F.2
454
01B0:  GOTO   1AF
455
01B1:  MOVF   1E,W
456
01B2:  MOVWF  24
457
....................  
458
....................       set_adc_channel(4); 
459
01B3:  MOVLW  20
460
01B4:  MOVWF  78
461
01B5:  MOVF   1F,W
462
01B6:  ANDLW  C7
463
01B7:  IORWF  78,W
464
01B8:  MOVWF  1F
465
....................       if(a<TRESHOLD_MAX) 
466
01B9:  MOVF   24,W
467
01BA:  SUBLW  45
468
01BB:  BTFSS  03.0
469
01BC:  GOTO   1C6
470
....................       { 
471
....................          if(a>TRESHOLD_MIN) 
472
01BD:  MOVF   24,W
473
01BE:  SUBLW  32
474
01BF:  BTFSC  03.0
475
01C0:  GOTO   1C5
476
....................          { 
477
....................             cidla |= (last_cidla & 0b00001000); 
478
01C1:  MOVF   21,W
479
01C2:  ANDLW  08
480
01C3:  IORWF  23,F
481
....................          } 
482
....................          else cidla |= 0b00001000; 
483
01C4:  GOTO   1C6
484
01C5:  BSF    23.3
485
....................       } 
486
....................       a=read_adc(); 
487
01C6:  BSF    1F.2
488
01C7:  BTFSC  1F.2
489
01C8:  GOTO   1C7
490
01C9:  MOVF   1E,W
491
01CA:  MOVWF  24
492
....................  
493
....................       set_adc_channel(5); 
494
01CB:  MOVLW  28
495
01CC:  MOVWF  78
496
01CD:  MOVF   1F,W
497
01CE:  ANDLW  C7
498
01CF:  IORWF  78,W
499
01D0:  MOVWF  1F
500
....................  
501
....................       if(a<TRESHOLD_MAX) 
502
01D1:  MOVF   24,W
503
01D2:  SUBLW  45
504
01D3:  BTFSS  03.0
505
01D4:  GOTO   1DE
506
....................       { 
507
....................          if(a>TRESHOLD_MIN) 
508
01D5:  MOVF   24,W
509
01D6:  SUBLW  32
510
01D7:  BTFSC  03.0
511
01D8:  GOTO   1DD
512
....................          { 
513
....................             cidla |= (last_cidla & 0b00010000); 
514
01D9:  MOVF   21,W
515
01DA:  ANDLW  10
516
01DB:  IORWF  23,F
517
....................          } 
518
....................          else cidla |= 0b00010000; 
519
01DC:  GOTO   1DE
520
01DD:  BSF    23.4
521
....................       } 
522
....................       a=read_adc(); 
523
01DE:  BSF    1F.2
524
01DF:  BTFSC  1F.2
525
01E0:  GOTO   1DF
526
01E1:  MOVF   1E,W
527
01E2:  MOVWF  24
528
....................  
529
....................       set_adc_channel(6); 
530
01E3:  MOVLW  30
531
01E4:  MOVWF  78
532
01E5:  MOVF   1F,W
533
01E6:  ANDLW  C7
534
01E7:  IORWF  78,W
535
01E8:  MOVWF  1F
536
....................       if(a<TRESHOLD_MAX) 
537
01E9:  MOVF   24,W
538
01EA:  SUBLW  45
539
01EB:  BTFSS  03.0
540
01EC:  GOTO   1F6
541
....................       { 
542
....................          if(a>TRESHOLD_MIN) 
543
01ED:  MOVF   24,W
544
01EE:  SUBLW  32
545
01EF:  BTFSC  03.0
546
01F0:  GOTO   1F5
547
....................          { 
548
....................             cidla |= (last_cidla & 0b00100000); 
549
01F1:  MOVF   21,W
550
01F2:  ANDLW  20
551
01F3:  IORWF  23,F
552
....................          } 
553
....................          else cidla |= 0b00100000; 
554
01F4:  GOTO   1F6
555
01F5:  BSF    23.5
556
....................       } 
557
....................       a=read_adc(); 
558
01F6:  BSF    1F.2
559
01F7:  BTFSC  1F.2
560
01F8:  GOTO   1F7
561
01F9:  MOVF   1E,W
562
01FA:  MOVWF  24
563
....................  
564
....................       if(a<TRESHOLD_MAX) 
565
01FB:  MOVF   24,W
566
01FC:  SUBLW  45
567
01FD:  BTFSS  03.0
568
01FE:  GOTO   208
569
....................       { 
570
....................          if(a>TRESHOLD_MIN) 
571
01FF:  MOVF   24,W
572
0200:  SUBLW  32
573
0201:  BTFSC  03.0
574
0202:  GOTO   207
575
....................          { 
576
....................             cidla |=(last_cidla & 0b01000000); 
577
0203:  MOVF   21,W
578
0204:  ANDLW  40
579
0205:  IORWF  23,F
580
....................          } 
581
....................          else cidla |= 0b01000000; 
582
0206:  GOTO   208
583
0207:  BSF    23.6
584
....................       } 
585
....................  
586
....................       last_cidla=cidla; 
587
0208:  MOVF   23,W
588
0209:  MOVWF  21
589
....................  
590
....................       if (!input(IRRX)) {if (shure<255) shure++;} else {shure=0;}; 
591
020A:  BSF    03.5
592
020B:  BSF    06.0
593
020C:  BCF    03.5
594
020D:  BTFSC  06.0
595
020E:  GOTO   214
596
020F:  INCFSZ 22,W
597
0210:  GOTO   212
598
0211:  GOTO   213
599
0212:  INCF   22,F
600
0213:  GOTO   215
601
0214:  CLRF   22
602
....................       if (shure>CIHLA) cidla|=0b10000000; 
603
0215:  MOVF   22,W
604
0216:  SUBLW  0A
605
0217:  BTFSS  03.0
606
0218:  BSF    23.7
607
....................  
608
.................... /*      if (negace == true) cidla=~cidla; 
609
....................       else 
610
....................       {    
611
....................          if(!bit_test(cidla,7)) bit_set(cidla,7); 
612
....................          else bit_clear(cidla,7); 
613
....................       }*/ 
614
....................        
615
....................       cidla=~cidla; 
616
0219:  COMF   23,F
617
....................        
618
....................       spi_write(cidla); 
619
021A:  MOVF   23,W
620
021B:  MOVWF  13
621
021C:  BSF    03.5
622
021D:  BTFSC  14.0
623
021E:  GOTO   221
624
021F:  BCF    03.5
625
0220:  GOTO   21C
626
....................    } 
627
0221:  BCF    03.5
628
0222:  GOTO   158
629
.................... } 
630
0223:  SLEEP
631
 
632
Configuration Fuses:
633
   Word  1: 3F38   NOWDT NOPUT MCLR NOBROWNOUT NOLVP NOCPD NOWRT NODEBUG CCPB0 NOPROTECT INTRC_IO
634
   Word  2: 3FFC   NOFCMEN NOIESO