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               16-IV-06 23:31
2
 
3
               Filename: D:\KAKLIK\programy\PIC_C\roboti\istrobot\3Orbis\cidla\cidla.lst
4
 
5
               ROM used: 282 words (7%)
6
                         Largest free fragment is 2048
7
               RAM used: 12 (7%) at main() level
8
                         12 (7%) worst case
9
               Stack:    0 locations
10
 
11
*
12
0000:  MOVLW  00
13
0001:  MOVWF  0A
14
0002:  GOTO   004
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
....................  
27
.................... //#include <stdlib.h> 
28
....................  
29
.................... #use rs232(baud=110,parity=N,xmit=PIN_B1,rcv=PIN_B0,bits=8,restart_wdt) 
30
....................  
31
.................... #define IRRX      PIN_B0 
32
....................  
33
.................... #define  TRESHOLD_MAX   60    // rozhodovaci uroven  pro cidla cerna/bila 
34
.................... #define  TRESHOLD_MIN   40 
35
.................... #define  CIHLA          50    // doba, po kterou musi byt detekovana cihla 
36
....................  
37
.................... unsigned int8 radius;         // co cidla vidi 
38
.................... unsigned int8 last_radius;    // rozsah 
39
.................... unsigned int8 last_cidla;     // co cidla videla minule 
40
.................... unsigned int8 shure;          // citac doby, po kterou musi byt detekovana cihla 
41
....................  
42
.................... //tuning 
43
.................... /*#define  PULZACE  3  // urcuje rychlost pulzovani pomoci PWM 
44
....................  
45
.................... //Vystup PWM je na PIN_B3 
46
.................... //////////////////////////////////////////////////////////////////////////////// 
47
.................... void pulzovani()  // postupne rozsvecuje a zhasina podsvetleni 
48
.................... { 
49
.................... unsigned int8 i,n; 
50
....................    for(n=0;n<=3;n++) 
51
....................    { 
52
....................       for(i=0;i<255;i++) {set_pwm1_duty(i); Delay_ms(PULZACE);} // rozsvecovani 
53
....................       for(i=255;i>0;i--) {set_pwm1_duty(i); Delay_ms(PULZACE);} // zhasinani 
54
....................    } 
55
.................... } 
56
.................... */ 
57
.................... //////////////////////////////////////////////////////////////////////////////// 
58
.................... void main() 
59
.................... { 
60
0004:  CLRF   04
61
0005:  MOVLW  1F
62
0006:  ANDWF  03,F
63
0007:  MOVLW  60
64
0008:  BSF    03.5
65
0009:  MOVWF  0F
66
000A:  BCF    06.1
67
000B:  BCF    03.5
68
000C:  BSF    06.1
69
000D:  BSF    03.5
70
000E:  BCF    1F.4
71
000F:  BCF    1F.5
72
0010:  MOVF   1B,W
73
0011:  ANDLW  80
74
0012:  MOVWF  1B
75
0013:  MOVLW  07
76
0014:  MOVWF  1C
77
....................    int8 cidla; 
78
....................    unsigned int8 a; 
79
....................    unsigned int8 n; 
80
....................  
81
....................    setup_adc_ports(sAN0|sAN1|sAN2|sAN3|sAN4|sAN5|sAN6|VSS_VDD); 
82
0015:  BCF    1F.4
83
0016:  BCF    1F.5
84
0017:  MOVF   1B,W
85
0018:  ANDLW  80
86
0019:  IORLW  7F
87
001A:  MOVWF  1B
88
....................    setup_adc(ADC_CLOCK_INTERNAL); 
89
001B:  BCF    1F.6
90
001C:  BCF    03.5
91
001D:  BSF    1F.6
92
001E:  BSF    1F.7
93
001F:  BSF    03.5
94
0020:  BCF    1F.7
95
0021:  BCF    03.5
96
0022:  BSF    1F.0
97
....................    setup_spi(SPI_SLAVE|SPI_H_TO_L|SPI_SS_DISABLED); 
98
0023:  BCF    14.5
99
0024:  BSF    03.5
100
0025:  BCF    06.2
101
0026:  BSF    06.1
102
0027:  BSF    06.4
103
0028:  MOVLW  35
104
0029:  BCF    03.5
105
002A:  MOVWF  14
106
002B:  MOVLW  40
107
002C:  BSF    03.5
108
002D:  MOVWF  14
109
....................    setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); 
110
002E:  MOVF   01,W
111
002F:  ANDLW  C7
112
0030:  IORLW  08
113
0031:  MOVWF  01
114
....................    setup_timer_1(T1_DISABLED); 
115
0032:  BCF    03.5
116
0033:  CLRF   10
117
....................    setup_timer_2(T2_DISABLED,0,1); 
118
0034:  MOVLW  00
119
0035:  MOVWF  78
120
0036:  MOVWF  12
121
0037:  MOVLW  00
122
0038:  BSF    03.5
123
0039:  MOVWF  12
124
....................    setup_comparator(NC_NC_NC_NC); 
125
003A:  MOVLW  07
126
003B:  MOVWF  1C
127
003C:  MOVF   05,W
128
003D:  CLRWDT
129
003E:  MOVLW  02
130
003F:  MOVWF  77
131
0040:  DECFSZ 77,F
132
0041:  GOTO   040
133
0042:  NOP
134
0043:  NOP
135
0044:  MOVF   1C,W
136
0045:  BCF    03.5
137
0046:  BCF    0D.6
138
....................    setup_vref(FALSE); 
139
0047:  BSF    03.5
140
0048:  CLRF   1D
141
....................  
142
....................    last_radius=0b00001000;  // minimalni rozsah snimani od stredu 
143
0049:  MOVLW  08
144
004A:  BCF    03.5
145
004B:  MOVWF  21
146
....................    last_cidla=0b00001000; 
147
004C:  MOVWF  22
148
....................  
149
....................    shure=0; 
150
004D:  CLRF   23
151
....................  
152
....................    while(true) 
153
....................    { 
154
....................       set_adc_channel(0); 
155
004E:  MOVLW  00
156
004F:  MOVWF  78
157
0050:  MOVF   1F,W
158
0051:  ANDLW  C7
159
0052:  IORWF  78,W
160
0053:  MOVWF  1F
161
....................       cidla=0; 
162
0054:  CLRF   24
163
....................       Delay_us(10); 
164
0055:  CLRWDT
165
0056:  MOVLW  02
166
0057:  MOVWF  77
167
0058:  DECFSZ 77,F
168
0059:  GOTO   058
169
005A:  NOP
170
005B:  NOP
171
....................       a=read_adc(); 
172
005C:  BSF    1F.2
173
005D:  BTFSC  1F.2
174
005E:  GOTO   05D
175
005F:  MOVF   1E,W
176
0060:  MOVWF  25
177
....................  
178
....................       set_adc_channel(1); 
179
0061:  MOVLW  08
180
0062:  MOVWF  78
181
0063:  MOVF   1F,W
182
0064:  ANDLW  C7
183
0065:  IORWF  78,W
184
0066:  MOVWF  1F
185
....................       if(a<TRESHOLD_MAX)         //hystereze cidel 
186
0067:  MOVF   25,W
187
0068:  SUBLW  3B
188
0069:  BTFSS  03.0
189
006A:  GOTO   074
190
....................       { 
191
....................          if(a>TRESHOLD_MIN) 
192
006B:  MOVF   25,W
193
006C:  SUBLW  28
194
006D:  BTFSC  03.0
195
006E:  GOTO   073
196
....................          { 
197
....................             cidla |= (last_cidla & 0b00000001); 
198
006F:  MOVF   22,W
199
0070:  ANDLW  01
200
0071:  IORWF  24,F
201
....................          } 
202
....................          else cidla |= 0b00000001; 
203
0072:  GOTO   074
204
0073:  BSF    24.0
205
....................       } 
206
....................  
207
....................       a=read_adc(); 
208
0074:  BSF    1F.2
209
0075:  BTFSC  1F.2
210
0076:  GOTO   075
211
0077:  MOVF   1E,W
212
0078:  MOVWF  25
213
....................  
214
....................       set_adc_channel(2); 
215
0079:  MOVLW  10
216
007A:  MOVWF  78
217
007B:  MOVF   1F,W
218
007C:  ANDLW  C7
219
007D:  IORWF  78,W
220
007E:  MOVWF  1F
221
....................       if(a<TRESHOLD_MAX) 
222
007F:  MOVF   25,W
223
0080:  SUBLW  3B
224
0081:  BTFSS  03.0
225
0082:  GOTO   08C
226
....................       { 
227
....................          if(a>TRESHOLD_MIN) 
228
0083:  MOVF   25,W
229
0084:  SUBLW  28
230
0085:  BTFSC  03.0
231
0086:  GOTO   08B
232
....................          { 
233
....................             cidla |= (last_cidla & 0b00000010); 
234
0087:  MOVF   22,W
235
0088:  ANDLW  02
236
0089:  IORWF  24,F
237
....................          } 
238
....................          else cidla |= 0b00000010; 
239
008A:  GOTO   08C
240
008B:  BSF    24.1
241
....................       } 
242
....................  
243
....................       a=read_adc(); 
244
008C:  BSF    1F.2
245
008D:  BTFSC  1F.2
246
008E:  GOTO   08D
247
008F:  MOVF   1E,W
248
0090:  MOVWF  25
249
....................  
250
....................       set_adc_channel(3); 
251
0091:  MOVLW  18
252
0092:  MOVWF  78
253
0093:  MOVF   1F,W
254
0094:  ANDLW  C7
255
0095:  IORWF  78,W
256
0096:  MOVWF  1F
257
....................       if(a<TRESHOLD_MAX) 
258
0097:  MOVF   25,W
259
0098:  SUBLW  3B
260
0099:  BTFSS  03.0
261
009A:  GOTO   0A4
262
....................       { 
263
....................          if(a>TRESHOLD_MIN) 
264
009B:  MOVF   25,W
265
009C:  SUBLW  28
266
009D:  BTFSC  03.0
267
009E:  GOTO   0A3
268
....................          { 
269
....................             cidla |= (last_cidla & 0b00000100); 
270
009F:  MOVF   22,W
271
00A0:  ANDLW  04
272
00A1:  IORWF  24,F
273
....................          } 
274
....................          else cidla |= 0b00000100; 
275
00A2:  GOTO   0A4
276
00A3:  BSF    24.2
277
....................       } 
278
....................  
279
....................       a=read_adc(); 
280
00A4:  BSF    1F.2
281
00A5:  BTFSC  1F.2
282
00A6:  GOTO   0A5
283
00A7:  MOVF   1E,W
284
00A8:  MOVWF  25
285
....................  
286
....................       set_adc_channel(4); 
287
00A9:  MOVLW  20
288
00AA:  MOVWF  78
289
00AB:  MOVF   1F,W
290
00AC:  ANDLW  C7
291
00AD:  IORWF  78,W
292
00AE:  MOVWF  1F
293
....................       if(a<TRESHOLD_MAX) 
294
00AF:  MOVF   25,W
295
00B0:  SUBLW  3B
296
00B1:  BTFSS  03.0
297
00B2:  GOTO   0BC
298
....................       { 
299
....................          if(a>TRESHOLD_MIN) 
300
00B3:  MOVF   25,W
301
00B4:  SUBLW  28
302
00B5:  BTFSC  03.0
303
00B6:  GOTO   0BB
304
....................          { 
305
....................             cidla |= (last_cidla & 0b00001000); 
306
00B7:  MOVF   22,W
307
00B8:  ANDLW  08
308
00B9:  IORWF  24,F
309
....................          } 
310
....................          else cidla |= 0b00001000; 
311
00BA:  GOTO   0BC
312
00BB:  BSF    24.3
313
....................       } 
314
....................       a=read_adc(); 
315
00BC:  BSF    1F.2
316
00BD:  BTFSC  1F.2
317
00BE:  GOTO   0BD
318
00BF:  MOVF   1E,W
319
00C0:  MOVWF  25
320
....................  
321
....................       set_adc_channel(5); 
322
00C1:  MOVLW  28
323
00C2:  MOVWF  78
324
00C3:  MOVF   1F,W
325
00C4:  ANDLW  C7
326
00C5:  IORWF  78,W
327
00C6:  MOVWF  1F
328
....................  
329
....................       if(a<TRESHOLD_MAX) 
330
00C7:  MOVF   25,W
331
00C8:  SUBLW  3B
332
00C9:  BTFSS  03.0
333
00CA:  GOTO   0D4
334
....................       { 
335
....................          if(a>TRESHOLD_MIN) 
336
00CB:  MOVF   25,W
337
00CC:  SUBLW  28
338
00CD:  BTFSC  03.0
339
00CE:  GOTO   0D3
340
....................          { 
341
....................             cidla |= (last_cidla & 0b00010000); 
342
00CF:  MOVF   22,W
343
00D0:  ANDLW  10
344
00D1:  IORWF  24,F
345
....................          } 
346
....................          else cidla |= 0b00010000; 
347
00D2:  GOTO   0D4
348
00D3:  BSF    24.4
349
....................       } 
350
....................       a=read_adc(); 
351
00D4:  BSF    1F.2
352
00D5:  BTFSC  1F.2
353
00D6:  GOTO   0D5
354
00D7:  MOVF   1E,W
355
00D8:  MOVWF  25
356
....................  
357
....................       set_adc_channel(6); 
358
00D9:  MOVLW  30
359
00DA:  MOVWF  78
360
00DB:  MOVF   1F,W
361
00DC:  ANDLW  C7
362
00DD:  IORWF  78,W
363
00DE:  MOVWF  1F
364
....................       if(a<TRESHOLD_MAX) 
365
00DF:  MOVF   25,W
366
00E0:  SUBLW  3B
367
00E1:  BTFSS  03.0
368
00E2:  GOTO   0EC
369
....................       { 
370
....................          if(a>TRESHOLD_MIN) 
371
00E3:  MOVF   25,W
372
00E4:  SUBLW  28
373
00E5:  BTFSC  03.0
374
00E6:  GOTO   0EB
375
....................          { 
376
....................             cidla |= (last_cidla & 0b00100000); 
377
00E7:  MOVF   22,W
378
00E8:  ANDLW  20
379
00E9:  IORWF  24,F
380
....................          } 
381
....................          else cidla |= 0b00100000; 
382
00EA:  GOTO   0EC
383
00EB:  BSF    24.5
384
....................       } 
385
....................       a=read_adc(); 
386
00EC:  BSF    1F.2
387
00ED:  BTFSC  1F.2
388
00EE:  GOTO   0ED
389
00EF:  MOVF   1E,W
390
00F0:  MOVWF  25
391
....................  
392
....................       if(a<TRESHOLD_MAX) 
393
00F1:  MOVF   25,W
394
00F2:  SUBLW  3B
395
00F3:  BTFSS  03.0
396
00F4:  GOTO   0FE
397
....................       { 
398
....................          if(a>TRESHOLD_MIN) 
399
00F5:  MOVF   25,W
400
00F6:  SUBLW  28
401
00F7:  BTFSC  03.0
402
00F8:  GOTO   0FD
403
....................          { 
404
....................             cidla |=(last_cidla & 0b01000000); 
405
00F9:  MOVF   22,W
406
00FA:  ANDLW  40
407
00FB:  IORWF  24,F
408
....................          } 
409
....................          else cidla |= 0b01000000; 
410
00FC:  GOTO   0FE
411
00FD:  BSF    24.6
412
....................       } 
413
....................  
414
....................       last_cidla=cidla; 
415
00FE:  MOVF   24,W
416
00FF:  MOVWF  22
417
....................  
418
....................       if (!input(IRRX)) {if (shure<255) shure++;} else {shure=0;}; 
419
0100:  BSF    03.5
420
0101:  BSF    06.0
421
0102:  BCF    03.5
422
0103:  BTFSC  06.0
423
0104:  GOTO   10A
424
0105:  INCFSZ 23,W
425
0106:  GOTO   108
426
0107:  GOTO   109
427
0108:  INCF   23,F
428
0109:  GOTO   10B
429
010A:  CLRF   23
430
....................       if (shure>CIHLA) cidla|=0b10000000; 
431
010B:  MOVF   23,W
432
010C:  SUBLW  32
433
010D:  BTFSS  03.0
434
010E:  BSF    24.7
435
....................  
436
....................       cidla=~cidla; 
437
010F:  COMF   24,F
438
....................       spi_write(cidla); 
439
0110:  MOVF   24,W
440
0111:  MOVWF  13
441
0112:  BSF    03.5
442
0113:  BTFSC  14.0
443
0114:  GOTO   117
444
0115:  BCF    03.5
445
0116:  GOTO   112
446
....................    } 
447
0117:  BCF    03.5
448
0118:  GOTO   04E
449
.................... } 
450
0119:  SLEEP
451
 
452
Configuration Fuses:
453
   Word  1: 3F38   NOWDT NOPUT MCLR NOBROWNOUT NOLVP NOCPD NOWRT NODEBUG CCPB0 NOPROTECT INTRC_IO
454
   Word  2: 3FFC   NOFCMEN NOIESO