Subversion Repositories svnkaklik

Rev

Details | Last modification | View Log

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