Subversion Repositories svnkaklik

Rev

Details | Last modification | View Log

Rev Author Line No. Line
6 kaklik 1
CCS PCW C Compiler, Version 3.110, 15448
2
 
3
               Filename: d:\@kaklik\programy\pic_c\prenos\letadlo\vysilac\main.LST
4
 
5
               ROM used: 1542 (38%)
6
                         Largest free fragment is 2048
7
               RAM used: 22 (11%) at main() level
8
                         40 (21%) worst case
9
               Stack:    5 locations
10
 
11
*
12
0000:  MOVLW  00
13
0001:  MOVWF  0A
14
0002:  GOTO   5C1
15
0003:  NOP
16
....................  // Vysilac  
17
....................   
18
.................... #include "main.h" 
19
....................  #include <16F873.h> 
20
....................  //////// Standard Header file for the PIC16F873 device ////////////////  
21
.................... #device PIC16F873  
22
.................... #list  
23
....................  
24
.................... #use delay(clock=4000000)  
25
*
26
0077:  MOVLW  3F
27
0078:  MOVWF  04
28
0079:  MOVF   00,W
29
007A:  BTFSC  03.2
30
007B:  GOTO   08B
31
007C:  MOVLW  01
32
007D:  MOVWF  21
33
007E:  CLRF   20
34
007F:  DECFSZ 20,F
35
0080:  GOTO   07F
36
0081:  DECFSZ 21,F
37
0082:  GOTO   07E
38
0083:  MOVLW  4A
39
0084:  MOVWF  20
40
0085:  DECFSZ 20,F
41
0086:  GOTO   085
42
0087:  NOP
43
0088:  NOP
44
0089:  DECFSZ 00,F
45
008A:  GOTO   07C
46
008B:  RETLW  00
47
*
48
0321:  MOVLW  3A
49
0322:  MOVWF  04
50
0323:  MOVLW  FC
51
0324:  ANDWF  00,F
52
0325:  RRF    00,F
53
0326:  RRF    00,F
54
0327:  MOVF   00,W
55
0328:  BTFSC  03.2
56
0329:  GOTO   32E
57
032A:  GOTO   32C
58
032B:  NOP
59
032C:  DECFSZ 00,F
60
032D:  GOTO   32B
61
032E:  BCF    0A.3
62
032F:  GOTO   545 (RETURN)
63
.................... #fuses XT,PUT,NOWDT  
64
....................   
65
....................  
66
.................... #include "..\common.h" 
67
....................  #DEFINE  OSA_X          1           // adresy os  
68
.................... #DEFINE  OSA_Y          2  
69
.................... #DEFINE  OSA_Z          3  
70
.................... #DEFINE  OSA_W          4  
71
.................... #DEFINE  TLs            5  
72
.................... #DEFINE  Trim           6           // ovladani prijimace  
73
....................   
74
.................... #DEFINE  IMPULS         250         // sirka impulsu  
75
.................... #DEFINE  SYNC           15          // delka uvodniho ticha v IMPULS/4  
76
....................  
77
.................... //Displej  
78
.................... #DEFINE  LCD_RS         PIN_B1      // rizeni registru LCD displeje  
79
.................... #DEFINE  LCD_E          PIN_B2      // enable LCD displeje  
80
.................... #DEFINE  LCD_DATA_LSB   PIN_B4      // pripojeni LSB bitu datoveho portu LCD displeje (celkem 4 bity vzestupne za sebou)  
81
.................... #INCLUDE "MYLCD.C" 
82
....................  // LCD modul pro ovladani dvouradkoveho LCD modulu se standardnim Hitachi radicem  
83
.................... // (c)miho 2002  
84
.................... //  
85
.................... // Historie:  
86
.................... //  
87
.................... // 0.0   Uvodni verze se snadnou definici portu LCD displeje  
88
.................... //  
89
.................... //  
90
.................... // Funkce:  
91
.................... //  
92
.................... //   lcd_init()            inicializuje LCD displej a porty, nutno volat jako prvni  
93
.................... //  
94
.................... //   lcd_putc(c)           zapis snaku do lcd displeje, zpracovava nasledujici ridici znaky  
95
.................... //                         \f = \x0C   - nova stranka - smazani displeje  
96
.................... //                         \n = \x0A   - odradkovani (prechod na druhou radku)  
97
.................... //                         \b = \x08   - backspace - posunuti kurzoru o 1 pozici zpet  
98
.................... //                         \r = \x0D   - goto home to position 1,1  
99
.................... //                         \0  .. \7   - definovatelne znaky v pozicich 0 az 7 v CGRAM  
100
.................... //                         \20 .. \27  - alternativne zapsane znaky (oktalove) v pozicich 0 az 7 CGRAM  
101
.................... //                         Pozor na to, ze funkce printf konci tisk pokud narazi na \0 (konec retezce)  
102
.................... //  
103
.................... //   lcd_gotoxy(x,y)       presune kurzor na uvedenou adresu  
104
.................... //                         nekontroluje parametry  
105
.................... //  
106
.................... //   lcd_cursor_on         zapne kurzor  
107
.................... //   lcd_cursor_off        vypne kurzor  
108
.................... //  
109
.................... //   lcd_define_char(Index, Def)       Makro, ktere definuje znaky od pozice Index obsahem definicniho  
110
.................... //                                     retezce Def. Kazdych 8 znaku retezce Def definuje dalsi znak v CGRAM.  
111
.................... //                                     Kapacita CGRAM je celkem 8 znaku s indexem 0 az 7.  
112
.................... //                                     Na konci se provede lcd_gotoxy(1,1).  
113
.................... //                                     Na konci teto knihovny je priklad pouziti definovanych znaku  
114
.................... //  
115
.................... // Definice portu:  
116
.................... //  
117
.................... // #DEFINE LCD_RS          PIN_B2      // rizeni registru LCD displeje  
118
.................... // #DEFINE LCD_E           PIN_B1      // enable LCD displeje  
119
.................... // #DEFINE LCD_DATA_LSB    PIN_C2      // pripojeni LSB bitu datoveho portu LCD displeje (celkem 4 bity vzestupne za sebou)  
120
....................   
121
....................   
122
....................   
123
....................   
124
.................... // Privatni sekce, cist jen v pripade, ze neco nefunguje  
125
....................   
126
....................   
127
....................   
128
....................   
129
.................... // Generovane defince portu pro ucely teto knihovny aby kod generoval spravne IO operace a soucasne  
130
.................... // bylo mozne jednoduse deklarovat pripojene piny LCD displeje pri pouziti teto knihovny. Problem spociva  
131
.................... // v tom, ze se musi spravne ridit smery portu a soucasne datovy port zabira jen 4 bity ze zadaneho portu  
132
.................... //  
133
.................... #DEFINE LCD_SHIFT (LCD_DATA_LSB&7)                 // pocet bitu posuvu dataoveho kanalu v datovem portu  
134
.................... #DEFINE LCD_PORT  (LCD_DATA_LSB>>3)                // adresa LCD datoveho portu  
135
.................... #DEFINE LCD_TRIS  (LCD_PORT+0x80)                  // adresa prislusneho TRIS registru  
136
.................... #DEFINE LCD_MASK  (0xF<<LCD_SHIFT)                 // maska platnych bitu  
137
.................... //  
138
.................... #IF LCD_SHIFT>4                                    // kontrola mezi  
139
.................... #ERROR LCD data port LSB bit not in range 0..4  
140
.................... #ENDIF  
141
....................   
142
....................   
143
.................... // Definice konstant pro LCD display  
144
.................... //  
145
.................... #define LCD_CURSOR_ON_  0x0E     // kurzor jako blikajici radka pod znakem  
146
.................... #define LCD_CURSOR_OFF_ 0x0C     // zadny kurzor  
147
.................... #define LCD_LINE_2      0x40     // adresa 1. znaku 2. radky  
148
....................   
149
....................   
150
.................... // Definice rezimu LCD displeje  
151
.................... //  
152
.................... BYTE const LCD_INIT_STRING[4] =  
153
.................... {  
154
....................    0x28,                         // intrfejs 4 bity, 2 radky, font 5x7  
155
....................    LCD_CURSOR_OFF_,              // display on, kurzor off,  
156
....................    0x01,                         // clear displeje  
157
....................    0x06                          // inkrement pozice kurzoru (posun kurzoru doprava)  
158
.................... };  
159
*
160
0004:  BCF    0A.0
161
0005:  BCF    0A.1
162
0006:  BCF    0A.2
163
0007:  ADDWF  02,F
164
0008:  RETLW  28
165
0009:  RETLW  0C
166
000A:  RETLW  01
167
000B:  RETLW  06
168
....................   
169
....................   
170
.................... // Odesle nibble do displeje (posle data a klikne signalem e)  
171
.................... //  
172
.................... void lcd_send_nibble( BYTE n )  
173
.................... {  
174
....................    *LCD_PORT = (*LCD_PORT & ~LCD_MASK) | ((n << LCD_SHIFT) & LCD_MASK);      // nastav datove bity portu a ostatni zachovej  
175
*
176
008C:  MOVF   06,W
177
008D:  ANDLW  0F
178
008E:  MOVWF  46
179
008F:  SWAPF  45,W
180
0090:  MOVWF  20
181
0091:  MOVLW  F0
182
0092:  ANDWF  20,F
183
0093:  MOVF   20,W
184
0094:  ANDLW  F0
185
0095:  IORWF  46,W
186
0096:  MOVWF  06
187
....................    output_bit(LCD_E,1);       // vzestupna hrana  
188
0097:  BSF    06.2
189
0098:  BSF    03.5
190
0099:  BCF    06.2
191
....................    delay_us(1);               // pockej alespon 450ns od e nebo alespon 195ns od dat  
192
009A:  NOP
193
....................    output_bit(LCD_E,0);       // sestupna hrana (minimalni perioda e je 1us)  
194
009B:  BCF    03.5
195
009C:  BCF    06.2
196
009D:  BSF    03.5
197
009E:  BCF    06.2
198
009F:  BCF    03.5
199
00A0:  RETLW  00
200
.................... }  
201
....................   
202
....................   
203
.................... // Odesle bajt do registru LCD  
204
.................... //  
205
.................... // Pokud je Adr=0 .. instrukcni registr  
206
.................... // Pokud je Adr=1 .. datovy registr  
207
.................... //  
208
.................... void lcd_send_byte( BOOLEAN Adr, BYTE n )  
209
.................... {  
210
....................    output_bit(LCD_RS,Adr);    // vyber registr  
211
00A1:  MOVF   43,F
212
00A2:  BTFSS  03.2
213
00A3:  GOTO   0A6
214
00A4:  BCF    06.1
215
00A5:  GOTO   0A7
216
00A6:  BSF    06.1
217
00A7:  BSF    03.5
218
00A8:  BCF    06.1
219
....................    swap(n);  
220
00A9:  BCF    03.5
221
00AA:  SWAPF  44,F
222
....................    lcd_send_nibble(n);        // posli horni pulku bajtu  
223
00AB:  MOVF   44,W
224
00AC:  MOVWF  45
225
00AD:  CALL   08C
226
....................    swap(n);  
227
00AE:  SWAPF  44,F
228
....................    lcd_send_nibble(n);        // posli spodni pulku bajtu  
229
00AF:  MOVF   44,W
230
00B0:  MOVWF  45
231
00B1:  CALL   08C
232
....................    delay_us(40);              // minimalni doba na provedeni prikazu  
233
00B2:  MOVLW  0D
234
00B3:  MOVWF  20
235
00B4:  DECFSZ 20,F
236
00B5:  GOTO   0B4
237
00B6:  RETLW  00
238
.................... }  
239
....................   
240
....................   
241
.................... // Provede inicializaci LCD displeje, smaze obsah a nastavi mod displeje  
242
.................... //  
243
.................... // Tato procedura se musi volat pred pouzitim ostatnich lcd_ procedur  
244
.................... //  
245
.................... void lcd_init()  
246
.................... {  
247
....................   
248
....................    int i;                              // pocitadlo cyklu  
249
....................   
250
....................    delay_ms(20);                       // spozdeni pro provedeni startu displeje po zapnuti napajeni  
251
00B7:  MOVLW  14
252
00B8:  MOVWF  3F
253
00B9:  CALL   077
254
....................   
255
....................    *LCD_TRIS = *LCD_TRIS & ~LCD_MASK;  // nuluj odpovidajici bity tris registru datoveho portu LCD  
256
00BA:  MOVLW  0F
257
00BB:  BSF    03.5
258
00BC:  ANDWF  06,F
259
....................   
260
....................    output_bit(LCD_RS,0);               // nastav jako vystup a nastav klidovy stav  
261
00BD:  BCF    03.5
262
00BE:  BCF    06.1
263
00BF:  BSF    03.5
264
00C0:  BCF    06.1
265
....................    output_bit(LCD_E,0);               // nastav jako vystup a nastav klidovy stav  
266
00C1:  BCF    03.5
267
00C2:  BCF    06.2
268
00C3:  BSF    03.5
269
00C4:  BCF    06.2
270
....................   
271
....................    for (i=0; i<3; i++)                 // nastav lcd do rezimu 8 bitu sbernice  
272
00C5:  BCF    03.5
273
00C6:  CLRF   36
274
00C7:  MOVF   36,W
275
00C8:  SUBLW  02
276
00C9:  BTFSS  03.0
277
00CA:  GOTO   0D3
278
....................    {  
279
....................       delay_ms(2);                     // muze byt rozdelany prenos dat (2x 4 bity) nebo pomaly povel  
280
00CB:  MOVLW  02
281
00CC:  MOVWF  3F
282
00CD:  CALL   077
283
....................       lcd_send_nibble(3);              // rezim 8 bitu  
284
00CE:  MOVLW  03
285
00CF:  MOVWF  45
286
00D0:  CALL   08C
287
....................    }  
288
00D1:  INCF   36,F
289
00D2:  GOTO   0C7
290
....................   
291
....................    delay_us(40);                       // cas na zpracovani  
292
00D3:  MOVLW  0D
293
00D4:  MOVWF  20
294
00D5:  DECFSZ 20,F
295
00D6:  GOTO   0D5
296
....................    lcd_send_nibble(2);                 // nastav rezim 4 bitu (plati od nasledujiciho prenosu)  
297
00D7:  MOVLW  02
298
00D8:  MOVWF  45
299
00D9:  CALL   08C
300
....................    delay_us(40);                       // cas na zpracovani  
301
00DA:  MOVLW  0D
302
00DB:  MOVWF  20
303
00DC:  DECFSZ 20,F
304
00DD:  GOTO   0DC
305
....................   
306
....................    for (i=0;i<3;i++)                   // proved inicializaci (nastaveni modu, smazani apod)  
307
00DE:  CLRF   36
308
00DF:  MOVF   36,W
309
00E0:  SUBLW  02
310
00E1:  BTFSS  03.0
311
00E2:  GOTO   0EF
312
....................    {  
313
....................       lcd_send_byte(0,LCD_INIT_STRING[i]);  
314
00E3:  MOVF   36,W
315
00E4:  CALL   004
316
00E5:  MOVWF  37
317
00E6:  CLRF   43
318
00E7:  MOVF   37,W
319
00E8:  MOVWF  44
320
00E9:  CALL   0A1
321
....................       delay_ms(2);  
322
00EA:  MOVLW  02
323
00EB:  MOVWF  3F
324
00EC:  CALL   077
325
....................    }  
326
00ED:  INCF   36,F
327
00EE:  GOTO   0DF
328
00EF:  BCF    0A.3
329
00F0:  GOTO   602 (RETURN)
330
.................... }  
331
....................   
332
....................   
333
.................... // Proved presun kurzoru  
334
.................... //  
335
.................... // Pozice 1.1 je domu  
336
.................... //  
337
.................... void lcd_gotoxy( BYTE x, BYTE y)  
338
.................... {  
339
....................   
340
....................    BYTE Adr;  
341
....................   
342
....................    Adr=x-1;  
343
*
344
0227:  MOVLW  01
345
0228:  SUBWF  3F,W
346
0229:  MOVWF  41
347
....................    if(y==2)  
348
022A:  MOVF   40,W
349
022B:  SUBLW  02
350
022C:  BTFSS  03.2
351
022D:  GOTO   230
352
....................      Adr+=LCD_LINE_2;  
353
022E:  MOVLW  40
354
022F:  ADDWF  41,F
355
....................   
356
....................    lcd_send_byte(0,0x80|Adr);  
357
0230:  MOVF   41,W
358
0231:  IORLW  80
359
0232:  MOVWF  42
360
0233:  CLRF   43
361
0234:  MOVF   42,W
362
0235:  MOVWF  44
363
0236:  CALL   0A1
364
0237:  RETLW  00
365
.................... }  
366
....................   
367
....................   
368
.................... // Zapis znaku na displej, zpracovani ridicich znaku  
369
.................... //  
370
.................... void lcd_putc( char c)  
371
.................... {  
372
....................   
373
....................    switch (c)  
374
0238:  MOVF   3E,W
375
0239:  MOVWF  20
376
023A:  MOVLW  0C
377
023B:  SUBWF  20,W
378
023C:  BTFSC  03.2
379
023D:  GOTO   24B
380
023E:  MOVLW  0A
381
023F:  SUBWF  20,W
382
0240:  BTFSC  03.2
383
0241:  GOTO   253
384
0242:  MOVLW  0D
385
0243:  SUBWF  20,W
386
0244:  BTFSC  03.2
387
0245:  GOTO   259
388
0246:  MOVLW  08
389
0247:  SUBWF  20,W
390
0248:  BTFSC  03.2
391
0249:  GOTO   25E
392
024A:  GOTO   263
393
....................    {  
394
....................       case '\f'   : lcd_send_byte(0,1);            // smaz displej  
395
024B:  CLRF   43
396
024C:  MOVLW  01
397
024D:  MOVWF  44
398
024E:  CALL   0A1
399
....................                     delay_ms(2);  
400
024F:  MOVLW  02
401
0250:  MOVWF  3F
402
0251:  CALL   077
403
....................                                             break;  
404
0252:  GOTO   26F
405
....................       case '\n'   : lcd_gotoxy(1,2);        break; // presun se na 1. znak 2. radky  
406
0253:  MOVLW  01
407
0254:  MOVWF  3F
408
0255:  MOVLW  02
409
0256:  MOVWF  40
410
0257:  CALL   227
411
0258:  GOTO   26F
412
....................       case '\r'   : lcd_gotoxy(1,1);        break; // presun home  
413
0259:  MOVLW  01
414
025A:  MOVWF  3F
415
025B:  MOVWF  40
416
025C:  CALL   227
417
025D:  GOTO   26F
418
....................       case '\b'   : lcd_send_byte(0,0x10);  break; // posun kurzor o 1 zpet  
419
025E:  CLRF   43
420
025F:  MOVLW  10
421
0260:  MOVWF  44
422
0261:  CALL   0A1
423
0262:  GOTO   26F
424
....................       default     : if (c<0x20) c&=0x7;            // preklopeni definovatelnych znaku na rozsah 0 az 0x1F  
425
0263:  MOVF   3E,W
426
0264:  SUBLW  1F
427
0265:  BTFSS  03.0
428
0266:  GOTO   269
429
0267:  MOVLW  07
430
0268:  ANDWF  3E,F
431
....................                     lcd_send_byte(1,c);     break; // zapis znak  
432
0269:  MOVLW  01
433
026A:  MOVWF  43
434
026B:  MOVF   3E,W
435
026C:  MOVWF  44
436
026D:  CALL   0A1
437
026E:  GOTO   26F
438
....................    }  
439
026F:  RETLW  00
440
.................... }  
441
....................   
442
....................   
443
.................... // Zapni kurzor  
444
.................... //  
445
.................... void lcd_cursor_on()  
446
.................... {  
447
....................    lcd_send_byte(0,LCD_CURSOR_ON_);  
448
.................... }  
449
....................   
450
....................   
451
.................... // Vypni kurzor  
452
.................... //  
453
.................... void lcd_cursor_off()  
454
.................... {  
455
....................    lcd_send_byte(0,LCD_CURSOR_OFF_);  
456
.................... }  
457
....................   
458
....................   
459
.................... // Definice vlastnich fontu  
460
.................... //  
461
.................... // Vlastnich definic muze byt jen 8 do pozic 0 az 7 pameti CGRAM radice lcd displeje  
462
.................... // Pro snadne definovani jsou pripraveny nasledujici definice a na konci souboru je uveden  
463
.................... // priklad pouziti definovanych znaku.  
464
....................   
465
....................   
466
.................... // Pomocna procedura pro posilani ridicich dat do radice displeje  
467
.................... //  
468
.................... void lcd_putc2(int Data)  
469
.................... {  
470
....................    lcd_send_byte(1,Data);  
471
.................... }  
472
....................   
473
....................   
474
.................... // Pomocne definice pro programovani obsahu CGRAM  
475
.................... //  
476
.................... #DEFINE lcd_define_start(Code)      lcd_send_byte(0,0x40+(Code<<3)); delay_ms(2)  
477
.................... #DEFINE lcd_define_def(String)      printf(lcd_putc2,String);  
478
.................... #DEFINE lcd_define_end()            lcd_send_byte(0,3); delay_ms(2)  
479
....................   
480
....................   
481
.................... // Vlastni vykonne makro pro definovani fontu do pozice Index CGRAM s definicnim retezcem Def  
482
.................... //  
483
.................... #DEFINE lcd_define_char(Index, Def) lcd_define_start(Index); lcd_define_def(Def); lcd_define_end();  
484
....................   
485
....................   
486
.................... // Pripravene definice fontu vybranych znaku  
487
.................... // V tabulce nesmi byt 00 (konec retezce v printf()), misto toho davame 80  
488
.................... //  
489
.................... #DEFINE LCD_CHAR_BAT100 "\x0E\x1F\x1F\x1F\x1F\x1F\x1F\x1F"      /* symbol plne baterie       */  
490
.................... #DEFINE LCD_CHAR_BAT50  "\x0E\x1F\x11\x11\x13\x17\x1F\x1F"      /* symbol polovicni baterie  */  
491
.................... #DEFINE LCD_CHAR_BAT0   "\x0E\x1F\x11\x11\x11\x11\x11\x1F"      /* symbol vybite baterie     */  
492
.................... #DEFINE LCD_CHAR_LUA    "\x04\x0E\x11\x11\x1F\x11\x11\x80"      /* A s carkou                */  
493
.................... #DEFINE LCD_CHAR_LLA    "\x01\x02\x0E\x01\x1F\x11\x0F\x80"      /* a s carkou                */  
494
.................... #DEFINE LCD_CHAR_HUC    "\x0A\x0E\x11\x10\x10\x11\x0E\x80"      /* C s hackem                */  
495
.................... #DEFINE LCD_CHAR_HLC    "\x0A\x04\x0E\x10\x10\x11\x0E\x80"      /* c s hackem                */  
496
.................... #DEFINE LCD_CHAR_HUD    "\x0A\x1C\x12\x11\x11\x12\x1C\x80"      /* D s hackem                */  
497
.................... #DEFINE LCD_CHAR_HLD    "\x05\x03\x0D\x13\x11\x11\x0F\x80"      /* d s hackem                */  
498
.................... #DEFINE LCD_CHAR_LUE    "\x04\x1F\x10\x10\x1E\x10\x1F\x80"      /* E s carkou                */  
499
.................... #DEFINE LCD_CHAR_LLE    "\x01\x02\x0E\x11\x1F\x10\x0E\x80"      /* e s carkou                */  
500
.................... #DEFINE LCD_CHAR_HUE    "\x0A\x1F\x10\x1E\x10\x10\x1F\x80"      /* E s hackem                */  
501
.................... #DEFINE LCD_CHAR_HLE    "\x0A\x04\x0E\x11\x1F\x10\x0E\x80"      /* e s hackem                */  
502
.................... #DEFINE LCD_CHAR_LUI    "\x04\x0E\x04\x04\x04\x04\x0E\x80"      /* I s carkou                */  
503
.................... #DEFINE LCD_CHAR_LLI    "\x02\x04\x80\x0C\x04\x04\x0E\x80"      /* i s carkou                */  
504
.................... #DEFINE LCD_CHAR_HUN    "\x0A\x15\x11\x19\x15\x13\x11\x80"      /* N s hackem                */  
505
.................... #DEFINE LCD_CHAR_HLN    "\x0A\x04\x16\x19\x11\x11\x11\x80"      /* n s hackem                */  
506
.................... #DEFINE LCD_CHAR_LUO    "\x04\x0E\x11\x11\x11\x11\x0E\x80"      /* O s carkou                */  
507
.................... #DEFINE LCD_CHAR_LLO    "\x02\x04\x0E\x11\x11\x11\x0E\x80"      /* o s carkou                */  
508
.................... #DEFINE LCD_CHAR_HUR    "\x0A\x1E\x11\x1E\x14\x12\x11\x80"      /* R s hackem                */  
509
.................... #DEFINE LCD_CHAR_HLR    "\x0A\x04\x16\x19\x10\x10\x10\x80"      /* r s hackem                */  
510
.................... #DEFINE LCD_CHAR_HUS    "\x0A\x0F\x10\x0E\x01\x01\x1E\x80"      /* S s hackem                */  
511
.................... #DEFINE LCD_CHAR_HLS    "\x0A\x04\x0E\x10\x0E\x01\x1E\x80"      /* s s hackem                */  
512
.................... #DEFINE LCD_CHAR_HUT    "\x0A\x1F\x04\x04\x04\x04\x04\x80"      /* T s hackem                */  
513
.................... #DEFINE LCD_CHAR_HLT    "\x0A\x0C\x1C\x08\x08\x09\x06\x80"      /* t s hackem                */  
514
.................... #DEFINE LCD_CHAR_LUU    "\x02\x15\x11\x11\x11\x11\x0E\x80"      /* U s carkou                */  
515
.................... #DEFINE LCD_CHAR_LLU    "\x02\x04\x11\x11\x11\x13\x0D\x80"      /* u s carkou                */  
516
.................... #DEFINE LCD_CHAR_CUU    "\x06\x17\x11\x11\x11\x11\x0E\x80"      /* U s krouzkem              */  
517
.................... #DEFINE LCD_CHAR_CLU    "\x06\x06\x11\x11\x11\x11\x0E\x80"      /* u s krouzkem              */  
518
.................... #DEFINE LCD_CHAR_LUY    "\x02\x15\x11\x0A\x04\x04\x04\x80"      /* Y s carkou                */  
519
.................... #DEFINE LCD_CHAR_LLY    "\x02\x04\x11\x11\x0F\x01\x0E\x80"      /* y s carkou                */  
520
.................... #DEFINE LCD_CHAR_HUZ    "\x0A\x1F\x01\x02\x04\x08\x1F\x80"      /* Z s hackem                */  
521
.................... #DEFINE LCD_CHAR_HLZ    "\x0A\x04\x1F\x02\x04\x08\x1F\x80"      /* z s hackem                */  
522
....................   
523
....................   
524
.................... // Priklad pouziti definovanych znaku  
525
.................... //  
526
.................... //  
527
.................... //void lcd_sample()  
528
.................... //{  
529
.................... //   lcd_define_char(0,LCD_CHAR_BAT50);                 // Priklad definice znaku baterie do pozice 0  
530
.................... //   lcd_define_char(2,LCD_CHAR_HLE LCD_CHAR_LUI);      // Priklad definice znaku e s hackem a I s carkou od pozice 2  
531
.................... //                                                      // vsimnete si, ze neni carka mezi retezci s definici (oba retezce definuji  
532
.................... //                                                      // jediny definicni retezec)  
533
.................... //   printf(lcd_putc,"\fZnaky:\20\22\23");              // priklad vypisu znaku z pozice 0, 2 a 3  
534
.................... //   delay_ms(1000);  
535
.................... //   lcd_define_char(0,LCD_CHAR_BAT0);                  // Predefinovani tvaru znaku v pozici 0  
536
.................... //   delay_ms(1000);  
537
.................... //}  
538
....................  
539
.................... #INCLUDE "lcd2.c" 
540
....................  #define  LCD_SC     0b0000011000     // posun displeje doleva  
541
.................... #define  RIGHT      1  
542
.................... #define  LEFT       0  
543
....................   
544
.................... void lcd_sh(int1 lr)  
545
.................... {  
546
....................    if (lr) lcd_send_byte(0,LCD_SC | 0x100); else lcd_send_byte(0,LCD_SC);  
547
.................... }  
548
....................  
549
.................... //Klavesnice  
550
.................... #DEFINE  PL             PIN_B3              // ovladani klavesnice  
551
.................... #DEFINE  STROBE_LED     PIN_C0  
552
.................... #DEFINE  STROBE_KL      PIN_C1  
553
.................... #DEFINE  DATA_OUT       PIN_C2  
554
.................... #DEFINE  CP             PIN_C3  
555
.................... #DEFINE  DATA_IN        PIN_C4  
556
.................... #INCLUDE "keybord.c" 
557
....................  //#DEFINE  PL             PIN_B3              // ovladani klavesnice  
558
.................... //#DEFINE  STROBE_LED     PIN_C0  
559
.................... //#DEFINE  STROBE_KL      PIN_C1  
560
.................... //#DEFINE  DATA_OUT       PIN_C2  
561
.................... //#DEFINE  CP             PIN_C3  
562
.................... //#DEFINE  DATA_IN        PIN_C4  
563
....................   
564
.................... #DEFINE  znak_0     14  
565
.................... #DEFINE  znak_1     10  
566
.................... #DEFINE  znak_2     11  
567
.................... #DEFINE  znak_3     12  
568
.................... #DEFINE  znak_4     20  
569
.................... #DEFINE  znak_5     21  
570
.................... #DEFINE  znak_6     22  
571
.................... #DEFINE  znak_7     04  
572
.................... #DEFINE  znak_8     05  
573
.................... #DEFINE  znak_9     06  
574
.................... #DEFINE  znak_R     15  
575
.................... #DEFINE  znak_F     16  
576
.................... #DEFINE  znak_C     27  
577
.................... #DEFINE  nic        80  
578
....................   
579
....................   
580
.................... void KL_init()  
581
.................... {  
582
.................... int8 i;  
583
....................    output_high(STROBE_KL);  
584
*
585
00F1:  BCF    25.1
586
00F2:  MOVF   25,W
587
00F3:  BSF    03.5
588
00F4:  MOVWF  07
589
00F5:  BCF    03.5
590
00F6:  BSF    07.1
591
....................    output_high(STROBE_LED);  
592
00F7:  BCF    25.0
593
00F8:  MOVF   25,W
594
00F9:  BSF    03.5
595
00FA:  MOVWF  07
596
00FB:  BCF    03.5
597
00FC:  BSF    07.0
598
....................   
599
....................    for (i=0;i<=7;i++)  
600
00FD:  CLRF   36
601
00FE:  MOVF   36,W
602
00FF:  SUBLW  07
603
0100:  BTFSS  03.0
604
0101:  GOTO   116
605
....................    {  
606
....................       output_low(DATA_IN);  
607
0102:  BCF    25.4
608
0103:  MOVF   25,W
609
0104:  BSF    03.5
610
0105:  MOVWF  07
611
0106:  BCF    03.5
612
0107:  BCF    07.4
613
....................       output_high(CP);  
614
0108:  BCF    25.3
615
0109:  MOVF   25,W
616
010A:  BSF    03.5
617
010B:  MOVWF  07
618
010C:  BCF    03.5
619
010D:  BSF    07.3
620
....................       output_low(CP);  
621
010E:  BCF    25.3
622
010F:  MOVF   25,W
623
0110:  BSF    03.5
624
0111:  MOVWF  07
625
0112:  BCF    03.5
626
0113:  BCF    07.3
627
....................    }  
628
0114:  INCF   36,F
629
0115:  GOTO   0FE
630
....................    output_low(STROBE_KL);  
631
0116:  BCF    25.1
632
0117:  MOVF   25,W
633
0118:  BSF    03.5
634
0119:  MOVWF  07
635
011A:  BCF    03.5
636
011B:  BCF    07.1
637
....................    output_low(STROBE_LED);  
638
011C:  BCF    25.0
639
011D:  MOVF   25,W
640
011E:  BSF    03.5
641
011F:  MOVWF  07
642
0120:  BCF    03.5
643
0121:  BCF    07.0
644
....................    output_high(CP);  
645
0122:  BCF    25.3
646
0123:  MOVF   25,W
647
0124:  BSF    03.5
648
0125:  MOVWF  07
649
0126:  BCF    03.5
650
0127:  BSF    07.3
651
....................    output_high(PL);  
652
0128:  BSF    03.5
653
0129:  BCF    06.3
654
012A:  BCF    03.5
655
012B:  BSF    06.3
656
012C:  BCF    0A.3
657
012D:  GOTO   603 (RETURN)
658
.................... }  
659
....................   
660
.................... void KL_CP(j)  
661
.................... {  
662
.................... int8 i;  
663
....................    for (i=0;i<=j;i++)  
664
....................    {  
665
....................       output_high(CP);  
666
....................       output_low(CP);  
667
....................    }  
668
.................... }  
669
....................   
670
.................... void LED(int8 LED)      //rosviti LED 1-7  
671
.................... {  
672
.................... int i;  
673
....................    output_low(CP);  
674
*
675
01E7:  BCF    25.3
676
01E8:  MOVF   25,W
677
01E9:  BSF    03.5
678
01EA:  MOVWF  07
679
01EB:  BCF    03.5
680
01EC:  BCF    07.3
681
....................    output_low(STROBE_LED);  
682
01ED:  BCF    25.0
683
01EE:  MOVF   25,W
684
01EF:  BSF    03.5
685
01F0:  MOVWF  07
686
01F1:  BCF    03.5
687
01F2:  BCF    07.0
688
....................    for (i=0;i<=7;i++)  
689
01F3:  CLRF   3C
690
01F4:  MOVF   3C,W
691
01F5:  SUBLW  07
692
01F6:  BTFSS  03.0
693
01F7:  GOTO   21A
694
....................    {  
695
....................       output_bit(DATA_IN,bit_test(LED,i));  
696
01F8:  MOVF   3B,W
697
01F9:  MOVWF  20
698
01FA:  MOVF   3C,W
699
01FB:  MOVWF  21
700
01FC:  BTFSC  03.2
701
01FD:  GOTO   202
702
01FE:  BCF    03.0
703
01FF:  RRF    20,F
704
0200:  DECFSZ 21,F
705
0201:  GOTO   1FE
706
0202:  BTFSC  20.0
707
0203:  GOTO   206
708
0204:  BCF    07.4
709
0205:  GOTO   207
710
0206:  BSF    07.4
711
0207:  BCF    25.4
712
0208:  MOVF   25,W
713
0209:  BSF    03.5
714
020A:  MOVWF  07
715
....................       output_high(CP);  
716
020B:  BCF    03.5
717
020C:  BCF    25.3
718
020D:  MOVF   25,W
719
020E:  BSF    03.5
720
020F:  MOVWF  07
721
0210:  BCF    03.5
722
0211:  BSF    07.3
723
....................       output_low(CP);  
724
0212:  BCF    25.3
725
0213:  MOVF   25,W
726
0214:  BSF    03.5
727
0215:  MOVWF  07
728
0216:  BCF    03.5
729
0217:  BCF    07.3
730
....................    };  
731
0218:  INCF   3C,F
732
0219:  GOTO   1F4
733
....................    output_high(STROBE_LED);  
734
021A:  BCF    25.0
735
021B:  MOVF   25,W
736
021C:  BSF    03.5
737
021D:  MOVWF  07
738
021E:  BCF    03.5
739
021F:  BSF    07.0
740
....................    output_low(STROBE_LED);  
741
0220:  BCF    25.0
742
0221:  MOVF   25,W
743
0222:  BSF    03.5
744
0223:  MOVWF  07
745
0224:  BCF    03.5
746
0225:  BCF    07.0
747
0226:  RETLW  00
748
.................... }  
749
....................   
750
.................... int8 klavesa()          //vrati cislo klavesy  
751
.................... {  
752
....................    int8 i;  
753
....................    int8 sloupec;  
754
....................   
755
....................    for(sloupec=0; sloupec<=7; sloupec++)  
756
*
757
012E:  CLRF   3E
758
012F:  MOVF   3E,W
759
0130:  SUBLW  07
760
0131:  BTFSS  03.0
761
0132:  GOTO   1E4
762
....................    {  
763
....................       output_low(STROBE_KL);  
764
0133:  BCF    25.1
765
0134:  MOVF   25,W
766
0135:  BSF    03.5
767
0136:  MOVWF  07
768
0137:  BCF    03.5
769
0138:  BCF    07.1
770
....................       output_low(DATA_IN);  
771
0139:  BCF    25.4
772
013A:  MOVF   25,W
773
013B:  BSF    03.5
774
013C:  MOVWF  07
775
013D:  BCF    03.5
776
013E:  BCF    07.4
777
....................       for (i=0;i<=7;i++)  
778
013F:  CLRF   3D
779
0140:  MOVF   3D,W
780
0141:  SUBLW  07
781
0142:  BTFSS  03.0
782
0143:  GOTO   152
783
....................       {                                   //nulovani sloupcu  
784
....................         output_high(CP);  
785
0144:  BCF    25.3
786
0145:  MOVF   25,W
787
0146:  BSF    03.5
788
0147:  MOVWF  07
789
0148:  BCF    03.5
790
0149:  BSF    07.3
791
....................         output_low(CP);  
792
014A:  BCF    25.3
793
014B:  MOVF   25,W
794
014C:  BSF    03.5
795
014D:  MOVWF  07
796
014E:  BCF    03.5
797
014F:  BCF    07.3
798
....................       }  
799
0150:  INCF   3D,F
800
0151:  GOTO   140
801
....................   
802
....................       output_high(DATA_IN);  
803
0152:  BCF    25.4
804
0153:  MOVF   25,W
805
0154:  BSF    03.5
806
0155:  MOVWF  07
807
0156:  BCF    03.5
808
0157:  BSF    07.4
809
....................       output_high(CP);                    //zavedeni 1 do registru sloupcu  
810
0158:  BCF    25.3
811
0159:  MOVF   25,W
812
015A:  BSF    03.5
813
015B:  MOVWF  07
814
015C:  BCF    03.5
815
015D:  BSF    07.3
816
....................       output_low(CP);  
817
015E:  BCF    25.3
818
015F:  MOVF   25,W
819
0160:  BSF    03.5
820
0161:  MOVWF  07
821
0162:  BCF    03.5
822
0163:  BCF    07.3
823
....................   
824
....................       output_low(DATA_IN);  
825
0164:  BCF    25.4
826
0165:  MOVF   25,W
827
0166:  BSF    03.5
828
0167:  MOVWF  07
829
0168:  BCF    03.5
830
0169:  BCF    07.4
831
....................       for (i=0;i<sloupec;i++)            //nastaveni sloupce  
832
016A:  CLRF   3D
833
016B:  MOVF   3E,W
834
016C:  SUBWF  3D,W
835
016D:  BTFSC  03.0
836
016E:  GOTO   17D
837
....................       {  
838
....................         output_high(CP);  
839
016F:  BCF    25.3
840
0170:  MOVF   25,W
841
0171:  BSF    03.5
842
0172:  MOVWF  07
843
0173:  BCF    03.5
844
0174:  BSF    07.3
845
....................         output_low(CP);  
846
0175:  BCF    25.3
847
0176:  MOVF   25,W
848
0177:  BSF    03.5
849
0178:  MOVWF  07
850
0179:  BCF    03.5
851
017A:  BCF    07.3
852
....................       }  
853
017B:  INCF   3D,F
854
017C:  GOTO   16B
855
....................   
856
....................       output_high(STROBE_KL);  
857
017D:  BCF    25.1
858
017E:  MOVF   25,W
859
017F:  BSF    03.5
860
0180:  MOVWF  07
861
0181:  BCF    03.5
862
0182:  BSF    07.1
863
....................       output_low(PL);  
864
0183:  BSF    03.5
865
0184:  BCF    06.3
866
0185:  BCF    03.5
867
0186:  BCF    06.3
868
....................       output_high(PL);  
869
0187:  BSF    03.5
870
0188:  BCF    06.3
871
0189:  BCF    03.5
872
018A:  BSF    06.3
873
....................   
874
....................       for (i=0;i<5;i++)                  //posunuti cteciho registru  
875
018B:  CLRF   3D
876
018C:  MOVF   3D,W
877
018D:  SUBLW  04
878
018E:  BTFSS  03.0
879
018F:  GOTO   19E
880
....................       {  
881
....................         output_high(CP);  
882
0190:  BCF    25.3
883
0191:  MOVF   25,W
884
0192:  BSF    03.5
885
0193:  MOVWF  07
886
0194:  BCF    03.5
887
0195:  BSF    07.3
888
....................         output_low(CP);  
889
0196:  BCF    25.3
890
0197:  MOVF   25,W
891
0198:  BSF    03.5
892
0199:  MOVWF  07
893
019A:  BCF    03.5
894
019B:  BCF    07.3
895
....................       }  
896
019C:  INCF   3D,F
897
019D:  GOTO   18C
898
....................   
899
....................      /* if (1==input(DATA_OUT)) return(sloupec);           // pokud je 4. radek  
900
....................       output_high(CP);  
901
....................       output_low(CP);  
902
....................       if (1==input(DATA_OUT)) return(sloupec);           // pokud je 3. radek  
903
....................       output_high(CP);  
904
....................       output_low(CP);*/  
905
....................       if (1==input(DATA_OUT)) return(sloupec);           // pokud je 0. radek  
906
019E:  BSF    25.2
907
019F:  MOVF   25,W
908
01A0:  BSF    03.5
909
01A1:  MOVWF  07
910
01A2:  MOVLW  00
911
01A3:  BCF    03.5
912
01A4:  BTFSC  07.2
913
01A5:  MOVLW  01
914
01A6:  SUBLW  01
915
01A7:  BTFSS  03.2
916
01A8:  GOTO   1AC
917
01A9:  MOVF   3E,W
918
01AA:  MOVWF  21
919
01AB:  GOTO   1E6
920
....................       output_high(CP);  
921
01AC:  BCF    25.3
922
01AD:  MOVF   25,W
923
01AE:  BSF    03.5
924
01AF:  MOVWF  07
925
01B0:  BCF    03.5
926
01B1:  BSF    07.3
927
....................       output_low(CP);  
928
01B2:  BCF    25.3
929
01B3:  MOVF   25,W
930
01B4:  BSF    03.5
931
01B5:  MOVWF  07
932
01B6:  BCF    03.5
933
01B7:  BCF    07.3
934
....................       if (1==input(DATA_OUT)) return(0b1000 | sloupec);  // pokud je 1. radek  
935
01B8:  BSF    25.2
936
01B9:  MOVF   25,W
937
01BA:  BSF    03.5
938
01BB:  MOVWF  07
939
01BC:  MOVLW  00
940
01BD:  BCF    03.5
941
01BE:  BTFSC  07.2
942
01BF:  MOVLW  01
943
01C0:  SUBLW  01
944
01C1:  BTFSS  03.2
945
01C2:  GOTO   1C7
946
01C3:  MOVF   3E,W
947
01C4:  IORLW  08
948
01C5:  MOVWF  21
949
01C6:  GOTO   1E6
950
....................       output_high(CP);  
951
01C7:  BCF    25.3
952
01C8:  MOVF   25,W
953
01C9:  BSF    03.5
954
01CA:  MOVWF  07
955
01CB:  BCF    03.5
956
01CC:  BSF    07.3
957
....................       output_low(CP);  
958
01CD:  BCF    25.3
959
01CE:  MOVF   25,W
960
01CF:  BSF    03.5
961
01D0:  MOVWF  07
962
01D1:  BCF    03.5
963
01D2:  BCF    07.3
964
....................       if (1==input(DATA_OUT)) return(0b10000 | sloupec); // pokud je 2. radek  
965
01D3:  BSF    25.2
966
01D4:  MOVF   25,W
967
01D5:  BSF    03.5
968
01D6:  MOVWF  07
969
01D7:  MOVLW  00
970
01D8:  BCF    03.5
971
01D9:  BTFSC  07.2
972
01DA:  MOVLW  01
973
01DB:  SUBLW  01
974
01DC:  BTFSS  03.2
975
01DD:  GOTO   1E2
976
01DE:  MOVF   3E,W
977
01DF:  IORLW  10
978
01E0:  MOVWF  21
979
01E1:  GOTO   1E6
980
....................   
981
....................   
982
....................    }  
983
01E2:  INCF   3E,F
984
01E3:  GOTO   12F
985
....................    return(0x80);  // nastavy nejvissi bit, ze neni nic zmacknuto  
986
01E4:  MOVLW  80
987
01E5:  MOVWF  21
988
01E6:  RETLW  00
989
.................... }  
990
....................   
991
.................... boolean read_KL(char *klv)  
992
.................... {  
993
....................    const char prev_tabulka[24]={'i','z','m','u','7','8','9','.','1','2','3','b','0','r','f','k','4','5','6','s',' ',' ','t','c'};  
994
....................   
995
....................    *klv = klavesa();  
996
....................    if (0x80==*klv) return(false);  
997
....................    else  
998
....................    {  
999
....................       *klv = prev_tabulka[*klv];  
1000
....................       return(true);  
1001
....................    }  
1002
.................... }  
1003
....................   
1004
....................  
1005
.................... //Vysilac  
1006
.................... #DEFINE  VYSILAC        PIN_C5  
1007
.................... #INCLUDE "vysilac.c" 
1008
....................  // Odesle nulu nebo jednicku podle nejnizsiho bitu predanych dat  
1009
.................... // Nula je posloupnost LH a jednicka je HL  
1010
.................... void odeslat_bit(int bit)  
1011
.................... {  
1012
....................    output_bit(VYSILAC,bit);  
1013
*
1014
02C9:  MOVF   3E,F
1015
02CA:  BTFSS  03.2
1016
02CB:  GOTO   2CE
1017
02CC:  BCF    07.5
1018
02CD:  GOTO   2CF
1019
02CE:  BSF    07.5
1020
02CF:  BCF    25.5
1021
02D0:  MOVF   25,W
1022
02D1:  BSF    03.5
1023
02D2:  MOVWF  07
1024
....................    delay_us(IMPULS);  
1025
02D3:  MOVLW  53
1026
02D4:  BCF    03.5
1027
02D5:  MOVWF  20
1028
02D6:  DECFSZ 20,F
1029
02D7:  GOTO   2D6
1030
....................    output_bit(VYSILAC,!bit);  
1031
02D8:  MOVF   3E,F
1032
02D9:  BTFSC  03.2
1033
02DA:  GOTO   2DD
1034
02DB:  BCF    07.5
1035
02DC:  GOTO   2DE
1036
02DD:  BSF    07.5
1037
02DE:  BCF    25.5
1038
02DF:  MOVF   25,W
1039
02E0:  BSF    03.5
1040
02E1:  MOVWF  07
1041
....................    delay_us(IMPULS);  
1042
02E2:  MOVLW  53
1043
02E3:  BCF    03.5
1044
02E4:  MOVWF  20
1045
02E5:  DECFSZ 20,F
1046
02E6:  GOTO   2E5
1047
02E7:  RETLW  00
1048
.................... }  
1049
....................   
1050
.................... // odesle datovy ramec  
1051
.................... void odeslat_paket(int8 kanal,int8 data)  
1052
.................... {  
1053
....................    int   i;  
1054
....................    int8 suma;  
1055
....................   
1056
....................   
1057
....................    data &= 0x1F;     // pro jistotu orizneme data, kdyby nekdo chtel prenaset vic poloh  
1058
02E8:  MOVLW  1F
1059
02E9:  ANDWF  3A,F
1060
....................    data |= kanal << 5;    // slozi osu a hodnotu do packetu  
1061
02EA:  SWAPF  39,W
1062
02EB:  MOVWF  20
1063
02EC:  RLF    20,F
1064
02ED:  MOVLW  E0
1065
02EE:  ANDWF  20,F
1066
02EF:  MOVF   20,W
1067
02F0:  IORWF  3A,F
1068
....................   
1069
....................    swap(data);          // vypocet kontrolniho souctu  
1070
02F1:  SWAPF  3A,F
1071
....................    suma = data & 0xF;     
1072
02F2:  MOVF   3A,W
1073
02F3:  ANDLW  0F
1074
02F4:  MOVWF  3C
1075
....................    swap(data);  
1076
02F5:  SWAPF  3A,F
1077
....................    suma += data & 0xF;  
1078
02F6:  MOVF   3A,W
1079
02F7:  ANDLW  0F
1080
02F8:  ADDWF  3C,F
1081
....................    suma++;  
1082
02F9:  INCF   3C,F
1083
....................   
1084
....................    odeslat_bit(0);         // start bit  
1085
02FA:  CLRF   3E
1086
02FB:  CALL   2C9
1087
....................   
1088
....................    for (i=8; i>0; i--)     // data  
1089
02FC:  MOVLW  08
1090
02FD:  MOVWF  3B
1091
02FE:  MOVF   3B,F
1092
02FF:  BTFSC  03.2
1093
0300:  GOTO   30B
1094
....................    {  
1095
....................       odeslat_bit(bit_test(data,7));  
1096
0301:  MOVLW  00
1097
0302:  BTFSC  3A.7
1098
0303:  MOVLW  01
1099
0304:  MOVWF  3D
1100
0305:  MOVWF  3E
1101
0306:  CALL   2C9
1102
....................       data <<= 1;  
1103
0307:  BCF    03.0
1104
0308:  RLF    3A,F
1105
....................    }  
1106
0309:  DECF   3B,F
1107
030A:  GOTO   2FE
1108
....................   
1109
....................    for (i=4; i>0; i--)     // checksum  
1110
030B:  MOVLW  04
1111
030C:  MOVWF  3B
1112
030D:  MOVF   3B,F
1113
030E:  BTFSC  03.2
1114
030F:  GOTO   31A
1115
....................    {  
1116
....................       odeslat_bit(bit_test(suma,3));  
1117
0310:  MOVLW  00
1118
0311:  BTFSC  3C.3
1119
0312:  MOVLW  01
1120
0313:  MOVWF  3D
1121
0314:  MOVWF  3E
1122
0315:  CALL   2C9
1123
....................       suma <<= 1;  
1124
0316:  BCF    03.0
1125
0317:  RLF    3C,F
1126
....................    }  
1127
0318:  DECF   3B,F
1128
0319:  GOTO   30D
1129
....................    output_high(VYSILAC);  
1130
031A:  BCF    25.5
1131
031B:  MOVF   25,W
1132
031C:  BSF    03.5
1133
031D:  MOVWF  07
1134
031E:  BCF    03.5
1135
031F:  BSF    07.5
1136
0320:  RETLW  00
1137
....................   
1138
.................... }  
1139
....................   
1140
....................  
1141
.................... //Joistick  
1142
.................... #DEFINE  EEleve_x           0  
1143
.................... #DEFINE  EEprave_x          1          //adresovani EEPROM  
1144
.................... #DEFINE  EEhorni_y          2  
1145
.................... #DEFINE  EEdolni_y          3  
1146
....................   
1147
.................... #DEFINE  EEmin_x            4  
1148
.................... #DEFINE  EEmax_x            5  
1149
.................... #DEFINE  EEmin_y            6  
1150
.................... #DEFINE  EEmax_y            7  
1151
.................... #DEFINE  EEstred_x          8  
1152
.................... #DEFINE  EEstred_y          9  
1153
....................   
1154
.................... #DEFINE  AD_OSA_X          1           // adresa A/D prevodniku pro osu X  
1155
.................... #DEFINE  AD_OSA_Y          0           // adresa A/D prevodniku pro osu Y  
1156
.................... #DEFINE  TL1            PIN_C6  
1157
.................... #DEFINE  TL2            PIN_C7  
1158
.................... #INCLUDE "Joystick.c" 
1159
....................  //#DEFINE  AD_OSA_X          0           // adresa A/D prevodniku pro osu X  
1160
.................... //#DEFINE  AD_OSA_Y          1           // adresa A/D prevodniku pro osu Y  
1161
.................... //#DEFINE  TL1           PIN_A2          // tlacitka  
1162
.................... //#DEFINE  TL2           PIN_A4  
1163
....................   
1164
.................... //#DEFINE  EEleve_x           0  
1165
.................... //#DEFINE  EEprave_x          1          //adresovani EEPROM  
1166
.................... //#DEFINE  EEhorni_y          2  
1167
.................... //#DEFINE  EEdolni_y          3  
1168
....................   
1169
.................... //#DEFINE  EEmin_x            4          // ulozeni hodnot (adresy)  
1170
.................... //#DEFINE  EEmax_x            5  
1171
.................... //#DEFINE  EEmin_y            6  
1172
.................... //#DEFINE  EEmax_y            7  
1173
.................... //#DEFINE  EEstred_x          8  
1174
.................... //#DEFINE  EEstred_y          9  
1175
....................   
1176
....................   
1177
.................... unsigned int min_x;  
1178
.................... unsigned int max_x;  
1179
.................... unsigned int min_y;  
1180
.................... unsigned int max_y;  
1181
.................... unsigned int stred_x;  
1182
.................... unsigned int stred_y;  
1183
.................... unsigned int leve_x;  
1184
.................... unsigned int prave_x;  
1185
.................... unsigned int horni_y;  
1186
.................... unsigned int dolni_y;  
1187
....................   
1188
....................   
1189
.................... /*#DEFINE  TEXT0    "Joy set to cent"  
1190
.................... #DEFINE  TEXT1    "er and press OK"  
1191
.................... #DEFINE  TEXT2    "Joy move in some "  
1192
.................... #DEFINE  TEXT3    "full circle"  
1193
.................... #DEFINE  TEXT4    "Calib. complete"*/  
1194
....................   
1195
.................... #DEFINE  TEXT0    " Dejte paku do "  
1196
.................... #DEFINE  TEXT1    "prostred"  
1197
.................... #DEFINE  TEXT2    "Udelajte par"  
1198
.................... #DEFINE  TEXT3    "kruhu"  
1199
.................... #DEFINE  TEXT4    "hotovo"  
1200
....................   
1201
....................   
1202
.................... void Joystick (int *ted_x, int *ted_y, int8 *ted_tl1, int8 *ted_tl2)  
1203
.................... {  
1204
....................    set_adc_channel(AD_OSA_X);  
1205
*
1206
0270:  MOVLW  08
1207
0271:  MOVWF  21
1208
0272:  MOVF   1F,W
1209
0273:  ANDLW  C7
1210
0274:  IORWF  21,W
1211
0275:  MOVWF  1F
1212
....................    delay_us(10);  
1213
0276:  MOVLW  03
1214
0277:  MOVWF  20
1215
0278:  DECFSZ 20,F
1216
0279:  GOTO   278
1217
....................    *ted_x=read_adc();  
1218
027A:  MOVF   3D,W
1219
027B:  MOVWF  04
1220
027C:  BSF    1F.2
1221
027D:  BTFSC  1F.2
1222
027E:  GOTO   27D
1223
027F:  MOVF   1E,W
1224
0280:  MOVWF  00
1225
....................    set_adc_channel(AD_OSA_Y);  
1226
0281:  MOVLW  00
1227
0282:  MOVWF  21
1228
0283:  MOVF   1F,W
1229
0284:  ANDLW  C7
1230
0285:  IORWF  21,W
1231
0286:  MOVWF  1F
1232
....................    delay_us(10);  
1233
0287:  MOVLW  03
1234
0288:  MOVWF  20
1235
0289:  DECFSZ 20,F
1236
028A:  GOTO   289
1237
....................    *ted_y=read_adc();  
1238
028B:  MOVF   3E,W
1239
028C:  MOVWF  04
1240
028D:  BSF    1F.2
1241
028E:  BTFSC  1F.2
1242
028F:  GOTO   28E
1243
0290:  MOVF   1E,W
1244
0291:  MOVWF  00
1245
....................   
1246
....................   
1247
....................  if (!input(TL1))  
1248
0292:  BSF    25.6
1249
0293:  MOVF   25,W
1250
0294:  BSF    03.5
1251
0295:  MOVWF  07
1252
0296:  BCF    03.5
1253
0297:  BTFSC  07.6
1254
0298:  GOTO   2AA
1255
....................   {  
1256
....................   delay_us(500);  
1257
0299:  MOVLW  A6
1258
029A:  MOVWF  20
1259
029B:  DECFSZ 20,F
1260
029C:  GOTO   29B
1261
029D:  NOP
1262
....................   if (!input(TL1)) *ted_tl1=True;  
1263
029E:  BSF    25.6
1264
029F:  MOVF   25,W
1265
02A0:  BSF    03.5
1266
02A1:  MOVWF  07
1267
02A2:  BCF    03.5
1268
02A3:  BTFSC  07.6
1269
02A4:  GOTO   2A9
1270
02A5:  MOVF   3F,W
1271
02A6:  MOVWF  04
1272
02A7:  MOVLW  01
1273
02A8:  MOVWF  00
1274
....................   }  
1275
....................   else *ted_TL1=False;  
1276
02A9:  GOTO   2AD
1277
02AA:  MOVF   3F,W
1278
02AB:  MOVWF  04
1279
02AC:  CLRF   00
1280
....................   
1281
....................  if (!input(TL2))  
1282
02AD:  BSF    25.7
1283
02AE:  MOVF   25,W
1284
02AF:  BSF    03.5
1285
02B0:  MOVWF  07
1286
02B1:  BCF    03.5
1287
02B2:  BTFSC  07.7
1288
02B3:  GOTO   2C5
1289
....................   {  
1290
....................   delay_us(500);  
1291
02B4:  MOVLW  A6
1292
02B5:  MOVWF  20
1293
02B6:  DECFSZ 20,F
1294
02B7:  GOTO   2B6
1295
02B8:  NOP
1296
....................   if (!input(TL2)) *ted_tl2=True;  
1297
02B9:  BSF    25.7
1298
02BA:  MOVF   25,W
1299
02BB:  BSF    03.5
1300
02BC:  MOVWF  07
1301
02BD:  BCF    03.5
1302
02BE:  BTFSC  07.7
1303
02BF:  GOTO   2C4
1304
02C0:  MOVF   40,W
1305
02C1:  MOVWF  04
1306
02C2:  MOVLW  01
1307
02C3:  MOVWF  00
1308
....................   }  
1309
....................   else *ted_tl2=False;  
1310
02C4:  GOTO   2C8
1311
02C5:  MOVF   40,W
1312
02C6:  MOVWF  04
1313
02C7:  CLRF   00
1314
02C8:  RETLW  00
1315
.................... }  
1316
....................   
1317
....................   
1318
....................   
1319
.................... void kalibrace()  
1320
.................... {  
1321
....................   
1322
.................... int  x,y;  
1323
.................... int8 tlac1,tlac2;  
1324
....................   
1325
....................    min_x = max_x = min_y = max_y = stred_x = stred_y = 128;  
1326
*
1327
0367:  MOVLW  80
1328
0368:  MOVWF  2B
1329
0369:  MOVWF  2A
1330
036A:  MOVWF  29
1331
036B:  MOVWF  28
1332
036C:  MOVWF  27
1333
036D:  MOVWF  26
1334
....................   
1335
.................... // ROZSACH JOYSTIKU  
1336
....................    printf(lcd_putc,"\f");  
1337
036E:  MOVLW  0C
1338
036F:  MOVWF  3E
1339
0370:  CALL   238
1340
....................    printf(lcd_putc,TEXT2);  
1341
*
1342
000C:  BCF    0A.0
1343
000D:  BCF    0A.1
1344
000E:  BCF    0A.2
1345
000F:  ADDWF  02,F
1346
0010:  RETLW  55
1347
0011:  RETLW  64
1348
0012:  RETLW  65
1349
0013:  RETLW  6C
1350
0014:  RETLW  61
1351
0015:  RETLW  6A
1352
0016:  RETLW  74
1353
0017:  RETLW  65
1354
0018:  RETLW  20
1355
0019:  RETLW  70
1356
001A:  RETLW  61
1357
001B:  RETLW  72
1358
001C:  RETLW  00
1359
*
1360
0371:  CLRF   3D
1361
0372:  MOVF   3D,W
1362
0373:  CALL   00C
1363
0374:  INCF   3D,F
1364
0375:  MOVWF  3E
1365
0376:  CALL   238
1366
0377:  MOVLW  0C
1367
0378:  SUBWF  3D,W
1368
0379:  BTFSS  03.2
1369
037A:  GOTO   372
1370
....................    lcd_gotoxy(1,2);  
1371
037B:  MOVLW  01
1372
037C:  MOVWF  3F
1373
037D:  MOVLW  02
1374
037E:  MOVWF  40
1375
037F:  CALL   227
1376
....................    printf(lcd_putc,TEXT3);  
1377
*
1378
001D:  BCF    0A.0
1379
001E:  BCF    0A.1
1380
001F:  BCF    0A.2
1381
0020:  ADDWF  02,F
1382
0021:  RETLW  6B
1383
0022:  RETLW  72
1384
0023:  RETLW  75
1385
0024:  RETLW  68
1386
0025:  RETLW  75
1387
0026:  RETLW  00
1388
*
1389
0380:  CLRF   3D
1390
0381:  MOVF   3D,W
1391
0382:  CALL   01D
1392
0383:  INCF   3D,F
1393
0384:  MOVWF  3E
1394
0385:  CALL   238
1395
0386:  MOVLW  05
1396
0387:  SUBWF  3D,W
1397
0388:  BTFSS  03.2
1398
0389:  GOTO   381
1399
....................   
1400
....................    while(input(TL1))  
1401
038A:  BSF    25.6
1402
038B:  MOVF   25,W
1403
038C:  BSF    03.5
1404
038D:  MOVWF  07
1405
038E:  BCF    03.5
1406
038F:  BTFSS  07.6
1407
0390:  GOTO   3B9
1408
....................    {  
1409
....................       if (0x17 == klavesa()) return;         // escape  
1410
0391:  CALL   12E
1411
0392:  MOVF   21,W
1412
0393:  SUBLW  17
1413
0394:  BTFSS  03.2
1414
0395:  GOTO   397
1415
0396:  GOTO   4BD
1416
....................   
1417
....................       Joystick(&x,&y,&tlac1,&tlac2);  
1418
0397:  MOVLW  39
1419
0398:  MOVWF  3D
1420
0399:  MOVLW  3A
1421
039A:  MOVWF  3E
1422
039B:  MOVLW  3B
1423
039C:  MOVWF  3F
1424
039D:  MOVLW  3C
1425
039E:  MOVWF  40
1426
039F:  CALL   270
1427
....................   
1428
....................       if (max_x < x )max_x=x;  
1429
03A0:  MOVF   39,W
1430
03A1:  SUBWF  27,W
1431
03A2:  BTFSC  03.0
1432
03A3:  GOTO   3A6
1433
03A4:  MOVF   39,W
1434
03A5:  MOVWF  27
1435
....................       if (min_x > x )min_x=x;  
1436
03A6:  MOVF   26,W
1437
03A7:  SUBWF  39,W
1438
03A8:  BTFSC  03.0
1439
03A9:  GOTO   3AC
1440
03AA:  MOVF   39,W
1441
03AB:  MOVWF  26
1442
....................       if (max_y < y )max_y=y;                //zjisteni meznich hodnot  
1443
03AC:  MOVF   3A,W
1444
03AD:  SUBWF  29,W
1445
03AE:  BTFSC  03.0
1446
03AF:  GOTO   3B2
1447
03B0:  MOVF   3A,W
1448
03B1:  MOVWF  29
1449
....................       if (min_y > y )min_y=y;  
1450
03B2:  MOVF   28,W
1451
03B3:  SUBWF  3A,W
1452
03B4:  BTFSC  03.0
1453
03B5:  GOTO   3B8
1454
03B6:  MOVF   3A,W
1455
03B7:  MOVWF  28
1456
....................    };  
1457
03B8:  GOTO   38A
1458
....................   
1459
....................    Delay_ms(500);  
1460
03B9:  MOVLW  02
1461
03BA:  MOVWF  3D
1462
03BB:  MOVLW  FA
1463
03BC:  MOVWF  3F
1464
03BD:  CALL   077
1465
03BE:  DECFSZ 3D,F
1466
03BF:  GOTO   3BB
1467
....................    printf(lcd_putc,"\f");  
1468
03C0:  MOVLW  0C
1469
03C1:  MOVWF  3E
1470
03C2:  CALL   238
1471
....................    printf(lcd_putc,TEXT0);  
1472
*
1473
0027:  BCF    0A.0
1474
0028:  BCF    0A.1
1475
0029:  BCF    0A.2
1476
002A:  ADDWF  02,F
1477
002B:  RETLW  20
1478
002C:  RETLW  44
1479
002D:  RETLW  65
1480
002E:  RETLW  6A
1481
002F:  RETLW  74
1482
0030:  RETLW  65
1483
0031:  RETLW  20
1484
0032:  RETLW  70
1485
0033:  RETLW  61
1486
0034:  RETLW  6B
1487
0035:  RETLW  75
1488
0036:  RETLW  20
1489
0037:  RETLW  64
1490
0038:  RETLW  6F
1491
0039:  RETLW  20
1492
003A:  RETLW  00
1493
*
1494
03C3:  CLRF   3D
1495
03C4:  MOVF   3D,W
1496
03C5:  CALL   027
1497
03C6:  INCF   3D,F
1498
03C7:  MOVWF  3E
1499
03C8:  CALL   238
1500
03C9:  MOVLW  0F
1501
03CA:  SUBWF  3D,W
1502
03CB:  BTFSS  03.2
1503
03CC:  GOTO   3C4
1504
....................    lcd_gotoxy(1,2);  
1505
03CD:  MOVLW  01
1506
03CE:  MOVWF  3F
1507
03CF:  MOVLW  02
1508
03D0:  MOVWF  40
1509
03D1:  CALL   227
1510
....................    printf(lcd_putc,TEXT1);  
1511
*
1512
003B:  BCF    0A.0
1513
003C:  BCF    0A.1
1514
003D:  BCF    0A.2
1515
003E:  ADDWF  02,F
1516
003F:  RETLW  70
1517
0040:  RETLW  72
1518
0041:  RETLW  6F
1519
0042:  RETLW  73
1520
0043:  RETLW  74
1521
0044:  RETLW  72
1522
0045:  RETLW  65
1523
0046:  RETLW  64
1524
0047:  RETLW  00
1525
*
1526
03D2:  CLRF   3D
1527
03D3:  MOVF   3D,W
1528
03D4:  CALL   03B
1529
03D5:  INCF   3D,F
1530
03D6:  MOVWF  3E
1531
03D7:  CALL   238
1532
03D8:  MOVLW  08
1533
03D9:  SUBWF  3D,W
1534
03DA:  BTFSS  03.2
1535
03DB:  GOTO   3D3
1536
....................   
1537
....................    while(input(TL1))  
1538
03DC:  BSF    25.6
1539
03DD:  MOVF   25,W
1540
03DE:  BSF    03.5
1541
03DF:  MOVWF  07
1542
03E0:  BCF    03.5
1543
03E1:  BTFSS  07.6
1544
03E2:  GOTO   3ED
1545
....................    joystick(&stred_x,&stred_y,&tlac1,&tlac2);            //nastaveni stredu  
1546
03E3:  MOVLW  2A
1547
03E4:  MOVWF  3D
1548
03E5:  MOVLW  2B
1549
03E6:  MOVWF  3E
1550
03E7:  MOVLW  3B
1551
03E8:  MOVWF  3F
1552
03E9:  MOVLW  3C
1553
03EA:  MOVWF  40
1554
03EB:  CALL   270
1555
03EC:  GOTO   3DC
1556
....................   
1557
....................   
1558
....................   
1559
....................     leve_x=max_x - stred_x;  
1560
03ED:  MOVF   2A,W
1561
03EE:  SUBWF  27,W
1562
03EF:  MOVWF  2C
1563
....................     prave_x=stred_x - min_x;  
1564
03F0:  MOVF   26,W
1565
03F1:  SUBWF  2A,W
1566
03F2:  MOVWF  2D
1567
....................     horni_y=max_y - stred_y;  
1568
03F3:  MOVF   2B,W
1569
03F4:  SUBWF  29,W
1570
03F5:  MOVWF  2E
1571
....................     dolni_y=stred_x - min_x;  
1572
03F6:  MOVF   26,W
1573
03F7:  SUBWF  2A,W
1574
03F8:  MOVWF  2F
1575
....................   
1576
....................     leve_x = leve_x / 8;                     //vypocet parametru  
1577
03F9:  RRF    2C,F
1578
03FA:  RRF    2C,F
1579
03FB:  RRF    2C,F
1580
03FC:  MOVLW  1F
1581
03FD:  ANDWF  2C,F
1582
....................     prave_x = prave_x / 8;  
1583
03FE:  RRF    2D,F
1584
03FF:  RRF    2D,F
1585
0400:  RRF    2D,F
1586
0401:  ANDWF  2D,F
1587
....................     horni_y = horni_y / 8;  
1588
0402:  RRF    2E,F
1589
0403:  RRF    2E,F
1590
0404:  RRF    2E,F
1591
0405:  ANDWF  2E,F
1592
....................     dolni_y = dolni_y / 8;  
1593
0406:  RRF    2F,F
1594
0407:  RRF    2F,F
1595
0408:  RRF    2F,F
1596
0409:  ANDWF  2F,F
1597
....................   
1598
....................    write_eeprom(EEleve_x,leve_x);  
1599
040A:  BSF    03.6
1600
040B:  CLRF   0D
1601
040C:  CLRF   0F
1602
040D:  BCF    03.6
1603
040E:  MOVF   2C,W
1604
040F:  BSF    03.6
1605
0410:  MOVWF  0C
1606
0411:  BSF    03.5
1607
0412:  BCF    0C.7
1608
0413:  BSF    0C.2
1609
0414:  BCF    03.5
1610
0415:  BCF    03.6
1611
0416:  MOVF   0B,W
1612
0417:  MOVWF  20
1613
0418:  BCF    0B.7
1614
0419:  BSF    03.5
1615
041A:  BSF    03.6
1616
041B:  MOVLW  55
1617
041C:  MOVWF  0D
1618
041D:  MOVLW  AA
1619
041E:  MOVWF  0D
1620
041F:  BSF    0C.1
1621
0420:  BTFSC  0C.1
1622
0421:  GOTO   420
1623
0422:  BCF    0C.2
1624
0423:  BCF    03.5
1625
0424:  BCF    03.6
1626
0425:  MOVF   20,W
1627
0426:  IORWF  0B,F
1628
....................    write_eeprom(EEprave_x,prave_x);  
1629
0427:  MOVLW  01
1630
0428:  BSF    03.6
1631
0429:  MOVWF  0D
1632
042A:  CLRF   0F
1633
042B:  BCF    03.6
1634
042C:  MOVF   2D,W
1635
042D:  BSF    03.6
1636
042E:  MOVWF  0C
1637
042F:  BSF    03.5
1638
0430:  BCF    0C.7
1639
0431:  BSF    0C.2
1640
0432:  BCF    03.5
1641
0433:  BCF    03.6
1642
0434:  MOVF   0B,W
1643
0435:  MOVWF  20
1644
0436:  BCF    0B.7
1645
0437:  BSF    03.5
1646
0438:  BSF    03.6
1647
0439:  MOVLW  55
1648
043A:  MOVWF  0D
1649
043B:  MOVLW  AA
1650
043C:  MOVWF  0D
1651
043D:  BSF    0C.1
1652
043E:  BTFSC  0C.1
1653
043F:  GOTO   43E
1654
0440:  BCF    0C.2
1655
0441:  BCF    03.5
1656
0442:  BCF    03.6
1657
0443:  MOVF   20,W
1658
0444:  IORWF  0B,F
1659
....................    write_eeprom(EEstred_x,stred_x);  
1660
0445:  MOVLW  08
1661
0446:  BSF    03.6
1662
0447:  MOVWF  0D
1663
0448:  CLRF   0F
1664
0449:  BCF    03.6
1665
044A:  MOVF   2A,W
1666
044B:  BSF    03.6
1667
044C:  MOVWF  0C
1668
044D:  BSF    03.5
1669
044E:  BCF    0C.7
1670
044F:  BSF    0C.2
1671
0450:  BCF    03.5
1672
0451:  BCF    03.6
1673
0452:  MOVF   0B,W
1674
0453:  MOVWF  20
1675
0454:  BCF    0B.7
1676
0455:  BSF    03.5
1677
0456:  BSF    03.6
1678
0457:  MOVLW  55
1679
0458:  MOVWF  0D
1680
0459:  MOVLW  AA
1681
045A:  MOVWF  0D
1682
045B:  BSF    0C.1
1683
045C:  BTFSC  0C.1
1684
045D:  GOTO   45C
1685
045E:  BCF    0C.2
1686
045F:  BCF    03.5
1687
0460:  BCF    03.6
1688
0461:  MOVF   20,W
1689
0462:  IORWF  0B,F
1690
....................    write_eeprom(EEstred_y,stred_y);  
1691
0463:  MOVLW  09
1692
0464:  BSF    03.6
1693
0465:  MOVWF  0D
1694
0466:  CLRF   0F
1695
0467:  BCF    03.6
1696
0468:  MOVF   2B,W
1697
0469:  BSF    03.6
1698
046A:  MOVWF  0C
1699
046B:  BSF    03.5
1700
046C:  BCF    0C.7
1701
046D:  BSF    0C.2
1702
046E:  BCF    03.5
1703
046F:  BCF    03.6
1704
0470:  MOVF   0B,W
1705
0471:  MOVWF  20
1706
0472:  BCF    0B.7
1707
0473:  BSF    03.5
1708
0474:  BSF    03.6
1709
0475:  MOVLW  55
1710
0476:  MOVWF  0D
1711
0477:  MOVLW  AA
1712
0478:  MOVWF  0D
1713
0479:  BSF    0C.1
1714
047A:  BTFSC  0C.1
1715
047B:  GOTO   47A
1716
047C:  BCF    0C.2
1717
047D:  BCF    03.5
1718
047E:  BCF    03.6
1719
047F:  MOVF   20,W
1720
0480:  IORWF  0B,F
1721
....................    write_eeprom(EEhorni_y,horni_y);  
1722
0481:  MOVLW  02
1723
0482:  BSF    03.6
1724
0483:  MOVWF  0D
1725
0484:  CLRF   0F
1726
0485:  BCF    03.6
1727
0486:  MOVF   2E,W
1728
0487:  BSF    03.6
1729
0488:  MOVWF  0C
1730
0489:  BSF    03.5
1731
048A:  BCF    0C.7
1732
048B:  BSF    0C.2
1733
048C:  BCF    03.5
1734
048D:  BCF    03.6
1735
048E:  MOVF   0B,W
1736
048F:  MOVWF  20
1737
0490:  BCF    0B.7
1738
0491:  BSF    03.5
1739
0492:  BSF    03.6
1740
0493:  MOVLW  55
1741
0494:  MOVWF  0D
1742
0495:  MOVLW  AA
1743
0496:  MOVWF  0D
1744
0497:  BSF    0C.1
1745
0498:  BTFSC  0C.1
1746
0499:  GOTO   498
1747
049A:  BCF    0C.2
1748
049B:  BCF    03.5
1749
049C:  BCF    03.6
1750
049D:  MOVF   20,W
1751
049E:  IORWF  0B,F
1752
....................    write_eeprom(EEdolni_y,dolni_y);  
1753
049F:  MOVLW  03
1754
04A0:  BSF    03.6
1755
04A1:  MOVWF  0D
1756
04A2:  CLRF   0F
1757
04A3:  BCF    03.6
1758
04A4:  MOVF   2F,W
1759
04A5:  BSF    03.6
1760
04A6:  MOVWF  0C
1761
04A7:  BSF    03.5
1762
04A8:  BCF    0C.7
1763
04A9:  BSF    0C.2
1764
04AA:  BCF    03.5
1765
04AB:  BCF    03.6
1766
04AC:  MOVF   0B,W
1767
04AD:  MOVWF  20
1768
04AE:  BCF    0B.7
1769
04AF:  BSF    03.5
1770
04B0:  BSF    03.6
1771
04B1:  MOVLW  55
1772
04B2:  MOVWF  0D
1773
04B3:  MOVLW  AA
1774
04B4:  MOVWF  0D
1775
04B5:  BSF    0C.1
1776
04B6:  BTFSC  0C.1
1777
04B7:  GOTO   4B6
1778
04B8:  BCF    0C.2
1779
04B9:  BCF    03.5
1780
04BA:  BCF    03.6
1781
04BB:  MOVF   20,W
1782
04BC:  IORWF  0B,F
1783
....................   
1784
....................    //write_eeprom(EEmin_x,min_x);              //zapis  
1785
....................    //write_eeprom(EEmax_x,max_x);  
1786
....................    //write_eeprom(EEmin_y,min_y);  
1787
....................    //write_eeprom(EEmax_y,max_y);  
1788
.................... }  
1789
....................   
1790
....................   
1791
....................   
1792
....................  
1793
....................   
1794
.................... int  x,y,tlac1,tlac2;  
1795
....................   
1796
.................... void trimovat()  
1797
.................... {  
1798
....................    odeslat_paket(Trim,0b0001);  
1799
*
1800
04BE:  MOVLW  06
1801
04BF:  MOVWF  39
1802
04C0:  MOVLW  01
1803
04C1:  MOVWF  3A
1804
04C2:  CALL   2E8
1805
....................    odeslat_paket(OSA_X,x);  
1806
04C3:  MOVLW  01
1807
04C4:  MOVWF  39
1808
04C5:  MOVF   30,W
1809
04C6:  MOVWF  3A
1810
04C7:  CALL   2E8
1811
....................    odeslat_paket(OSA_Y,y);  
1812
04C8:  MOVLW  02
1813
04C9:  MOVWF  39
1814
04CA:  MOVF   31,W
1815
04CB:  MOVWF  3A
1816
04CC:  CALL   2E8
1817
.................... }  
1818
....................   
1819
.................... void vysilat()  
1820
.................... {  
1821
....................   
1822
....................    leve_x = read_eeprom(EEleve_x);  
1823
*
1824
04CE:  BSF    03.6
1825
04CF:  CLRF   0D
1826
04D0:  CLRF   0F
1827
04D1:  BSF    03.5
1828
04D2:  BCF    0C.7
1829
04D3:  BSF    0C.0
1830
04D4:  BCF    03.5
1831
04D5:  MOVF   0C,W
1832
04D6:  BCF    03.6
1833
04D7:  MOVWF  2C
1834
....................    prave_x = read_eeprom(EEprave_x);  
1835
04D8:  MOVLW  01
1836
04D9:  BSF    03.6
1837
04DA:  MOVWF  0D
1838
04DB:  CLRF   0F
1839
04DC:  BSF    03.5
1840
04DD:  BCF    0C.7
1841
04DE:  BSF    0C.0
1842
04DF:  BCF    03.5
1843
04E0:  MOVF   0C,W
1844
04E1:  BCF    03.6
1845
04E2:  MOVWF  2D
1846
....................    stred_x = read_eeprom(EEstred_x);  
1847
04E3:  MOVLW  08
1848
04E4:  BSF    03.6
1849
04E5:  MOVWF  0D
1850
04E6:  CLRF   0F
1851
04E7:  BSF    03.5
1852
04E8:  BCF    0C.7
1853
04E9:  BSF    0C.0
1854
04EA:  BCF    03.5
1855
04EB:  MOVF   0C,W
1856
04EC:  BCF    03.6
1857
04ED:  MOVWF  2A
1858
....................    stred_y = read_eeprom(EEstred_y);  
1859
04EE:  MOVLW  09
1860
04EF:  BSF    03.6
1861
04F0:  MOVWF  0D
1862
04F1:  CLRF   0F
1863
04F2:  BSF    03.5
1864
04F3:  BCF    0C.7
1865
04F4:  BSF    0C.0
1866
04F5:  BCF    03.5
1867
04F6:  MOVF   0C,W
1868
04F7:  BCF    03.6
1869
04F8:  MOVWF  2B
1870
....................    horni_y = read_eeprom(EEhorni_y);  
1871
04F9:  MOVLW  02
1872
04FA:  BSF    03.6
1873
04FB:  MOVWF  0D
1874
04FC:  CLRF   0F
1875
04FD:  BSF    03.5
1876
04FE:  BCF    0C.7
1877
04FF:  BSF    0C.0
1878
0500:  BCF    03.5
1879
0501:  MOVF   0C,W
1880
0502:  BCF    03.6
1881
0503:  MOVWF  2E
1882
....................    dolni_y = read_eeprom(EEdolni_y);  
1883
0504:  MOVLW  03
1884
0505:  BSF    03.6
1885
0506:  MOVWF  0D
1886
0507:  CLRF   0F
1887
0508:  BSF    03.5
1888
0509:  BCF    0C.7
1889
050A:  BSF    0C.0
1890
050B:  BCF    03.5
1891
050C:  MOVF   0C,W
1892
050D:  BCF    03.6
1893
050E:  MOVWF  2F
1894
....................   
1895
....................    Delay_ms(200);  
1896
050F:  MOVLW  C8
1897
0510:  MOVWF  3F
1898
0511:  CALL   077
1899
....................    lcd_gotoxy(6,2);  
1900
0512:  MOVLW  06
1901
0513:  MOVWF  3F
1902
0514:  MOVLW  02
1903
0515:  MOVWF  40
1904
0516:  CALL   227
1905
....................    printf(lcd_putc,"Vysilam");  
1906
*
1907
0048:  BCF    0A.0
1908
0049:  BCF    0A.1
1909
004A:  BCF    0A.2
1910
004B:  ADDWF  02,F
1911
004C:  RETLW  56
1912
004D:  RETLW  79
1913
004E:  RETLW  73
1914
004F:  RETLW  69
1915
0050:  RETLW  6C
1916
0051:  RETLW  61
1917
0052:  RETLW  6D
1918
0053:  RETLW  00
1919
*
1920
0517:  CLRF   39
1921
0518:  MOVF   39,W
1922
0519:  CALL   048
1923
051A:  INCF   39,F
1924
051B:  MOVWF  3E
1925
051C:  CALL   238
1926
051D:  MOVLW  07
1927
051E:  SUBWF  39,W
1928
051F:  BTFSS  03.2
1929
0520:  GOTO   518
1930
....................   
1931
....................    while(0x80 == klavesa())  
1932
0521:  CALL   12E
1933
0522:  MOVF   21,W
1934
0523:  SUBLW  80
1935
0524:  BTFSS  03.2
1936
0525:  GOTO   54D
1937
....................       {  
1938
....................          Joystick(&x,&y,&tlac1,&tlac2);  
1939
0526:  MOVLW  30
1940
0527:  MOVWF  3D
1941
0528:  MOVLW  31
1942
0529:  MOVWF  3E
1943
052A:  MOVLW  32
1944
052B:  MOVWF  3F
1945
052C:  MOVLW  33
1946
052D:  MOVWF  40
1947
052E:  CALL   270
1948
....................          /*if (stred_x >= x)  
1949
....................          {  
1950
....................             x = stred_x - x;  
1951
....................             x = x/leve_x;  
1952
....................          }  
1953
....................          else  
1954
....................          {  
1955
....................             x = x - stred_x;  
1956
....................             x = x/prave_x;  
1957
....................          }  
1958
....................   
1959
....................          if (stred_y >= y)  
1960
....................          {  
1961
....................             y = stred_y - y;  
1962
....................             y = y/dolni_y;  
1963
....................          }  
1964
....................          else  
1965
....................          {  
1966
....................             y = y - stred_y;  
1967
....................             y = y/horni_y;  
1968
....................          }*/  
1969
....................   
1970
....................          x=x/8;  
1971
052F:  RRF    30,F
1972
0530:  RRF    30,F
1973
0531:  RRF    30,F
1974
0532:  MOVLW  1F
1975
0533:  ANDWF  30,F
1976
....................          y=y/8;  
1977
0534:  RRF    31,F
1978
0535:  RRF    31,F
1979
0536:  RRF    31,F
1980
0537:  ANDWF  31,F
1981
....................   
1982
....................         odeslat_paket(OSA_X,x);  
1983
0538:  MOVLW  01
1984
0539:  MOVWF  39
1985
053A:  MOVF   30,W
1986
053B:  MOVWF  3A
1987
053C:  CALL   2E8
1988
....................         Delay_us(1600);  
1989
053D:  MOVLW  01
1990
053E:  MOVWF  3F
1991
053F:  CALL   077
1992
0540:  MOVLW  03
1993
0541:  MOVWF  39
1994
0542:  MOVLW  BA
1995
0543:  MOVWF  3A
1996
0544:  GOTO   321
1997
0545:  DECFSZ 39,F
1998
0546:  GOTO   542
1999
....................         odeslat_paket(OSA_Y,y);  
2000
0547:  MOVLW  02
2001
0548:  MOVWF  39
2002
0549:  MOVF   31,W
2003
054A:  MOVWF  3A
2004
054B:  CALL   2E8
2005
....................    }  
2006
054C:  GOTO   521
2007
.................... }  
2008
....................   
2009
.................... void menu()  
2010
.................... {  
2011
.................... int8 polozka = 3;  
2012
.................... int8 old_polozka = 0;  
2013
*
2014
0330:  MOVLW  03
2015
0331:  MOVWF  36
2016
0332:  CLRF   37
2017
.................... int pom;  
2018
....................   
2019
....................    while(true)  
2020
....................    {  
2021
....................       pom = klavesa();  
2022
0333:  CALL   12E
2023
0334:  MOVF   21,W
2024
0335:  MOVWF  38
2025
....................       if (0x07 == pom) polozka++;  
2026
0336:  MOVF   38,W
2027
0337:  SUBLW  07
2028
0338:  BTFSS  03.2
2029
0339:  GOTO   33B
2030
033A:  INCF   36,F
2031
....................       if (0x0f == pom) polozka--;  
2032
033B:  MOVF   38,W
2033
033C:  SUBLW  0F
2034
033D:  BTFSS  03.2
2035
033E:  GOTO   340
2036
033F:  DECF   36,F
2037
....................       if (0x04 <= polozka) polozka = 1;  
2038
0340:  MOVF   36,W
2039
0341:  SUBLW  03
2040
0342:  BTFSC  03.0
2041
0343:  GOTO   346
2042
0344:  MOVLW  01
2043
0345:  MOVWF  36
2044
....................       if (0x00 == polozka) polozka = 3;  
2045
0346:  MOVF   36,F
2046
0347:  BTFSS  03.2
2047
0348:  GOTO   34B
2048
0349:  MOVLW  03
2049
034A:  MOVWF  36
2050
....................       if (0x16 == pom)   // enter  
2051
034B:  MOVF   38,W
2052
034C:  SUBLW  16
2053
034D:  BTFSS  03.2
2054
034E:  GOTO   55E
2055
....................       {  
2056
....................          LED((1 << (polozka + 1)) | 1);  
2057
034F:  MOVLW  01
2058
0350:  ADDWF  36,W
2059
0351:  MOVWF  21
2060
0352:  MOVLW  01
2061
0353:  MOVWF  20
2062
0354:  MOVF   21,F
2063
0355:  BTFSC  03.2
2064
0356:  GOTO   35B
2065
0357:  BCF    03.0
2066
0358:  RLF    20,F
2067
0359:  DECFSZ 21,F
2068
035A:  GOTO   357
2069
035B:  MOVF   20,W
2070
035C:  IORLW  01
2071
035D:  MOVWF  3A
2072
035E:  MOVWF  3B
2073
035F:  CALL   1E7
2074
....................          switch(polozka)  
2075
0360:  MOVLW  01
2076
0361:  SUBWF  36,W
2077
0362:  ADDLW  FD
2078
0363:  BTFSC  03.0
2079
0364:  GOTO   54E
2080
0365:  ADDLW  03
2081
0366:  GOTO   5B3
2082
....................          {  
2083
....................             case 1:  
2084
....................               kalibrace();  
2085
....................               break;  
2086
*
2087
04BD:  GOTO   54E
2088
....................   
2089
....................             case 2:  
2090
....................               trimovat();  
2091
....................               break;  
2092
*
2093
04CD:  GOTO   54E
2094
....................   
2095
....................             case 3:  
2096
....................               vysilat();  
2097
....................               break;  
2098
*
2099
054D:  GOTO   54E
2100
....................          };  
2101
*
2102
05B3:  BSF    0A.0
2103
05B4:  BCF    0A.1
2104
05B5:  BSF    0A.2
2105
05B6:  ADDWF  02,F
2106
05B7:  GOTO   367
2107
05B8:  GOTO   4BE
2108
05B9:  GOTO   4CE
2109
....................          LED(1 << (polozka + 1));  
2110
*
2111
054E:  MOVLW  01
2112
054F:  ADDWF  36,W
2113
0550:  MOVWF  21
2114
0551:  MOVLW  01
2115
0552:  MOVWF  39
2116
0553:  MOVF   21,F
2117
0554:  BTFSC  03.2
2118
0555:  GOTO   55A
2119
0556:  BCF    03.0
2120
0557:  RLF    39,F
2121
0558:  DECFSZ 21,F
2122
0559:  GOTO   556
2123
055A:  MOVF   39,W
2124
055B:  MOVWF  3B
2125
055C:  CALL   1E7
2126
....................          old_polozka=0;  
2127
055D:  CLRF   37
2128
....................       };  
2129
....................   
2130
....................       if (polozka != old_polozka)  
2131
055E:  MOVF   37,W
2132
055F:  SUBWF  36,W
2133
0560:  BTFSC  03.2
2134
0561:  GOTO   5B0
2135
....................       {  
2136
....................          old_polozka=polozka;  
2137
0562:  MOVF   36,W
2138
0563:  MOVWF  37
2139
....................          printf(lcd_putc,"\f");  
2140
0564:  MOVLW  0C
2141
0565:  MOVWF  3E
2142
0566:  CALL   238
2143
....................          switch(polozka)  
2144
0567:  MOVLW  01
2145
0568:  SUBWF  36,W
2146
0569:  ADDLW  FD
2147
056A:  BTFSC  03.0
2148
056B:  GOTO   59E
2149
056C:  ADDLW  03
2150
056D:  GOTO   5BA
2151
....................          {  
2152
....................             case 1:  
2153
....................               lcd_gotoxy(5,2);  
2154
056E:  MOVLW  05
2155
056F:  MOVWF  3F
2156
0570:  MOVLW  02
2157
0571:  MOVWF  40
2158
0572:  CALL   227
2159
....................               printf(lcd_putc,"Kalibrace");  
2160
*
2161
0054:  BCF    0A.0
2162
0055:  BCF    0A.1
2163
0056:  BCF    0A.2
2164
0057:  ADDWF  02,F
2165
0058:  RETLW  4B
2166
0059:  RETLW  61
2167
005A:  RETLW  6C
2168
005B:  RETLW  69
2169
005C:  RETLW  62
2170
005D:  RETLW  72
2171
005E:  RETLW  61
2172
005F:  RETLW  63
2173
0060:  RETLW  65
2174
0061:  RETLW  00
2175
*
2176
0573:  CLRF   39
2177
0574:  MOVF   39,W
2178
0575:  CALL   054
2179
0576:  INCF   39,F
2180
0577:  MOVWF  3E
2181
0578:  CALL   238
2182
0579:  MOVLW  09
2183
057A:  SUBWF  39,W
2184
057B:  BTFSS  03.2
2185
057C:  GOTO   574
2186
....................               break;  
2187
057D:  GOTO   59E
2188
....................   
2189
....................             case 2:  
2190
....................               lcd_gotoxy(7,2);  
2191
057E:  MOVLW  07
2192
057F:  MOVWF  3F
2193
0580:  MOVLW  02
2194
0581:  MOVWF  40
2195
0582:  CALL   227
2196
....................               printf(lcd_putc,"Trim");  
2197
*
2198
0062:  BCF    0A.0
2199
0063:  BCF    0A.1
2200
0064:  BCF    0A.2
2201
0065:  ADDWF  02,F
2202
0066:  RETLW  54
2203
0067:  RETLW  72
2204
0068:  RETLW  69
2205
0069:  RETLW  6D
2206
006A:  RETLW  00
2207
*
2208
0583:  CLRF   39
2209
0584:  MOVF   39,W
2210
0585:  CALL   062
2211
0586:  INCF   39,F
2212
0587:  MOVWF  3E
2213
0588:  CALL   238
2214
0589:  MOVLW  04
2215
058A:  SUBWF  39,W
2216
058B:  BTFSS  03.2
2217
058C:  GOTO   584
2218
....................               break;  
2219
058D:  GOTO   59E
2220
....................   
2221
....................             case 3:  
2222
....................               lcd_gotoxy(6,2);  
2223
058E:  MOVLW  06
2224
058F:  MOVWF  3F
2225
0590:  MOVLW  02
2226
0591:  MOVWF  40
2227
0592:  CALL   227
2228
....................               printf(lcd_putc,"Vysilat");  
2229
*
2230
006B:  BCF    0A.0
2231
006C:  BCF    0A.1
2232
006D:  BCF    0A.2
2233
006E:  ADDWF  02,F
2234
006F:  RETLW  56
2235
0070:  RETLW  79
2236
0071:  RETLW  73
2237
0072:  RETLW  69
2238
0073:  RETLW  6C
2239
0074:  RETLW  61
2240
0075:  RETLW  74
2241
0076:  RETLW  00
2242
*
2243
0593:  CLRF   39
2244
0594:  MOVF   39,W
2245
0595:  CALL   06B
2246
0596:  INCF   39,F
2247
0597:  MOVWF  3E
2248
0598:  CALL   238
2249
0599:  MOVLW  07
2250
059A:  SUBWF  39,W
2251
059B:  BTFSS  03.2
2252
059C:  GOTO   594
2253
....................               break;  
2254
059D:  GOTO   59E
2255
....................          };  
2256
*
2257
05BA:  BSF    0A.0
2258
05BB:  BCF    0A.1
2259
05BC:  BSF    0A.2
2260
05BD:  ADDWF  02,F
2261
05BE:  GOTO   56E
2262
05BF:  GOTO   57E
2263
05C0:  GOTO   58E
2264
....................          LED(1 << (polozka + 1));  
2265
*
2266
059E:  MOVLW  01
2267
059F:  ADDWF  36,W
2268
05A0:  MOVWF  21
2269
05A1:  MOVLW  01
2270
05A2:  MOVWF  39
2271
05A3:  MOVF   21,F
2272
05A4:  BTFSC  03.2
2273
05A5:  GOTO   5AA
2274
05A6:  BCF    03.0
2275
05A7:  RLF    39,F
2276
05A8:  DECFSZ 21,F
2277
05A9:  GOTO   5A6
2278
05AA:  MOVF   39,W
2279
05AB:  MOVWF  3B
2280
05AC:  CALL   1E7
2281
....................          Delay_ms(250);  
2282
05AD:  MOVLW  FA
2283
05AE:  MOVWF  3F
2284
05AF:  CALL   077
2285
....................       }  
2286
....................    }  
2287
05B0:  GOTO   333
2288
05B1:  BCF    0A.3
2289
05B2:  GOTO   604 (RETURN)
2290
.................... }  
2291
....................   
2292
.................... void main()  
2293
.................... {  
2294
.................... int8 tlacitka,tlacitka_old;  
2295
*
2296
05C1:  CLRF   04
2297
05C2:  MOVLW  1F
2298
05C3:  ANDWF  03,F
2299
05C4:  MOVLW  07
2300
05C5:  BSF    03.5
2301
05C6:  MOVWF  1F
2302
05C7:  MOVLW  FF
2303
05C8:  BCF    03.5
2304
05C9:  MOVWF  25
2305
....................    setup_adc_ports(RA0_RA1_RA3_ANALOG);  
2306
05CA:  MOVLW  04
2307
05CB:  BSF    03.5
2308
05CC:  MOVWF  1F
2309
....................    setup_adc(ADC_CLOCK_DIV_2);  
2310
05CD:  BCF    03.5
2311
05CE:  MOVF   1F,W
2312
05CF:  ANDLW  38
2313
05D0:  IORLW  01
2314
05D1:  MOVWF  1F
2315
....................    setup_spi(FALSE);  
2316
05D2:  BCF    14.5
2317
05D3:  BCF    25.5
2318
05D4:  MOVF   25,W
2319
05D5:  BSF    03.5
2320
05D6:  MOVWF  07
2321
05D7:  BCF    03.5
2322
05D8:  BSF    25.4
2323
05D9:  MOVF   25,W
2324
05DA:  BSF    03.5
2325
05DB:  MOVWF  07
2326
05DC:  BCF    03.5
2327
05DD:  BCF    25.3
2328
05DE:  MOVF   25,W
2329
05DF:  BSF    03.5
2330
05E0:  MOVWF  07
2331
05E1:  MOVLW  00
2332
05E2:  BCF    03.5
2333
05E3:  MOVWF  14
2334
05E4:  BSF    03.5
2335
05E5:  MOVWF  14
2336
....................    setup_counters(RTCC_INTERNAL,RTCC_DIV_2);  
2337
05E6:  BCF    03.5
2338
05E7:  CLRF   20
2339
05E8:  BTFSS  20.3
2340
05E9:  GOTO   5F2
2341
05EA:  MOVLW  07
2342
05EB:  CLRF   01
2343
05EC:  MOVLW  81
2344
05ED:  MOVWF  04
2345
05EE:  MOVF   00,W
2346
05EF:  ANDLW  C0
2347
05F0:  IORLW  0F
2348
05F1:  MOVWF  00
2349
05F2:  CLRWDT
2350
05F3:  MOVLW  81
2351
05F4:  MOVWF  04
2352
05F5:  MOVF   00,W
2353
05F6:  ANDLW  C0
2354
05F7:  IORWF  20,W
2355
05F8:  MOVWF  00
2356
....................    setup_timer_1(T1_DISABLED);  
2357
05F9:  CLRF   10
2358
....................    setup_timer_2(T2_DISABLED,0,1);  
2359
05FA:  MOVLW  00
2360
05FB:  MOVWF  21
2361
05FC:  MOVWF  12
2362
05FD:  MOVLW  00
2363
05FE:  BSF    03.5
2364
05FF:  MOVWF  12
2365
....................   
2366
....................    lcd_init();  
2367
0600:  BCF    03.5
2368
0601:  GOTO   0B7
2369
....................    KL_init();  
2370
0602:  GOTO   0F1
2371
....................   
2372
....................    menu();  
2373
0603:  GOTO   330
2374
....................   
2375
.................... while(true)  
2376
.................... {  
2377
.................... //char xx;  
2378
.................... //      if (true == read_kl(&xx))  
2379
.................... //      {  
2380
.................... //      printf(lcd_putc,"%C",xx );  
2381
.................... //      }  
2382
.................... }  
2383
0604:  GOTO   604
2384
.................... }  
2385
....................  
2386
0605:  SLEEP