Subversion Repositories svnkaklik

Rev

Details | Last modification | View Log

Rev Author Line No. Line
7 kaklik 1
CCS PCM C Compiler, Version 3.245, 27853               12-IX-06 23:20
2
 
3
               Filename: D:\KAKL\roboti\solarni\2006\scamnum\menic.lst
4
 
5
               ROM used: 837 words (20%)
6
                         Largest free fragment is 2048
7
               RAM used: 85 (49%) at main() level
8
                         91 (52%) worst case
9
               Stack:    4 worst case (3 in main + 1 for interrupts)
10
 
11
*
12
0000:  MOVLW  00
13
0001:  MOVWF  0A
14
0002:  GOTO   1BA
15
0003:  NOP
16
0004:  MOVWF  7F
17
0005:  SWAPF  03,W
18
0006:  CLRF   03
19
0007:  MOVWF  21
20
0008:  MOVF   7F,W
21
0009:  MOVWF  20
22
000A:  MOVF   0A,W
23
000B:  MOVWF  28
24
000C:  CLRF   0A
25
000D:  SWAPF  20,F
26
000E:  MOVF   04,W
27
000F:  MOVWF  22
28
0010:  MOVF   77,W
29
0011:  MOVWF  23
30
0012:  MOVF   78,W
31
0013:  MOVWF  24
32
0014:  MOVF   79,W
33
0015:  MOVWF  25
34
0016:  MOVF   7A,W
35
0017:  MOVWF  26
36
0018:  MOVF   7B,W
37
0019:  MOVWF  27
38
001A:  BCF    03.7
39
001B:  BCF    03.5
40
001C:  MOVLW  8C
41
001D:  MOVWF  04
42
001E:  BTFSS  00.3
43
001F:  GOTO   022
44
0020:  BTFSC  0C.3
45
0021:  GOTO   035
46
0022:  MOVF   22,W
47
0023:  MOVWF  04
48
0024:  MOVF   23,W
49
0025:  MOVWF  77
50
0026:  MOVF   24,W
51
0027:  MOVWF  78
52
0028:  MOVF   25,W
53
0029:  MOVWF  79
54
002A:  MOVF   26,W
55
002B:  MOVWF  7A
56
002C:  MOVF   27,W
57
002D:  MOVWF  7B
58
002E:  MOVF   28,W
59
002F:  MOVWF  0A
60
0030:  SWAPF  21,W
61
0031:  MOVWF  03
62
0032:  SWAPF  7F,F
63
0033:  SWAPF  7F,W
64
0034:  RETFIE
65
0035:  BCF    0A.3
66
0036:  GOTO   043
67
.................... // ************************************* 
68
.................... // * Scamnum Specularis ** 20. 9. 2006 * 
69
.................... // ************************************* 
70
....................  
71
.................... #include ".\menic.h" 
72
.................... #include <16F88.h> 
73
.................... //////// Standard Header file for the PIC16F88 device //////////////// 
74
.................... #device PIC16F88 
75
.................... #list 
76
....................  
77
....................  
78
.................... #device adc=8 
79
....................  
80
.................... #fuses   WDT,INTRC_IO, NOPUT, MCLR, NOBROWNOUT, NOLVP, NOCPD, \ 
81
....................          NOWRT, DEBUG, NOPROTECT, NOFCMEN, NOIESO, CCPB3 
82
....................  
83
.................... #use delay(clock=3900000,RESTART_WDT) 
84
*
85
0048:  MOVLW  6F
86
0049:  MOVWF  04
87
004A:  MOVF   00,W
88
004B:  BTFSC  03.2
89
004C:  GOTO   05D
90
004D:  MOVLW  01
91
004E:  MOVWF  78
92
004F:  MOVLW  BF
93
0050:  MOVWF  77
94
0051:  CLRWDT
95
0052:  DECFSZ 77,F
96
0053:  GOTO   051
97
0054:  DECFSZ 78,F
98
0055:  GOTO   04F
99
0056:  MOVLW  42
100
0057:  MOVWF  77
101
0058:  DECFSZ 77,F
102
0059:  GOTO   058
103
005A:  CLRWDT
104
005B:  DECFSZ 00,F
105
005C:  GOTO   04D
106
005D:  RETLW  00
107
....................  
108
....................  
109
....................  
110
.................... #define  TXo PIN_B5           // To the transmitter modulator 
111
.................... #include ".\AX25.c"           // Podprogram pro prenos telemetrie 
112
.................... //#define  PTT PIN_A2                 // PTT control 
113
.................... //#define  TXo PIN_C0                 // To the transmitter modulator 
114
.................... //#define  PERIODAH delay_us(218)     // Halfperiod H 222;78/1200     500;430/500 
115
.................... //#define  TAILH delay_us(74) 
116
.................... //#define  PERIODAL delay_us(408)     // Halfperiod L 412;345/1200    1000;880/500 
117
.................... //#define  TAILL delay_us(341) 
118
.................... #define  PERIODAH delay_us(222)     // Halfperiod H 222;78/1200     500;430/500 
119
.................... #define  TAILH delay_us(78) 
120
.................... #define  PERIODAL delay_us(412)     // Halfperiod L 412;345/1200    1000;880/500 
121
.................... #define  TAILL delay_us(345) 
122
.................... #byte    STATUS = 3                 // CPUs status register 
123
....................  
124
.................... byte SendData[16] = {'A'<<1, 'L'<<1, 'L'<<1, ' '<<1, ' '<<1, ' '<<1,  0x60, 
125
....................                      'C'<<1, 'Z'<<1, '0'<<1, 'R'<<1, 'R'<<1, 'R'<<1, 0x61, 
126
....................                      0x03, 0xF0}; 
127
*
128
01C5:  MOVLW  82
129
01C6:  BCF    03.5
130
01C7:  MOVWF  29
131
01C8:  MOVLW  98
132
01C9:  MOVWF  2A
133
01CA:  MOVWF  2B
134
01CB:  MOVLW  40
135
01CC:  MOVWF  2C
136
01CD:  MOVWF  2D
137
01CE:  MOVWF  2E
138
01CF:  MOVLW  60
139
01D0:  MOVWF  2F
140
01D1:  MOVLW  86
141
01D2:  MOVWF  30
142
01D3:  MOVLW  B4
143
01D4:  MOVWF  31
144
01D5:  MOVLW  60
145
01D6:  MOVWF  32
146
01D7:  MOVLW  A4
147
01D8:  MOVWF  33
148
01D9:  MOVWF  34
149
01DA:  MOVWF  35
150
01DB:  MOVLW  61
151
01DC:  MOVWF  36
152
01DD:  MOVLW  03
153
01DE:  MOVWF  37
154
01DF:  MOVLW  F0
155
01E0:  MOVWF  38
156
....................  
157
.................... boolean bit; 
158
.................... int fcslo, fcshi;    // variabloes for calculating FCS (CRC) 
159
.................... int stuff;           // stuff counter for extra 0 
160
.................... int flag_flag;       // if it is sending flag (7E) 
161
.................... int fcs_flag;        // if it is sending Frame Check Sequence 
162
.................... int i;               // for for 
163
....................  
164
.................... void flipout()       //flips the state of output pin a_1 
165
.................... { 
166
.................... 	stuff = 0;        //since this is a 0, reset the stuff counter 
167
*
168
00E7:  CLRF   3C
169
.................... 	if (bit) 
170
00E8:  BTFSS  39.0
171
00E9:  GOTO   0EC
172
....................    { 
173
....................      bit=FALSE;      //if the state of the pin was low, make it high. 
174
00EA:  BCF    39.0
175
....................    } 
176
....................    else 
177
00EB:  GOTO   0ED
178
....................    { 
179
....................      bit=TRUE;	  	   //if the state of the pin was high make it low 
180
00EC:  BSF    39.0
181
....................    } 
182
.................... } 
183
00ED:  RETLW  00
184
....................  
185
.................... void fcsbit(byte tbyte) 
186
.................... { 
187
.................... #asm 
188
....................    BCF    STATUS,0 
189
*
190
0149:  BCF    03.0
191
....................    RRF    fcshi,F             // rotates the entire 16 bits 
192
014A:  RRF    3B,F
193
....................    RRF    fcslo,F			      // to the right 
194
014B:  RRF    3A,F
195
.................... #endasm 
196
....................    if (((STATUS & 0x01)^(tbyte)) ==0x01) 
197
014C:  MOVF   03,W
198
014D:  ANDLW  01
199
014E:  XORWF  73,W
200
014F:  SUBLW  01
201
0150:  BTFSS  03.2
202
0151:  GOTO   156
203
....................    { 
204
....................          fcshi = fcshi^0x84; 
205
0152:  MOVLW  84
206
0153:  XORWF  3B,F
207
....................          fcslo = fcslo^0x08; 
208
0154:  MOVLW  08
209
0155:  XORWF  3A,F
210
....................    } 
211
.................... } 
212
....................  
213
.................... void SendBit () 
214
.................... { 
215
.................... 	if (bit) 
216
*
217
00EE:  BTFSS  39.0
218
00EF:  GOTO   11A
219
....................    { 
220
....................       output_low(TXo); 
221
00F0:  BSF    03.5
222
00F1:  BCF    06.5
223
00F2:  BCF    03.5
224
00F3:  BCF    06.5
225
....................       PERIODAH; 
226
00F4:  CLRWDT
227
00F5:  MOVLW  47
228
00F6:  MOVWF  77
229
00F7:  DECFSZ 77,F
230
00F8:  GOTO   0F7
231
00F9:  NOP
232
....................       output_high(TXo); 
233
00FA:  BSF    03.5
234
00FB:  BCF    06.5
235
00FC:  BCF    03.5
236
00FD:  BSF    06.5
237
....................       PERIODAH; 
238
00FE:  CLRWDT
239
00FF:  MOVLW  47
240
0100:  MOVWF  77
241
0101:  DECFSZ 77,F
242
0102:  GOTO   101
243
0103:  NOP
244
....................       output_low(TXo); 
245
0104:  BSF    03.5
246
0105:  BCF    06.5
247
0106:  BCF    03.5
248
0107:  BCF    06.5
249
....................       PERIODAH; 
250
0108:  CLRWDT
251
0109:  MOVLW  47
252
010A:  MOVWF  77
253
010B:  DECFSZ 77,F
254
010C:  GOTO   10B
255
010D:  NOP
256
....................       output_high(TXo); 
257
010E:  BSF    03.5
258
010F:  BCF    06.5
259
0110:  BCF    03.5
260
0111:  BSF    06.5
261
....................       TAILH; 
262
0112:  CLRWDT
263
0113:  MOVLW  18
264
0114:  MOVWF  77
265
0115:  DECFSZ 77,F
266
0116:  GOTO   115
267
0117:  NOP
268
0118:  NOP
269
....................     } 
270
....................     else 
271
0119:  GOTO   12D
272
....................     { 
273
....................       output_low(TXo); 
274
011A:  BSF    03.5
275
011B:  BCF    06.5
276
011C:  BCF    03.5
277
011D:  BCF    06.5
278
....................       PERIODAL; 
279
011E:  CLRWDT
280
011F:  MOVLW  85
281
0120:  MOVWF  77
282
0121:  DECFSZ 77,F
283
0122:  GOTO   121
284
....................       output_high(TXo); 
285
0123:  BSF    03.5
286
0124:  BCF    06.5
287
0125:  BCF    03.5
288
0126:  BSF    06.5
289
....................       TAILL; 
290
0127:  CLRWDT
291
0128:  MOVLW  6F
292
0129:  MOVWF  77
293
012A:  DECFSZ 77,F
294
012B:  GOTO   12A
295
012C:  NOP
296
....................     }; 
297
.................... } 
298
012D:  RETLW  00
299
....................  
300
.................... void SendByte (byte inbyte) 
301
.................... { 
302
....................    int k, bt; 
303
....................  
304
....................    for (k=0;k<8;k++)    //do the following for each of the 8 bits in the byte 
305
012E:  CLRF   71
306
012F:  MOVF   71,W
307
0130:  SUBLW  07
308
0131:  BTFSS  03.0
309
0132:  GOTO   176
310
....................    { 
311
....................      bt = inbyte & 0x01;            //strip off the rightmost bit of the byte to be sent (inbyte) 
312
0133:  MOVF   70,W
313
0134:  ANDLW  01
314
0135:  MOVWF  72
315
....................      if ((fcs_flag == FALSE) & (flag_flag == FALSE)) fcsbit(bt);    //do FCS calc, but only if this 
316
0136:  MOVF   3E,F
317
0137:  BTFSC  03.2
318
0138:  GOTO   13B
319
0139:  MOVLW  00
320
013A:  GOTO   13C
321
013B:  MOVLW  01
322
013C:  MOVWF  73
323
013D:  MOVF   3D,F
324
013E:  BTFSC  03.2
325
013F:  GOTO   142
326
0140:  MOVLW  00
327
0141:  GOTO   143
328
0142:  MOVLW  01
329
0143:  ANDWF  73,W
330
0144:  XORLW  00
331
0145:  BTFSC  03.2
332
0146:  GOTO   156
333
0147:  MOVF   72,W
334
0148:  MOVWF  73
335
.................... 						                                                //is not a flag or fcs byte 
336
....................      if (bt == 0) 
337
*
338
0156:  MOVF   72,F
339
0157:  BTFSS  03.2
340
0158:  GOTO   15B
341
....................      { 
342
....................        flipout(); 
343
0159:  CALL   0E7
344
....................      }  			               // if this bit is a zero, flip the output state 
345
....................      else 
346
015A:  GOTO   171
347
....................      {                          			      //otherwise if it is a 1, do the following: 
348
....................        if (flag_flag == FALSE) stuff++;      //increment the count of consequtive 1's 
349
015B:  MOVF   3D,F
350
015C:  BTFSC  03.2
351
015D:  INCF   3C,F
352
....................        if ((flag_flag == FALSE) & (stuff == 5)) 
353
015E:  MOVF   3D,F
354
015F:  BTFSC  03.2
355
0160:  GOTO   163
356
0161:  MOVLW  00
357
0162:  GOTO   164
358
0163:  MOVLW  01
359
0164:  MOVWF  73
360
0165:  MOVF   3C,W
361
0166:  SUBLW  05
362
0167:  BTFSC  03.2
363
0168:  GOTO   16B
364
0169:  MOVLW  00
365
016A:  GOTO   16C
366
016B:  MOVLW  01
367
016C:  ANDWF  73,W
368
016D:  BTFSC  03.2
369
016E:  GOTO   171
370
....................        {       //stuff an extra 0, if 5 1's in a row 
371
....................          SendBit(); 
372
016F:  CALL   0EE
373
....................          flipout();               //flip the output state to stuff a 0 
374
0170:  CALL   0E7
375
....................        }//end of if 
376
....................      }//end of else 
377
....................      // delay_us(850);				 //introduces a delay that creates 1200 baud 
378
....................      SendBit(); 
379
0171:  CALL   0EE
380
....................      inbyte = inbyte>>1;          //go to the next bit in the byte 
381
0172:  BCF    03.0
382
0173:  RRF    70,F
383
....................    }//end of for 
384
0174:  INCF   71,F
385
0175:  GOTO   12F
386
.................... }//end of SendByte 
387
0176:  RETLW  00
388
....................  
389
.................... void SendPacket(char *data) 
390
.................... { 
391
....................     bit=FALSE; 
392
0177:  BCF    39.0
393
....................  
394
....................    fcslo=fcshi=0xFF;       //The 2 FCS Bytes are initialized to FF 
395
0178:  MOVLW  FF
396
0179:  MOVWF  3B
397
017A:  MOVWF  3A
398
....................    stuff = 0;              //The variable stuff counts the number of 1's in a row. When it gets to 5 
399
017B:  CLRF   3C
400
.................... 		                     // it is time to stuff a 0. 
401
....................  
402
.................... //   output_low(PTT);        // Blinking LED 
403
.................... //   delay_ms(1000); 
404
.................... //   output_high(PTT); 
405
....................  
406
....................    flag_flag = TRUE;       //The variable flag is true if you are transmitted flags (7E's) false otherwise. 
407
017C:  MOVLW  01
408
017D:  MOVWF  3D
409
....................    fcs_flag = FALSE;       //The variable fcsflag is true if you are transmitting FCS bytes, false otherwise. 
410
017E:  CLRF   3E
411
....................  
412
....................    for(i=0; i<10; i++) SendByte(0x7E); //Sends flag bytes.  Adjust length for txdelay 
413
017F:  CLRF   3F
414
0180:  MOVF   3F,W
415
0181:  SUBLW  09
416
0182:  BTFSS  03.0
417
0183:  GOTO   189
418
0184:  MOVLW  7E
419
0185:  MOVWF  70
420
0186:  CALL   12E
421
0187:  INCF   3F,F
422
0188:  GOTO   180
423
....................                                        //each flag takes approx 6.7 ms 
424
....................    flag_flag = FALSE;      //done sending flags 
425
0189:  CLRF   3D
426
....................  
427
....................    for(i=0; i<16; i++) SendByte(SendData[i]);      //send the packet bytes 
428
018A:  CLRF   3F
429
018B:  MOVF   3F,W
430
018C:  SUBLW  0F
431
018D:  BTFSS  03.0
432
018E:  GOTO   198
433
018F:  MOVLW  29
434
0190:  ADDWF  3F,W
435
0191:  MOVWF  04
436
0192:  MOVF   00,W
437
0193:  MOVWF  6F
438
0194:  MOVWF  70
439
0195:  CALL   12E
440
0196:  INCF   3F,F
441
0197:  GOTO   18B
442
....................  
443
....................    for(i=0; 0 != *data; i++) 
444
0198:  CLRF   3F
445
0199:  MOVF   6E,W
446
019A:  MOVWF  04
447
019B:  MOVF   00,W
448
019C:  BTFSC  03.2
449
019D:  GOTO   1A7
450
....................    { 
451
....................       SendByte(*data);     //send the packet bytes 
452
019E:  MOVF   6E,W
453
019F:  MOVWF  04
454
01A0:  MOVF   00,W
455
01A1:  MOVWF  6F
456
01A2:  MOVWF  70
457
01A3:  CALL   12E
458
....................       data++; 
459
01A4:  INCF   6E,F
460
....................    }; 
461
01A5:  INCF   3F,F
462
01A6:  GOTO   199
463
....................  
464
....................    fcs_flag = TRUE;       	//about to send the FCS bytes 
465
01A7:  MOVLW  01
466
01A8:  MOVWF  3E
467
....................    fcslo =fcslo^0xff;      //must XOR them with FF before sending 
468
01A9:  MOVLW  FF
469
01AA:  XORWF  3A,F
470
....................    fcshi = fcshi^0xff; 
471
01AB:  XORWF  3B,F
472
....................    SendByte(fcslo);        //send the low byte of fcs 
473
01AC:  MOVF   3A,W
474
01AD:  MOVWF  70
475
01AE:  CALL   12E
476
....................    SendByte(fcshi);        //send the high byte of fcs 
477
01AF:  MOVF   3B,W
478
01B0:  MOVWF  70
479
01B1:  CALL   12E
480
....................    fcs_flag = FALSE;		   //done sending FCS 
481
01B2:  CLRF   3E
482
....................    flag_flag = TRUE;  		//about to send flags 
483
01B3:  MOVLW  01
484
01B4:  MOVWF  3D
485
....................    SendByte(0x7e);         // Send a flag to end packet 
486
01B5:  MOVLW  7E
487
01B6:  MOVWF  70
488
01B7:  CALL   12E
489
.................... } 
490
01B8:  BCF    0A.3
491
01B9:  GOTO   30C (RETURN)
492
....................  
493
....................  
494
....................  
495
....................  
496
.................... char AXstring[40];            // Buffer pro prenos telemetrie 
497
....................  
498
.................... #define REFSTART  95    // Hodnota odpovidajici 1,2V pri nezatizenych clancich 
499
.................... #define DUTY1     2     // Delka sepnuti PWM v us pro sero 
500
.................... #define DUTY2     19    // Delka sepnuti PWM v us pro jednu zarovku 500W 
501
....................  
502
.................... // Tabulka hodnot prevodniku pro ruzna napajeci napeti 
503
.................... //  80   3,99V 
504
.................... //  90   3,54V 
505
.................... // 100   3,20V 
506
.................... // 105   3,04V 
507
.................... // 107   2,99V 
508
.................... // 110   2,91v 
509
.................... // 200   1,61V 
510
....................  
511
.................... #define PIEZO     PIN_A6   // Jeden pol piezo reproduktoru 
512
.................... #define LED       PIN_A7   // LED / druhy pol piezo reproduktoru 
513
.................... #define MENIC     PIN_B3   // Spinani tranzistoru menice 
514
.................... #define REFPWR    PIN_B1   // Napajeni zdroje referencniho napeti 
515
.................... #define MOTOR     PIN_B2   // Spinani tranzistoru motoru 
516
.................... #define SW1       PIN_B6   // DIPswitch 1 
517
.................... #define SW2       PIN_B7   // DIPswitch 2 
518
.................... #define NAPETI    4        // Cislo kanalu DA prevodniku pro mereni napeti 
519
.................... #define PWM       0        // Cislo kanalu DA prevodniku pro nastaveni PWM 
520
.................... #define ROZJEZD   1        // Cislo kanalu DA prevodniku pro nastaveni rozjezdu 
521
....................  
522
.................... #byte SSPBUF   = 0x13   // Adresy registru jednotky SSP 
523
.................... #byte SSPCON1  = 0x14 
524
.................... #byte SSPSTAT  = 0x94 
525
....................  
526
.................... // Vzorky pro generovani PWM pomoci SSP 
527
.................... unsigned int8 const Pattern[8] = {0x02,0x06,0x0e,0x1e,0x3e,0x7e,0xfe,0xff}; 
528
.................... unsigned int8 MotorPattern; 
529
....................  
530
.................... #INT_SSP 
531
.................... void IntSSP() 
532
.................... { 
533
....................    SSPBUF=MotorPattern;             // znovu vysli stejnou hodnotu 
534
*
535
0043:  MOVF   68,W
536
0044:  MOVWF  13
537
.................... } 
538
....................  
539
0045:  BCF    0C.3
540
0046:  BCF    0A.3
541
0047:  GOTO   022
542
.................... void pip()     // pipnuti a bliknuti 
543
.................... { 
544
....................    int1 beep; 
545
....................    int i; 
546
....................  
547
....................    for(i=0; i<250; i++) 
548
*
549
006B:  CLRF   6F
550
006C:  MOVF   6F,W
551
006D:  SUBLW  F9
552
006E:  BTFSS  03.0
553
006F:  GOTO   08B
554
....................    { 
555
....................       output_bit(PIEZO, beep); 
556
0070:  BTFSC  6E.0
557
0071:  GOTO   074
558
0072:  BCF    05.6
559
0073:  GOTO   075
560
0074:  BSF    05.6
561
0075:  BSF    03.5
562
0076:  BCF    05.6
563
....................       beep=~beep; 
564
0077:  MOVLW  01
565
0078:  BCF    03.5
566
0079:  XORWF  6E,F
567
....................       output_bit(LED, beep); 
568
007A:  BTFSC  6E.0
569
007B:  GOTO   07E
570
007C:  BCF    05.7
571
007D:  GOTO   07F
572
007E:  BSF    05.7
573
007F:  BSF    03.5
574
0080:  BCF    05.7
575
....................       delay_us(100); 
576
0081:  CLRWDT
577
0082:  MOVLW  1F
578
0083:  MOVWF  77
579
0084:  DECFSZ 77,F
580
0085:  GOTO   084
581
0086:  NOP
582
0087:  NOP
583
....................    }; 
584
0088:  BCF    03.5
585
0089:  INCF   6F,F
586
008A:  GOTO   06C
587
....................    output_high(PIEZO); 
588
008B:  BSF    03.5
589
008C:  BCF    05.6
590
008D:  BCF    03.5
591
008E:  BSF    05.6
592
....................    output_high(LED); 
593
008F:  BSF    03.5
594
0090:  BCF    05.7
595
0091:  BCF    03.5
596
0092:  BSF    05.7
597
.................... } 
598
0093:  BCF    0A.3
599
0094:  GOTO   2A3 (RETURN)
600
....................  
601
.................... void cvak()    // pouze cvaknuti piezoelementem bez bliknuti 
602
.................... { 
603
....................    output_bit(PIEZO,~input(PIEZO)); 
604
*
605
005E:  BSF    03.5
606
005F:  BSF    05.6
607
0060:  BCF    03.5
608
0061:  BTFSS  05.6
609
0062:  GOTO   065
610
0063:  BCF    05.6
611
0064:  GOTO   066
612
0065:  BSF    05.6
613
0066:  BSF    03.5
614
0067:  BCF    05.6
615
.................... } 
616
0068:  BCF    03.5
617
0069:  BCF    0A.3
618
006A:  GOTO   25A (RETURN)
619
....................  
620
.................... void main() 
621
.................... { 
622
*
623
01BA:  CLRF   04
624
01BB:  MOVLW  1F
625
01BC:  ANDWF  03,F
626
01BD:  BSF    03.5
627
01BE:  BCF    1F.4
628
01BF:  BCF    1F.5
629
01C0:  MOVF   1B,W
630
01C1:  ANDLW  80
631
01C2:  MOVWF  1B
632
01C3:  MOVLW  07
633
01C4:  MOVWF  1C
634
....................    int8 n; 
635
....................    int8 perioda; 
636
....................    int8 razeni; 
637
....................    int8 uclanku; 
638
....................  
639
....................    setup_timer_0(RTCC_INTERNAL);setup_wdt(WDT_1152MS); 
640
*
641
01E2:  BSF    03.5
642
01E3:  MOVF   01,W
643
01E4:  ANDLW  C0
644
01E5:  MOVWF  01
645
01E6:  MOVLW  0E
646
01E7:  MOVWF  77
647
01E8:  MOVLW  07
648
01E9:  BCF    03.5
649
01EA:  CLRF   01
650
01EB:  MOVLW  81
651
01EC:  MOVWF  04
652
01ED:  MOVF   00,W
653
01EE:  ANDLW  F0
654
01EF:  IORLW  07
655
01F0:  MOVWF  00
656
01F1:  CLRWDT
657
01F2:  MOVF   00,W
658
01F3:  ANDLW  F7
659
01F4:  BTFSC  77.3
660
01F5:  ANDLW  F0
661
01F6:  IORWF  77,W
662
01F7:  MOVWF  00
663
....................    setup_timer_1(T1_DISABLED); 
664
01F8:  CLRF   10
665
....................    setup_adc_ports(ADC_CLOCK_INTERNAL|sAN0|sAN1|sAN4|VSS_VDD); 
666
01F9:  BSF    03.5
667
01FA:  BCF    1F.4
668
01FB:  BCF    1F.5
669
01FC:  MOVF   1B,W
670
01FD:  ANDLW  80
671
01FE:  IORLW  D3
672
01FF:  MOVWF  1B
673
....................    setup_adc(ADC_CLOCK_INTERNAL); 
674
0200:  BCF    1F.6
675
0201:  BCF    03.5
676
0202:  BSF    1F.6
677
0203:  BSF    1F.7
678
0204:  BSF    03.5
679
0205:  BCF    1F.7
680
0206:  BCF    03.5
681
0207:  BSF    1F.0
682
....................    setup_spi(FALSE); 
683
0208:  BCF    14.5
684
0209:  BSF    03.5
685
020A:  BCF    06.2
686
020B:  BSF    06.1
687
020C:  BCF    06.4
688
020D:  MOVLW  00
689
020E:  BCF    03.5
690
020F:  MOVWF  14
691
0210:  BSF    03.5
692
0211:  MOVWF  14
693
....................    setup_comparator(NC_NC_NC_NC); 
694
0212:  MOVLW  07
695
0213:  MOVWF  1C
696
0214:  MOVF   05,W
697
0215:  CLRWDT
698
0216:  MOVLW  02
699
0217:  MOVWF  77
700
0218:  DECFSZ 77,F
701
0219:  GOTO   218
702
021A:  NOP
703
021B:  MOVF   1C,W
704
021C:  BCF    03.5
705
021D:  BCF    0D.6
706
....................    setup_vref(FALSE); 
707
021E:  BSF    03.5
708
021F:  CLRF   1D
709
....................  
710
....................    output_low(MENIC);      // Vsechno zastav 
711
0220:  BCF    06.3
712
0221:  BCF    03.5
713
0222:  BCF    06.3
714
....................    output_low(MOTOR); 
715
0223:  BSF    03.5
716
0224:  BCF    06.2
717
0225:  BCF    03.5
718
0226:  BCF    06.2
719
....................    output_low(REFPWR); 
720
0227:  BSF    03.5
721
0228:  BCF    06.1
722
0229:  BCF    03.5
723
022A:  BCF    06.1
724
....................    output_high(LED); 
725
022B:  BSF    03.5
726
022C:  BCF    05.7
727
022D:  BCF    03.5
728
022E:  BSF    05.7
729
....................    output_high(PIEZO); 
730
022F:  BSF    03.5
731
0230:  BCF    05.6
732
0231:  BCF    03.5
733
0232:  BSF    05.6
734
....................  
735
....................    set_adc_channel(NAPETI);     // Vyber AD kanal pro pomerne mereni napeti 
736
0233:  MOVLW  20
737
0234:  MOVWF  78
738
0235:  MOVF   1F,W
739
0236:  ANDLW  C7
740
0237:  IORWF  78,W
741
0238:  MOVWF  1F
742
....................    set_pwm1_duty(0);       // Spust PWM, ale zatim s trvalou 0 na vystupu 
743
0239:  CLRF   15
744
....................    setup_ccp1(CCP_PWM); 
745
023A:  BSF    03.5
746
023B:  BCF    06.3
747
023C:  BCF    03.5
748
023D:  BCF    06.3
749
023E:  MOVLW  0C
750
023F:  MOVWF  17
751
....................    setup_timer_2(T2_DIV_BY_1,100,1);  // perioda 
752
0240:  MOVLW  00
753
0241:  MOVWF  78
754
0242:  IORLW  04
755
0243:  MOVWF  12
756
0244:  MOVLW  64
757
0245:  BSF    03.5
758
0246:  MOVWF  12
759
....................  
760
....................    setup_oscillator(OSC_4MHZ|OSC_INTRC);  // rozjed PIC (zvysi se odber) 
761
0247:  MOVLW  62
762
0248:  MOVWF  0F
763
....................  
764
.................... // jsme v depu? 
765
....................    set_pwm1_duty(DUTY1);          // PWM pro zatizeni clanku pri malem osvetleni 
766
0249:  MOVLW  02
767
024A:  BCF    03.5
768
024B:  MOVWF  15
769
....................    n=0; 
770
024C:  CLRF   6A
771
....................    do 
772
....................    { 
773
....................       output_low(REFPWR);  // Vypni napajeni napetove reference, aby se setrilo 
774
024D:  BSF    03.5
775
024E:  BCF    06.1
776
024F:  BCF    03.5
777
0250:  BCF    06.1
778
....................       delay_ms(100); 
779
0251:  MOVLW  64
780
0252:  MOVWF  6F
781
0253:  CALL   048
782
....................       if (4==n++) {cvak(); n=0;};   // Kazdy 4. pruchod cvakni 
783
0254:  MOVF   6A,W
784
0255:  INCF   6A,F
785
0256:  SUBLW  04
786
0257:  BTFSS  03.2
787
0258:  GOTO   25B
788
0259:  GOTO   05E
789
025A:  CLRF   6A
790
....................       output_high(REFPWR);          // Zapni napajeni napetove reference 
791
025B:  BSF    03.5
792
025C:  BCF    06.1
793
025D:  BCF    03.5
794
025E:  BSF    06.1
795
....................       delay_ms(1);                  // Pockej na ustaleni napeti 
796
025F:  MOVLW  01
797
0260:  MOVWF  6F
798
0261:  CALL   048
799
....................    } while (read_adc()>REFSTART);   // Odkryl starter clanky? 
800
0262:  BSF    1F.2
801
0263:  BTFSC  1F.2
802
0264:  GOTO   263
803
0265:  MOVF   1E,W
804
0266:  SUBLW  5F
805
0267:  BTFSS  03.0
806
0268:  GOTO   24D
807
....................    output_low(REFPWR);     // Vypni napajeni napetove reference, aby se setrilo 
808
0269:  BSF    03.5
809
026A:  BCF    06.1
810
026B:  BCF    03.5
811
026C:  BCF    06.1
812
....................  
813
.................... //   port_b_pullups(TRUE);            // Zapni pullupy, aby slo cist DIPswitch 
814
.................... //   do 
815
.................... //   { 
816
....................       // Precti trimry 
817
....................       set_adc_channel(PWM);         // Zjisteni nastaveni PWM 
818
026D:  MOVLW  00
819
026E:  MOVWF  78
820
026F:  MOVF   1F,W
821
0270:  ANDLW  C7
822
0271:  IORWF  78,W
823
0272:  MOVWF  1F
824
....................       delay_us(100);                // Pockej na prepnuti kanalu A/D prevodniku 
825
0273:  CLRWDT
826
0274:  MOVLW  1F
827
0275:  MOVWF  77
828
0276:  DECFSZ 77,F
829
0277:  GOTO   276
830
0278:  NOP
831
0279:  NOP
832
....................       perioda=(read_adc()>>1)+40;   // rozsah: 40 az 167 
833
027A:  BSF    1F.2
834
027B:  BTFSC  1F.2
835
027C:  GOTO   27B
836
027D:  MOVF   1E,W
837
027E:  MOVWF  77
838
027F:  BCF    03.0
839
0280:  RRF    77,F
840
0281:  MOVF   77,W
841
0282:  ADDLW  28
842
0283:  MOVWF  6B
843
....................  
844
....................       set_adc_channel(ROZJEZD);     // Zjisteni nastaveni rozjezdu 
845
0284:  MOVLW  08
846
0285:  MOVWF  78
847
0286:  MOVF   1F,W
848
0287:  ANDLW  C7
849
0288:  IORWF  78,W
850
0289:  MOVWF  1F
851
....................       delay_us(100);                // Pockej na prepnuti kanalu A/D prevodniku 
852
028A:  CLRWDT
853
028B:  MOVLW  1F
854
028C:  MOVWF  77
855
028D:  DECFSZ 77,F
856
028E:  GOTO   28D
857
028F:  NOP
858
0290:  NOP
859
....................       razeni=read_adc()>>1;         // rozsah: 0 az 127 
860
0291:  BSF    1F.2
861
0292:  BTFSC  1F.2
862
0293:  GOTO   292
863
0294:  BCF    03.0
864
0295:  RRF    1E,W
865
0296:  MOVWF  6C
866
....................  
867
....................       // Rozjeti menice 
868
....................       set_pwm1_duty(0);    // Zastav PWM, aby slo nastavit jinou frekvenci 
869
0297:  CLRF   15
870
....................       setup_timer_2(T2_DIV_BY_1,perioda,1);    // perioda 
871
0298:  MOVLW  00
872
0299:  MOVWF  78
873
029A:  IORLW  04
874
029B:  MOVWF  12
875
029C:  MOVF   6B,W
876
029D:  BSF    03.5
877
029E:  MOVWF  12
878
....................       set_pwm1_duty(DUTY2); // PWM pro zatizeni clanku pri jedne 500W zarovce 
879
029F:  MOVLW  13
880
02A0:  BCF    03.5
881
02A1:  MOVWF  15
882
....................  
883
....................       pip();                  // potvrzeni odstartovani / servisni mod 
884
02A2:  GOTO   06B
885
....................       delay_ms(500); 
886
02A3:  MOVLW  02
887
02A4:  MOVWF  6E
888
02A5:  MOVLW  FA
889
02A6:  MOVWF  6F
890
02A7:  CALL   048
891
02A8:  DECFSZ 6E,F
892
02A9:  GOTO   2A5
893
....................  
894
.................... //   } while (input(SW1));      // Je zapnut servisni mod? SW1(OFF)=ANO 
895
.................... //   port_b_pullups(FALSE);     // Vypni pullupy, aby se setrilo energii 
896
....................  
897
.................... // Regulace nabíjení 
898
....................    output_high(REFPWR);          // Prepni AD na mereni napeti clanku 
899
02AA:  BSF    03.5
900
02AB:  BCF    06.1
901
02AC:  BCF    03.5
902
02AD:  BSF    06.1
903
....................    set_adc_channel(NAPETI);      // Prepni Zmer napeti clanku 
904
02AE:  MOVLW  20
905
02AF:  MOVWF  78
906
02B0:  MOVF   1F,W
907
02B1:  ANDLW  C7
908
02B2:  IORWF  78,W
909
02B3:  MOVWF  1F
910
....................    delay_us(50);                // Pockej na prepnuti kanalu A/D prevodniku 
911
02B4:  CLRWDT
912
02B5:  MOVLW  0F
913
02B6:  MOVWF  77
914
02B7:  DECFSZ 77,F
915
02B8:  GOTO   2B7
916
02B9:  NOP
917
....................    for(n=1;n<=10;n++) 
918
02BA:  MOVLW  01
919
02BB:  MOVWF  6A
920
02BC:  MOVF   6A,W
921
02BD:  SUBLW  0A
922
02BE:  BTFSS  03.0
923
02BF:  GOTO   2DC
924
....................    { 
925
....................       // Zmer napeti (aktualni zatizeni clanku) 
926
....................       uclanku=read_adc(); 
927
02C0:  BSF    1F.2
928
02C1:  BTFSC  1F.2
929
02C2:  GOTO   2C1
930
02C3:  MOVF   1E,W
931
02C4:  MOVWF  6D
932
....................       // Uprav parametry menice 
933
....................       if (uclanku>105) 
934
02C5:  MOVF   6D,W
935
02C6:  SUBLW  69
936
02C7:  BTFSC  03.0
937
02C8:  GOTO   2CB
938
....................       { 
939
....................          perioda++; 
940
02C9:  INCF   6B,F
941
....................       } 
942
....................       else 
943
02CA:  GOTO   2CC
944
....................       { 
945
....................          perioda--; 
946
02CB:  DECF   6B,F
947
....................       } 
948
....................       set_pwm1_duty(0);    // Zastav PWM, aby slo nastavit jinou frekvenci 
949
02CC:  CLRF   15
950
....................       setup_timer_2(T2_DIV_BY_1,perioda,1);    // perioda 
951
02CD:  MOVLW  00
952
02CE:  MOVWF  78
953
02CF:  IORLW  04
954
02D0:  MOVWF  12
955
02D1:  MOVF   6B,W
956
02D2:  BSF    03.5
957
02D3:  MOVWF  12
958
....................       set_pwm1_duty(DUTY2); // PWM pro zatizeni clanku pri jedne 500W zarovce 
959
02D4:  MOVLW  13
960
02D5:  BCF    03.5
961
02D6:  MOVWF  15
962
....................       delay_ms(100); 
963
02D7:  MOVLW  64
964
02D8:  MOVWF  6F
965
02D9:  CALL   048
966
....................    } 
967
02DA:  INCF   6A,F
968
02DB:  GOTO   2BC
969
....................    output_low(REFPWR); 
970
02DC:  BSF    03.5
971
02DD:  BCF    06.1
972
02DE:  BCF    03.5
973
02DF:  BCF    06.1
974
....................    // posli telemetrii 
975
....................    sprintf(AXstring,"p=%u r=%u u=%u", perioda, razeni, uclanku);  // Convert DATA to String. 
976
*
977
01E1:  CLRF   69
978
*
979
02E0:  MOVLW  40
980
02E1:  MOVWF  69
981
02E2:  MOVLW  70
982
02E3:  MOVWF  70
983
02E4:  CALL   095
984
02E5:  MOVLW  3D
985
02E6:  MOVWF  70
986
02E7:  CALL   095
987
02E8:  MOVF   6B,W
988
02E9:  MOVWF  6E
989
02EA:  MOVLW  1B
990
02EB:  MOVWF  6F
991
02EC:  CALL   0B2
992
02ED:  MOVLW  20
993
02EE:  MOVWF  70
994
02EF:  CALL   095
995
02F0:  MOVLW  72
996
02F1:  MOVWF  70
997
02F2:  CALL   095
998
02F3:  MOVLW  3D
999
02F4:  MOVWF  70
1000
02F5:  CALL   095
1001
02F6:  MOVF   6C,W
1002
02F7:  MOVWF  6E
1003
02F8:  MOVLW  1B
1004
02F9:  MOVWF  6F
1005
02FA:  CALL   0B2
1006
02FB:  MOVLW  20
1007
02FC:  MOVWF  70
1008
02FD:  CALL   095
1009
02FE:  MOVLW  75
1010
02FF:  MOVWF  70
1011
0300:  CALL   095
1012
0301:  MOVLW  3D
1013
0302:  MOVWF  70
1014
0303:  CALL   095
1015
0304:  MOVF   6D,W
1016
0305:  MOVWF  6E
1017
0306:  MOVLW  1B
1018
0307:  MOVWF  6F
1019
0308:  CALL   0B2
1020
....................    SendPacket(&AXstring[0]); 
1021
0309:  MOVLW  40
1022
030A:  MOVWF  6E
1023
030B:  GOTO   177
1024
....................  
1025
....................    delay_ms(13000);           // Pockame 14s 
1026
030C:  MOVLW  34
1027
030D:  MOVWF  6E
1028
030E:  MOVLW  FA
1029
030F:  MOVWF  6F
1030
0310:  CALL   048
1031
0311:  DECFSZ 6E,F
1032
0312:  GOTO   30E
1033
....................  
1034
.................... // rozjezd 
1035
....................    SSPSTAT = 0;                  // inicializace SPI jednotky 
1036
0313:  BSF    03.5
1037
0314:  CLRF   14
1038
....................    SSPCON1 = 0x22;               // SPI OSC/64 
1039
0315:  MOVLW  22
1040
0316:  BCF    03.5
1041
0317:  MOVWF  14
1042
....................    MotorPattern=0x02;            // prvni data pro vyslani 
1043
0318:  MOVLW  02
1044
0319:  MOVWF  68
1045
....................    SSPBUF=MotorPattern; 
1046
031A:  MOVF   68,W
1047
031B:  MOVWF  13
1048
....................    enable_interrupts(global); 
1049
031C:  MOVLW  C0
1050
031D:  IORWF  0B,F
1051
....................    enable_interrupts(INT_SSP);   // az budou vyslana, prijde interrupt od SSP 
1052
031E:  BSF    03.5
1053
031F:  BSF    0C.3
1054
....................  
1055
....................    for(n=0; n<=7; n++)     // razeni osmi rychlostnich stupnu 
1056
0320:  BCF    03.5
1057
0321:  CLRF   6A
1058
0322:  MOVF   6A,W
1059
0323:  SUBLW  07
1060
0324:  BTFSS  03.0
1061
0325:  GOTO   32F
1062
....................    { 
1063
....................       MotorPattern=Pattern[n]; 
1064
0326:  MOVF   6A,W
1065
0327:  CALL   037
1066
0328:  MOVWF  78
1067
0329:  MOVWF  68
1068
....................       delay_ms(razeni);             // Pockej na dalsi razeni 
1069
032A:  MOVF   6C,W
1070
032B:  MOVWF  6F
1071
032C:  CALL   048
1072
....................    }; 
1073
032D:  INCF   6A,F
1074
032E:  GOTO   322
1075
....................    SSPSTAT = 0; 
1076
032F:  BSF    03.5
1077
0330:  CLRF   14
1078
....................    SSPCON1 = 0;                     // SPI stop 
1079
0331:  BCF    03.5
1080
0332:  CLRF   14
1081
....................    disable_interrupts(INT_SSP);     // zastav preruseni od SSP 
1082
0333:  BSF    03.5
1083
0334:  BCF    0C.3
1084
....................  
1085
.................... // jedem co to da 
1086
....................    output_high(MOTOR); 
1087
0335:  BCF    06.2
1088
0336:  BCF    03.5
1089
0337:  BSF    06.2
1090
....................  
1091
.................... /* 
1092
....................    if (TRUE)         // Venkovni jizda? 
1093
....................    { 
1094
....................       delay_ms(5000);                  // Venku muzeme jet 5s 
1095
....................       set_pwm1_duty(0);                // Zastav menic 
1096
.................... //      output_low(MOTOR);               // Zastav motor 
1097
....................       while(TRUE) restart_wdt();       // Cekej porad 
1098
....................    }; 
1099
....................    delay_ms(3000);                  
1100
.................... */ 
1101
....................    delay_ms(1300);                  // Nemeli bysme jet dele nez 1,3s :-) 
1102
0338:  MOVLW  0A
1103
0339:  MOVWF  6E
1104
033A:  MOVLW  82
1105
033B:  MOVWF  6F
1106
033C:  CALL   048
1107
033D:  DECFSZ 6E,F
1108
033E:  GOTO   33A
1109
....................    output_low(MOTOR);               // Zastav motor 
1110
033F:  BSF    03.5
1111
0340:  BCF    06.2
1112
0341:  BCF    03.5
1113
0342:  BCF    06.2
1114
....................                                     // Menic je stale zapnut a zatezuje clanky 
1115
....................  
1116
....................    while(TRUE);            // Cekej, dokud se neztrati svetlo, 
1117
0343:  GOTO   343
1118
....................                            // nebo prijde WatchDog 
1119
....................  
1120
.................... } 
1121
0344:  SLEEP
1122
 
1123
Configuration Fuses:
1124
   Word  1: 273C   WDT NOPUT MCLR NOBROWNOUT NOLVP NOCPD NOWRT DEBUG CCPB3 NOPROTECT INTRC_IO
1125
   Word  2: 3FFC   NOFCMEN NOIESO