6 |
kaklik |
1 |
CCS PCW C Compiler, Version 3.110, 15448
|
|
|
2 |
|
|
|
3 |
Filename: d:\@kaklik\programy\pic_c\prenos\letadlo\prijimac\main.LST
|
|
|
4 |
|
|
|
5 |
ROM used: 730 (71%)
|
|
|
6 |
Largest free fragment is 294
|
|
|
7 |
RAM used: 9 (13%) at main() level
|
|
|
8 |
26 (38%) worst case
|
|
|
9 |
Stack: 5 locations
|
|
|
10 |
|
|
|
11 |
*
|
|
|
12 |
0000: MOVLW 00
|
|
|
13 |
0001: MOVWF 0A
|
|
|
14 |
0002: GOTO 251
|
|
|
15 |
0003: NOP
|
|
|
16 |
.................... #include "main.h"
|
|
|
17 |
.................... #include <16F84.h>
|
|
|
18 |
.................... //////// Standard Header file for the PIC16F84 device ////////////////
|
|
|
19 |
.................... #device PIC16F84
|
|
|
20 |
.................... #list
|
|
|
21 |
....................
|
|
|
22 |
.................... #use delay(clock=4000000)
|
|
|
23 |
*
|
|
|
24 |
000C: MOVLW 1A
|
|
|
25 |
000D: MOVWF 04
|
|
|
26 |
000E: MOVF 00,W
|
|
|
27 |
000F: BTFSC 03.2
|
|
|
28 |
0010: GOTO 020
|
|
|
29 |
0011: MOVLW 01
|
|
|
30 |
0012: MOVWF 0D
|
|
|
31 |
0013: CLRF 0C
|
|
|
32 |
0014: DECFSZ 0C,F
|
|
|
33 |
0015: GOTO 014
|
|
|
34 |
0016: DECFSZ 0D,F
|
|
|
35 |
0017: GOTO 013
|
|
|
36 |
0018: MOVLW 4A
|
|
|
37 |
0019: MOVWF 0C
|
|
|
38 |
001A: DECFSZ 0C,F
|
|
|
39 |
001B: GOTO 01A
|
|
|
40 |
001C: NOP
|
|
|
41 |
001D: NOP
|
|
|
42 |
001E: DECFSZ 00,F
|
|
|
43 |
001F: GOTO 011
|
|
|
44 |
0020: RETLW 00
|
|
|
45 |
*
|
|
|
46 |
011B: MOVLW 1D
|
|
|
47 |
011C: MOVWF 04
|
|
|
48 |
011D: MOVLW FC
|
|
|
49 |
011E: ANDWF 00,F
|
|
|
50 |
011F: RRF 00,F
|
|
|
51 |
0120: RRF 00,F
|
|
|
52 |
0121: MOVF 00,W
|
|
|
53 |
0122: BTFSC 03.2
|
|
|
54 |
0123: GOTO 128
|
|
|
55 |
0124: GOTO 126
|
|
|
56 |
0125: NOP
|
|
|
57 |
0126: DECFSZ 00,F
|
|
|
58 |
0127: GOTO 125
|
|
|
59 |
0128: GOTO 154 (RETURN)
|
|
|
60 |
.................... #fuses XT,NOWDT,PUT
|
|
|
61 |
....................
|
|
|
62 |
....................
|
|
|
63 |
.................... #include "..\common.h"
|
|
|
64 |
.................... #DEFINE OSA_X 0 // adresy os
|
|
|
65 |
.................... #DEFINE OSA_Y 1
|
|
|
66 |
.................... #DEFINE TLs 2
|
|
|
67 |
.................... #DEFINE IMPULS 250 // sirka impulsu
|
|
|
68 |
....................
|
|
|
69 |
....................
|
|
|
70 |
.................... #DEFINE LCD_RS PIN_B1 // rizeni registru LCD displeje
|
|
|
71 |
.................... #DEFINE LCD_E PIN_B0 // enable LCD displeje
|
|
|
72 |
.................... #DEFINE LCD_DATA_LSB PIN_B2 // pripojeni LSB bitu datoveho portu LCD displeje (celkem 4 bity vzestupne za sebou)
|
|
|
73 |
.................... #INCLUDE "MYLCD.C"
|
|
|
74 |
.................... // LCD modul pro ovladani dvouradkoveho LCD modulu se standardnim Hitachi radicem
|
|
|
75 |
.................... // (c)miho 2002
|
|
|
76 |
.................... //
|
|
|
77 |
.................... // Historie:
|
|
|
78 |
.................... //
|
|
|
79 |
.................... // 0.0 Uvodni verze se snadnou definici portu LCD displeje
|
|
|
80 |
.................... //
|
|
|
81 |
.................... //
|
|
|
82 |
.................... // Funkce:
|
|
|
83 |
.................... //
|
|
|
84 |
.................... // lcd_init() inicializuje LCD displej a porty, nutno volat jako prvni
|
|
|
85 |
.................... //
|
|
|
86 |
.................... // lcd_putc(c) zapis snaku do lcd displeje, zpracovava nasledujici ridici znaky
|
|
|
87 |
.................... // \f = \x0C - nova stranka - smazani displeje
|
|
|
88 |
.................... // \n = \x0A - odradkovani (prechod na druhou radku)
|
|
|
89 |
.................... // \b = \x08 - backspace - posunuti kurzoru o 1 pozici zpet
|
|
|
90 |
.................... // \r = \x0D - goto home to position 1,1
|
|
|
91 |
.................... // \0 .. \7 - definovatelne znaky v pozicich 0 az 7 v CGRAM
|
|
|
92 |
.................... // \20 .. \27 - alternativne zapsane znaky (oktalove) v pozicich 0 az 7 CGRAM
|
|
|
93 |
.................... // Pozor na to, ze funkce printf konci tisk pokud narazi na \0 (konec retezce)
|
|
|
94 |
.................... //
|
|
|
95 |
.................... // lcd_gotoxy(x,y) presune kurzor na uvedenou adresu
|
|
|
96 |
.................... // nekontroluje parametry
|
|
|
97 |
.................... //
|
|
|
98 |
.................... // lcd_cursor_on zapne kurzor
|
|
|
99 |
.................... // lcd_cursor_off vypne kurzor
|
|
|
100 |
.................... //
|
|
|
101 |
.................... // lcd_define_char(Index, Def) Makro, ktere definuje znaky od pozice Index obsahem definicniho
|
|
|
102 |
.................... // retezce Def. Kazdych 8 znaku retezce Def definuje dalsi znak v CGRAM.
|
|
|
103 |
.................... // Kapacita CGRAM je celkem 8 znaku s indexem 0 az 7.
|
|
|
104 |
.................... // Na konci se provede lcd_gotoxy(1,1).
|
|
|
105 |
.................... // Na konci teto knihovny je priklad pouziti definovanych znaku
|
|
|
106 |
.................... //
|
|
|
107 |
.................... // Definice portu:
|
|
|
108 |
.................... //
|
|
|
109 |
.................... // #DEFINE LCD_RS PIN_B2 // rizeni registru LCD displeje
|
|
|
110 |
.................... // #DEFINE LCD_E PIN_B1 // enable LCD displeje
|
|
|
111 |
.................... // #DEFINE LCD_DATA_LSB PIN_C2 // pripojeni LSB bitu datoveho portu LCD displeje (celkem 4 bity vzestupne za sebou)
|
|
|
112 |
....................
|
|
|
113 |
....................
|
|
|
114 |
....................
|
|
|
115 |
....................
|
|
|
116 |
.................... // Privatni sekce, cist jen v pripade, ze neco nefunguje
|
|
|
117 |
....................
|
|
|
118 |
....................
|
|
|
119 |
....................
|
|
|
120 |
....................
|
|
|
121 |
.................... // Generovane defince portu pro ucely teto knihovny aby kod generoval spravne IO operace a soucasne
|
|
|
122 |
.................... // bylo mozne jednoduse deklarovat pripojene piny LCD displeje pri pouziti teto knihovny. Problem spociva
|
|
|
123 |
.................... // v tom, ze se musi spravne ridit smery portu a soucasne datovy port zabira jen 4 bity ze zadaneho portu
|
|
|
124 |
.................... //
|
|
|
125 |
.................... #DEFINE LCD_SHIFT (LCD_DATA_LSB&7) // pocet bitu posuvu dataoveho kanalu v datovem portu
|
|
|
126 |
.................... #DEFINE LCD_PORT (LCD_DATA_LSB>>3) // adresa LCD datoveho portu
|
|
|
127 |
.................... #DEFINE LCD_TRIS (LCD_PORT+0x80) // adresa prislusneho TRIS registru
|
|
|
128 |
.................... #DEFINE LCD_MASK (0xF<<LCD_SHIFT) // maska platnych bitu
|
|
|
129 |
.................... //
|
|
|
130 |
.................... #IF LCD_SHIFT>4 // kontrola mezi
|
|
|
131 |
.................... #ERROR LCD data port LSB bit not in range 0..4
|
|
|
132 |
.................... #ENDIF
|
|
|
133 |
....................
|
|
|
134 |
....................
|
|
|
135 |
.................... // Definice konstant pro LCD display
|
|
|
136 |
.................... //
|
|
|
137 |
.................... #define LCD_CURSOR_ON_ 0x0E // kurzor jako blikajici radka pod znakem
|
|
|
138 |
.................... #define LCD_CURSOR_OFF_ 0x0C // zadny kurzor
|
|
|
139 |
.................... #define LCD_LINE_2 0x40 // adresa 1. znaku 2. radky
|
|
|
140 |
....................
|
|
|
141 |
....................
|
|
|
142 |
.................... // Definice rezimu LCD displeje
|
|
|
143 |
.................... //
|
|
|
144 |
.................... BYTE const LCD_INIT_STRING[4] =
|
|
|
145 |
.................... {
|
|
|
146 |
.................... 0x28, // intrfejs 4 bity, 2 radky, font 5x7
|
|
|
147 |
.................... LCD_CURSOR_OFF_, // display on, kurzor off,
|
|
|
148 |
.................... 0x01, // clear displeje
|
|
|
149 |
.................... 0x06 // inkrement pozice kurzoru (posun kurzoru doprava)
|
|
|
150 |
.................... };
|
|
|
151 |
*
|
|
|
152 |
0004: BCF 0A.0
|
|
|
153 |
0005: BCF 0A.1
|
|
|
154 |
0006: BCF 0A.2
|
|
|
155 |
0007: ADDWF 02,F
|
|
|
156 |
0008: RETLW 28
|
|
|
157 |
0009: RETLW 0C
|
|
|
158 |
000A: RETLW 01
|
|
|
159 |
000B: RETLW 06
|
|
|
160 |
....................
|
|
|
161 |
....................
|
|
|
162 |
.................... // Odesle nibble do displeje (posle data a klikne signalem e)
|
|
|
163 |
.................... //
|
|
|
164 |
.................... void lcd_send_nibble( BYTE n )
|
|
|
165 |
.................... {
|
|
|
166 |
.................... *LCD_PORT = (*LCD_PORT & ~LCD_MASK) | ((n << LCD_SHIFT) & LCD_MASK); // nastav datove bity portu a ostatni zachovej
|
|
|
167 |
*
|
|
|
168 |
0021: MOVF 06,W
|
|
|
169 |
0022: ANDLW C3
|
|
|
170 |
0023: MOVWF 21
|
|
|
171 |
0024: RLF 20,W
|
|
|
172 |
0025: MOVWF 0C
|
|
|
173 |
0026: RLF 0C,F
|
|
|
174 |
0027: MOVLW FC
|
|
|
175 |
0028: ANDWF 0C,F
|
|
|
176 |
0029: MOVF 0C,W
|
|
|
177 |
002A: ANDLW 3C
|
|
|
178 |
002B: IORWF 21,W
|
|
|
179 |
002C: MOVWF 06
|
|
|
180 |
.................... output_bit(LCD_E,1); // vzestupna hrana
|
|
|
181 |
002D: BSF 06.0
|
|
|
182 |
002E: BSF 03.5
|
|
|
183 |
002F: BCF 06.0
|
|
|
184 |
.................... delay_us(1); // pockej alespon 450ns od e nebo alespon 195ns od dat
|
|
|
185 |
0030: NOP
|
|
|
186 |
.................... output_bit(LCD_E,0); // sestupna hrana (minimalni perioda e je 1us)
|
|
|
187 |
0031: BCF 03.5
|
|
|
188 |
0032: BCF 06.0
|
|
|
189 |
0033: BSF 03.5
|
|
|
190 |
0034: BCF 06.0
|
|
|
191 |
0035: BCF 03.5
|
|
|
192 |
0036: RETLW 00
|
|
|
193 |
.................... }
|
|
|
194 |
....................
|
|
|
195 |
....................
|
|
|
196 |
.................... // Odesle bajt do registru LCD
|
|
|
197 |
.................... //
|
|
|
198 |
.................... // Pokud je Adr=0 .. instrukcni registr
|
|
|
199 |
.................... // Pokud je Adr=1 .. datovy registr
|
|
|
200 |
.................... //
|
|
|
201 |
.................... void lcd_send_byte( BOOLEAN Adr, BYTE n )
|
|
|
202 |
.................... {
|
|
|
203 |
.................... output_bit(LCD_RS,Adr); // vyber registr
|
|
|
204 |
0037: MOVF 1E,F
|
|
|
205 |
0038: BTFSS 03.2
|
|
|
206 |
0039: GOTO 03C
|
|
|
207 |
003A: BCF 06.1
|
|
|
208 |
003B: GOTO 03D
|
|
|
209 |
003C: BSF 06.1
|
|
|
210 |
003D: BSF 03.5
|
|
|
211 |
003E: BCF 06.1
|
|
|
212 |
.................... swap(n);
|
|
|
213 |
003F: BCF 03.5
|
|
|
214 |
0040: SWAPF 1F,F
|
|
|
215 |
.................... lcd_send_nibble(n); // posli horni pulku bajtu
|
|
|
216 |
0041: MOVF 1F,W
|
|
|
217 |
0042: MOVWF 20
|
|
|
218 |
0043: CALL 021
|
|
|
219 |
.................... swap(n);
|
|
|
220 |
0044: SWAPF 1F,F
|
|
|
221 |
.................... lcd_send_nibble(n); // posli spodni pulku bajtu
|
|
|
222 |
0045: MOVF 1F,W
|
|
|
223 |
0046: MOVWF 20
|
|
|
224 |
0047: CALL 021
|
|
|
225 |
.................... delay_us(40); // minimalni doba na provedeni prikazu
|
|
|
226 |
0048: MOVLW 0D
|
|
|
227 |
0049: MOVWF 0C
|
|
|
228 |
004A: DECFSZ 0C,F
|
|
|
229 |
004B: GOTO 04A
|
|
|
230 |
004C: RETLW 00
|
|
|
231 |
.................... }
|
|
|
232 |
....................
|
|
|
233 |
....................
|
|
|
234 |
.................... // Provede inicializaci LCD displeje, smaze obsah a nastavi mod displeje
|
|
|
235 |
.................... //
|
|
|
236 |
.................... // Tato procedura se musi volat pred pouzitim ostatnich lcd_ procedur
|
|
|
237 |
.................... //
|
|
|
238 |
.................... void lcd_init()
|
|
|
239 |
.................... {
|
|
|
240 |
....................
|
|
|
241 |
.................... int i; // pocitadlo cyklu
|
|
|
242 |
....................
|
|
|
243 |
.................... delay_ms(20); // spozdeni pro provedeni startu displeje po zapnuti napajeni
|
|
|
244 |
004D: MOVLW 14
|
|
|
245 |
004E: MOVWF 1A
|
|
|
246 |
004F: CALL 00C
|
|
|
247 |
....................
|
|
|
248 |
.................... *LCD_TRIS = *LCD_TRIS & ~LCD_MASK; // nuluj odpovidajici bity tris registru datoveho portu LCD
|
|
|
249 |
0050: MOVLW C3
|
|
|
250 |
0051: BSF 03.5
|
|
|
251 |
0052: ANDWF 06,F
|
|
|
252 |
....................
|
|
|
253 |
.................... output_bit(LCD_RS,0); // nastav jako vystup a nastav klidovy stav
|
|
|
254 |
0053: BCF 03.5
|
|
|
255 |
0054: BCF 06.1
|
|
|
256 |
0055: BSF 03.5
|
|
|
257 |
0056: BCF 06.1
|
|
|
258 |
.................... output_bit(LCD_E,0); // nastav jako vystup a nastav klidovy stav
|
|
|
259 |
0057: BCF 03.5
|
|
|
260 |
0058: BCF 06.0
|
|
|
261 |
0059: BSF 03.5
|
|
|
262 |
005A: BCF 06.0
|
|
|
263 |
....................
|
|
|
264 |
.................... for (i=0; i<3; i++) // nastav lcd do rezimu 8 bitu sbernice
|
|
|
265 |
005B: BCF 03.5
|
|
|
266 |
005C: CLRF 17
|
|
|
267 |
005D: MOVF 17,W
|
|
|
268 |
005E: SUBLW 02
|
|
|
269 |
005F: BTFSS 03.0
|
|
|
270 |
0060: GOTO 069
|
|
|
271 |
.................... {
|
|
|
272 |
.................... delay_ms(2); // muze byt rozdelany prenos dat (2x 4 bity) nebo pomaly povel
|
|
|
273 |
0061: MOVLW 02
|
|
|
274 |
0062: MOVWF 1A
|
|
|
275 |
0063: CALL 00C
|
|
|
276 |
.................... lcd_send_nibble(3); // rezim 8 bitu
|
|
|
277 |
0064: MOVLW 03
|
|
|
278 |
0065: MOVWF 20
|
|
|
279 |
0066: CALL 021
|
|
|
280 |
.................... }
|
|
|
281 |
0067: INCF 17,F
|
|
|
282 |
0068: GOTO 05D
|
|
|
283 |
....................
|
|
|
284 |
.................... delay_us(40); // cas na zpracovani
|
|
|
285 |
0069: MOVLW 0D
|
|
|
286 |
006A: MOVWF 0C
|
|
|
287 |
006B: DECFSZ 0C,F
|
|
|
288 |
006C: GOTO 06B
|
|
|
289 |
.................... lcd_send_nibble(2); // nastav rezim 4 bitu (plati od nasledujiciho prenosu)
|
|
|
290 |
006D: MOVLW 02
|
|
|
291 |
006E: MOVWF 20
|
|
|
292 |
006F: CALL 021
|
|
|
293 |
.................... delay_us(40); // cas na zpracovani
|
|
|
294 |
0070: MOVLW 0D
|
|
|
295 |
0071: MOVWF 0C
|
|
|
296 |
0072: DECFSZ 0C,F
|
|
|
297 |
0073: GOTO 072
|
|
|
298 |
....................
|
|
|
299 |
.................... for (i=0;i<3;i++) // proved inicializaci (nastaveni modu, smazani apod)
|
|
|
300 |
0074: CLRF 17
|
|
|
301 |
0075: MOVF 17,W
|
|
|
302 |
0076: SUBLW 02
|
|
|
303 |
0077: BTFSS 03.0
|
|
|
304 |
0078: GOTO 085
|
|
|
305 |
.................... {
|
|
|
306 |
.................... lcd_send_byte(0,LCD_INIT_STRING[i]);
|
|
|
307 |
0079: MOVF 17,W
|
|
|
308 |
007A: CALL 004
|
|
|
309 |
007B: MOVWF 18
|
|
|
310 |
007C: CLRF 1E
|
|
|
311 |
007D: MOVF 18,W
|
|
|
312 |
007E: MOVWF 1F
|
|
|
313 |
007F: CALL 037
|
|
|
314 |
.................... delay_ms(2);
|
|
|
315 |
0080: MOVLW 02
|
|
|
316 |
0081: MOVWF 1A
|
|
|
317 |
0082: CALL 00C
|
|
|
318 |
.................... }
|
|
|
319 |
0083: INCF 17,F
|
|
|
320 |
0084: GOTO 075
|
|
|
321 |
0085: GOTO 256 (RETURN)
|
|
|
322 |
.................... }
|
|
|
323 |
....................
|
|
|
324 |
....................
|
|
|
325 |
.................... // Proved presun kurzoru
|
|
|
326 |
.................... //
|
|
|
327 |
.................... // Pozice 1.1 je domu
|
|
|
328 |
.................... //
|
|
|
329 |
.................... void lcd_gotoxy( BYTE x, BYTE y)
|
|
|
330 |
.................... {
|
|
|
331 |
....................
|
|
|
332 |
.................... BYTE Adr;
|
|
|
333 |
....................
|
|
|
334 |
.................... Adr=x-1;
|
|
|
335 |
*
|
|
|
336 |
01C1: MOVLW 01
|
|
|
337 |
01C2: SUBWF 1A,W
|
|
|
338 |
01C3: MOVWF 1C
|
|
|
339 |
.................... if(y==2)
|
|
|
340 |
01C4: MOVF 1B,W
|
|
|
341 |
01C5: SUBLW 02
|
|
|
342 |
01C6: BTFSS 03.2
|
|
|
343 |
01C7: GOTO 1CA
|
|
|
344 |
.................... Adr+=LCD_LINE_2;
|
|
|
345 |
01C8: MOVLW 40
|
|
|
346 |
01C9: ADDWF 1C,F
|
|
|
347 |
....................
|
|
|
348 |
.................... lcd_send_byte(0,0x80|Adr);
|
|
|
349 |
01CA: MOVF 1C,W
|
|
|
350 |
01CB: IORLW 80
|
|
|
351 |
01CC: MOVWF 1D
|
|
|
352 |
01CD: CLRF 1E
|
|
|
353 |
01CE: MOVF 1D,W
|
|
|
354 |
01CF: MOVWF 1F
|
|
|
355 |
01D0: CALL 037
|
|
|
356 |
01D1: RETLW 00
|
|
|
357 |
.................... }
|
|
|
358 |
....................
|
|
|
359 |
....................
|
|
|
360 |
.................... // Zapis znaku na displej, zpracovani ridicich znaku
|
|
|
361 |
.................... //
|
|
|
362 |
.................... void lcd_putc( char c)
|
|
|
363 |
.................... {
|
|
|
364 |
....................
|
|
|
365 |
.................... switch (c)
|
|
|
366 |
01D2: MOVF 19,W
|
|
|
367 |
01D3: MOVWF 0C
|
|
|
368 |
01D4: MOVLW 0C
|
|
|
369 |
01D5: SUBWF 0C,W
|
|
|
370 |
01D6: BTFSC 03.2
|
|
|
371 |
01D7: GOTO 1E5
|
|
|
372 |
01D8: MOVLW 0A
|
|
|
373 |
01D9: SUBWF 0C,W
|
|
|
374 |
01DA: BTFSC 03.2
|
|
|
375 |
01DB: GOTO 1ED
|
|
|
376 |
01DC: MOVLW 0D
|
|
|
377 |
01DD: SUBWF 0C,W
|
|
|
378 |
01DE: BTFSC 03.2
|
|
|
379 |
01DF: GOTO 1F3
|
|
|
380 |
01E0: MOVLW 08
|
|
|
381 |
01E1: SUBWF 0C,W
|
|
|
382 |
01E2: BTFSC 03.2
|
|
|
383 |
01E3: GOTO 1F8
|
|
|
384 |
01E4: GOTO 1FD
|
|
|
385 |
.................... {
|
|
|
386 |
.................... case '\f' : lcd_send_byte(0,1); // smaz displej
|
|
|
387 |
01E5: CLRF 1E
|
|
|
388 |
01E6: MOVLW 01
|
|
|
389 |
01E7: MOVWF 1F
|
|
|
390 |
01E8: CALL 037
|
|
|
391 |
.................... delay_ms(2);
|
|
|
392 |
01E9: MOVLW 02
|
|
|
393 |
01EA: MOVWF 1A
|
|
|
394 |
01EB: CALL 00C
|
|
|
395 |
.................... break;
|
|
|
396 |
01EC: GOTO 209
|
|
|
397 |
.................... case '\n' : lcd_gotoxy(1,2); break; // presun se na 1. znak 2. radky
|
|
|
398 |
01ED: MOVLW 01
|
|
|
399 |
01EE: MOVWF 1A
|
|
|
400 |
01EF: MOVLW 02
|
|
|
401 |
01F0: MOVWF 1B
|
|
|
402 |
01F1: CALL 1C1
|
|
|
403 |
01F2: GOTO 209
|
|
|
404 |
.................... case '\r' : lcd_gotoxy(1,1); break; // presun home
|
|
|
405 |
01F3: MOVLW 01
|
|
|
406 |
01F4: MOVWF 1A
|
|
|
407 |
01F5: MOVWF 1B
|
|
|
408 |
01F6: CALL 1C1
|
|
|
409 |
01F7: GOTO 209
|
|
|
410 |
.................... case '\b' : lcd_send_byte(0,0x10); break; // posun kurzor o 1 zpet
|
|
|
411 |
01F8: CLRF 1E
|
|
|
412 |
01F9: MOVLW 10
|
|
|
413 |
01FA: MOVWF 1F
|
|
|
414 |
01FB: CALL 037
|
|
|
415 |
01FC: GOTO 209
|
|
|
416 |
.................... default : if (c<0x20) c&=0x7; // preklopeni definovatelnych znaku na rozsah 0 az 0x1F
|
|
|
417 |
01FD: MOVF 19,W
|
|
|
418 |
01FE: SUBLW 1F
|
|
|
419 |
01FF: BTFSS 03.0
|
|
|
420 |
0200: GOTO 203
|
|
|
421 |
0201: MOVLW 07
|
|
|
422 |
0202: ANDWF 19,F
|
|
|
423 |
.................... lcd_send_byte(1,c); break; // zapis znak
|
|
|
424 |
0203: MOVLW 01
|
|
|
425 |
0204: MOVWF 1E
|
|
|
426 |
0205: MOVF 19,W
|
|
|
427 |
0206: MOVWF 1F
|
|
|
428 |
0207: CALL 037
|
|
|
429 |
0208: GOTO 209
|
|
|
430 |
.................... }
|
|
|
431 |
0209: RETLW 00
|
|
|
432 |
.................... }
|
|
|
433 |
....................
|
|
|
434 |
....................
|
|
|
435 |
.................... // Zapni kurzor
|
|
|
436 |
.................... //
|
|
|
437 |
.................... void lcd_cursor_on()
|
|
|
438 |
.................... {
|
|
|
439 |
.................... lcd_send_byte(0,LCD_CURSOR_ON_);
|
|
|
440 |
.................... }
|
|
|
441 |
....................
|
|
|
442 |
....................
|
|
|
443 |
.................... // Vypni kurzor
|
|
|
444 |
.................... //
|
|
|
445 |
.................... void lcd_cursor_off()
|
|
|
446 |
.................... {
|
|
|
447 |
.................... lcd_send_byte(0,LCD_CURSOR_OFF_);
|
|
|
448 |
.................... }
|
|
|
449 |
....................
|
|
|
450 |
....................
|
|
|
451 |
.................... // Definice vlastnich fontu
|
|
|
452 |
.................... //
|
|
|
453 |
.................... // Vlastnich definic muze byt jen 8 do pozic 0 az 7 pameti CGRAM radice lcd displeje
|
|
|
454 |
.................... // Pro snadne definovani jsou pripraveny nasledujici definice a na konci souboru je uveden
|
|
|
455 |
.................... // priklad pouziti definovanych znaku.
|
|
|
456 |
....................
|
|
|
457 |
....................
|
|
|
458 |
.................... // Pomocna procedura pro posilani ridicich dat do radice displeje
|
|
|
459 |
.................... //
|
|
|
460 |
.................... void lcd_putc2(int Data)
|
|
|
461 |
.................... {
|
|
|
462 |
.................... lcd_send_byte(1,Data);
|
|
|
463 |
.................... }
|
|
|
464 |
....................
|
|
|
465 |
....................
|
|
|
466 |
.................... // Pomocne definice pro programovani obsahu CGRAM
|
|
|
467 |
.................... //
|
|
|
468 |
.................... #DEFINE lcd_define_start(Code) lcd_send_byte(0,0x40+(Code<<3)); delay_ms(2)
|
|
|
469 |
.................... #DEFINE lcd_define_def(String) printf(lcd_putc2,String);
|
|
|
470 |
.................... #DEFINE lcd_define_end() lcd_send_byte(0,3); delay_ms(2)
|
|
|
471 |
....................
|
|
|
472 |
....................
|
|
|
473 |
.................... // Vlastni vykonne makro pro definovani fontu do pozice Index CGRAM s definicnim retezcem Def
|
|
|
474 |
.................... //
|
|
|
475 |
.................... #DEFINE lcd_define_char(Index, Def) lcd_define_start(Index); lcd_define_def(Def); lcd_define_end();
|
|
|
476 |
....................
|
|
|
477 |
....................
|
|
|
478 |
.................... // Pripravene definice fontu vybranych znaku
|
|
|
479 |
.................... // V tabulce nesmi byt 00 (konec retezce v printf()), misto toho davame 80
|
|
|
480 |
.................... //
|
|
|
481 |
.................... #DEFINE LCD_CHAR_BAT100 "\x0E\x1F\x1F\x1F\x1F\x1F\x1F\x1F" /* symbol plne baterie */
|
|
|
482 |
.................... #DEFINE LCD_CHAR_BAT50 "\x0E\x1F\x11\x11\x13\x17\x1F\x1F" /* symbol polovicni baterie */
|
|
|
483 |
.................... #DEFINE LCD_CHAR_BAT0 "\x0E\x1F\x11\x11\x11\x11\x11\x1F" /* symbol vybite baterie */
|
|
|
484 |
.................... #DEFINE LCD_CHAR_LUA "\x04\x0E\x11\x11\x1F\x11\x11\x80" /* A s carkou */
|
|
|
485 |
.................... #DEFINE LCD_CHAR_LLA "\x01\x02\x0E\x01\x1F\x11\x0F\x80" /* a s carkou */
|
|
|
486 |
.................... #DEFINE LCD_CHAR_HUC "\x0A\x0E\x11\x10\x10\x11\x0E\x80" /* C s hackem */
|
|
|
487 |
.................... #DEFINE LCD_CHAR_HLC "\x0A\x04\x0E\x10\x10\x11\x0E\x80" /* c s hackem */
|
|
|
488 |
.................... #DEFINE LCD_CHAR_HUD "\x0A\x1C\x12\x11\x11\x12\x1C\x80" /* D s hackem */
|
|
|
489 |
.................... #DEFINE LCD_CHAR_HLD "\x05\x03\x0D\x13\x11\x11\x0F\x80" /* d s hackem */
|
|
|
490 |
.................... #DEFINE LCD_CHAR_LUE "\x04\x1F\x10\x10\x1E\x10\x1F\x80" /* E s carkou */
|
|
|
491 |
.................... #DEFINE LCD_CHAR_LLE "\x01\x02\x0E\x11\x1F\x10\x0E\x80" /* e s carkou */
|
|
|
492 |
.................... #DEFINE LCD_CHAR_HUE "\x0A\x1F\x10\x1E\x10\x10\x1F\x80" /* E s hackem */
|
|
|
493 |
.................... #DEFINE LCD_CHAR_HLE "\x0A\x04\x0E\x11\x1F\x10\x0E\x80" /* e s hackem */
|
|
|
494 |
.................... #DEFINE LCD_CHAR_LUI "\x04\x0E\x04\x04\x04\x04\x0E\x80" /* I s carkou */
|
|
|
495 |
.................... #DEFINE LCD_CHAR_LLI "\x02\x04\x80\x0C\x04\x04\x0E\x80" /* i s carkou */
|
|
|
496 |
.................... #DEFINE LCD_CHAR_HUN "\x0A\x15\x11\x19\x15\x13\x11\x80" /* N s hackem */
|
|
|
497 |
.................... #DEFINE LCD_CHAR_HLN "\x0A\x04\x16\x19\x11\x11\x11\x80" /* n s hackem */
|
|
|
498 |
.................... #DEFINE LCD_CHAR_LUO "\x04\x0E\x11\x11\x11\x11\x0E\x80" /* O s carkou */
|
|
|
499 |
.................... #DEFINE LCD_CHAR_LLO "\x02\x04\x0E\x11\x11\x11\x0E\x80" /* o s carkou */
|
|
|
500 |
.................... #DEFINE LCD_CHAR_HUR "\x0A\x1E\x11\x1E\x14\x12\x11\x80" /* R s hackem */
|
|
|
501 |
.................... #DEFINE LCD_CHAR_HLR "\x0A\x04\x16\x19\x10\x10\x10\x80" /* r s hackem */
|
|
|
502 |
.................... #DEFINE LCD_CHAR_HUS "\x0A\x0F\x10\x0E\x01\x01\x1E\x80" /* S s hackem */
|
|
|
503 |
.................... #DEFINE LCD_CHAR_HLS "\x0A\x04\x0E\x10\x0E\x01\x1E\x80" /* s s hackem */
|
|
|
504 |
.................... #DEFINE LCD_CHAR_HUT "\x0A\x1F\x04\x04\x04\x04\x04\x80" /* T s hackem */
|
|
|
505 |
.................... #DEFINE LCD_CHAR_HLT "\x0A\x0C\x1C\x08\x08\x09\x06\x80" /* t s hackem */
|
|
|
506 |
.................... #DEFINE LCD_CHAR_LUU "\x02\x15\x11\x11\x11\x11\x0E\x80" /* U s carkou */
|
|
|
507 |
.................... #DEFINE LCD_CHAR_LLU "\x02\x04\x11\x11\x11\x13\x0D\x80" /* u s carkou */
|
|
|
508 |
.................... #DEFINE LCD_CHAR_CUU "\x06\x17\x11\x11\x11\x11\x0E\x80" /* U s krouzkem */
|
|
|
509 |
.................... #DEFINE LCD_CHAR_CLU "\x06\x06\x11\x11\x11\x11\x0E\x80" /* u s krouzkem */
|
|
|
510 |
.................... #DEFINE LCD_CHAR_LUY "\x02\x15\x11\x0A\x04\x04\x04\x80" /* Y s carkou */
|
|
|
511 |
.................... #DEFINE LCD_CHAR_LLY "\x02\x04\x11\x11\x0F\x01\x0E\x80" /* y s carkou */
|
|
|
512 |
.................... #DEFINE LCD_CHAR_HUZ "\x0A\x1F\x01\x02\x04\x08\x1F\x80" /* Z s hackem */
|
|
|
513 |
.................... #DEFINE LCD_CHAR_HLZ "\x0A\x04\x1F\x02\x04\x08\x1F\x80" /* z s hackem */
|
|
|
514 |
....................
|
|
|
515 |
....................
|
|
|
516 |
.................... // Priklad pouziti definovanych znaku
|
|
|
517 |
.................... //
|
|
|
518 |
.................... //
|
|
|
519 |
.................... //void lcd_sample()
|
|
|
520 |
.................... //{
|
|
|
521 |
.................... // lcd_define_char(0,LCD_CHAR_BAT50); // Priklad definice znaku baterie do pozice 0
|
|
|
522 |
.................... // lcd_define_char(2,LCD_CHAR_HLE LCD_CHAR_LUI); // Priklad definice znaku e s hackem a I s carkou od pozice 2
|
|
|
523 |
.................... // // vsimnete si, ze neni carka mezi retezci s definici (oba retezce definuji
|
|
|
524 |
.................... // // jediny definicni retezec)
|
|
|
525 |
.................... // printf(lcd_putc,"\fZnaky:\20\22\23"); // priklad vypisu znaku z pozice 0, 2 a 3
|
|
|
526 |
.................... // delay_ms(1000);
|
|
|
527 |
.................... // lcd_define_char(0,LCD_CHAR_BAT0); // Predefinovani tvaru znaku v pozici 0
|
|
|
528 |
.................... // delay_ms(1000);
|
|
|
529 |
.................... //}
|
|
|
530 |
....................
|
|
|
531 |
.................... #DEFINE PRIJIMAC PIN_A3 // pin na ktery je pripojen prijimac
|
|
|
532 |
.................... #DEFINE SERVO_X PIN_A0 // pin na ktery je pripojeno servo
|
|
|
533 |
.................... #DEFINE SERVO_Y PIN_A1
|
|
|
534 |
....................
|
|
|
535 |
.................... int8 bit,x,y;
|
|
|
536 |
.................... int counter; // pocitadlo 1 a 0 v detektoru
|
|
|
537 |
.................... int x_old=0,y_old;
|
|
|
538 |
....................
|
|
|
539 |
.................... void servo(int uhel, int souradnice)
|
|
|
540 |
.................... {
|
|
|
541 |
....................
|
|
|
542 |
....................
|
|
|
543 |
.................... if (X==souradnice) output_high(SERVO_X); else output_high(SERVO_Y);
|
|
|
544 |
*
|
|
|
545 |
0129: MOVF 18,W
|
|
|
546 |
012A: SUBWF 0F,W
|
|
|
547 |
012B: BTFSS 03.2
|
|
|
548 |
012C: GOTO 132
|
|
|
549 |
012D: BSF 03.5
|
|
|
550 |
012E: BCF 05.0
|
|
|
551 |
012F: BCF 03.5
|
|
|
552 |
0130: BSF 05.0
|
|
|
553 |
0131: GOTO 136
|
|
|
554 |
0132: BSF 03.5
|
|
|
555 |
0133: BCF 05.1
|
|
|
556 |
0134: BCF 03.5
|
|
|
557 |
0135: BSF 05.1
|
|
|
558 |
....................
|
|
|
559 |
.................... delay_us(62.5*uhel);
|
|
|
560 |
0136: CLRF 1A
|
|
|
561 |
0137: MOVF 17,W
|
|
|
562 |
0138: MOVWF 19
|
|
|
563 |
0139: GOTO 086
|
|
|
564 |
013A: CLRF 1C
|
|
|
565 |
013B: CLRF 1B
|
|
|
566 |
013C: MOVLW 7A
|
|
|
567 |
013D: MOVWF 1A
|
|
|
568 |
013E: MOVLW 84
|
|
|
569 |
013F: MOVWF 19
|
|
|
570 |
0140: MOVF 0F,W
|
|
|
571 |
0141: MOVWF 20
|
|
|
572 |
0142: MOVF 0E,W
|
|
|
573 |
0143: MOVWF 1F
|
|
|
574 |
0144: MOVF 0D,W
|
|
|
575 |
0145: MOVWF 1E
|
|
|
576 |
0146: MOVF 0C,W
|
|
|
577 |
0147: MOVWF 1D
|
|
|
578 |
0148: GOTO 0A4
|
|
|
579 |
0149: MOVF 0C,W
|
|
|
580 |
014A: MOVWF 19
|
|
|
581 |
014B: MOVF 0D,W
|
|
|
582 |
014C: MOVWF 1A
|
|
|
583 |
014D: MOVF 0E,W
|
|
|
584 |
014E: MOVWF 1B
|
|
|
585 |
014F: MOVF 0F,W
|
|
|
586 |
0150: MOVWF 1C
|
|
|
587 |
0151: MOVF 0C,W
|
|
|
588 |
0152: MOVWF 1D
|
|
|
589 |
0153: GOTO 11B
|
|
|
590 |
....................
|
|
|
591 |
.................... if (SERVO_X==souradnice) output_low(SERVO_X); else output_low(SERVO_Y);
|
|
|
592 |
0154: MOVF 18,W
|
|
|
593 |
0155: SUBLW 28
|
|
|
594 |
0156: BTFSS 03.2
|
|
|
595 |
0157: GOTO 15D
|
|
|
596 |
0158: BSF 03.5
|
|
|
597 |
0159: BCF 05.0
|
|
|
598 |
015A: BCF 03.5
|
|
|
599 |
015B: BCF 05.0
|
|
|
600 |
015C: GOTO 161
|
|
|
601 |
015D: BSF 03.5
|
|
|
602 |
015E: BCF 05.1
|
|
|
603 |
015F: BCF 03.5
|
|
|
604 |
0160: BCF 05.1
|
|
|
605 |
0161: RETLW 00
|
|
|
606 |
.................... // delay_ms(10);
|
|
|
607 |
....................
|
|
|
608 |
....................
|
|
|
609 |
.................... }
|
|
|
610 |
....................
|
|
|
611 |
.................... int8 prijmout(int8* bit)
|
|
|
612 |
.................... {
|
|
|
613 |
.................... // || |
|
|
|
614 |
.................... // |--|_____ 1
|
|
|
615 |
.................... // |
|
|
|
616 |
.................... // |-|__|-|_ 0
|
|
|
617 |
....................
|
|
|
618 |
.................... while (!input(PRIJIMAC)) ; // cekej na jednicku
|
|
|
619 |
0162: BSF 03.5
|
|
|
620 |
0163: BSF 05.3
|
|
|
621 |
0164: BCF 03.5
|
|
|
622 |
0165: BTFSS 05.3
|
|
|
623 |
0166: GOTO 162
|
|
|
624 |
.................... delay_us(IMPULS/4); // presvec se, jestli je stale 1 po 1/4 impulsu
|
|
|
625 |
0167: MOVLW 14
|
|
|
626 |
0168: MOVWF 0C
|
|
|
627 |
0169: DECFSZ 0C,F
|
|
|
628 |
016A: GOTO 169
|
|
|
629 |
016B: NOP
|
|
|
630 |
.................... if (!input(PRIJIMAC)) return(false); // vrat chybu, kdyz neni stale 1
|
|
|
631 |
016C: BSF 03.5
|
|
|
632 |
016D: BSF 05.3
|
|
|
633 |
016E: BCF 03.5
|
|
|
634 |
016F: BTFSC 05.3
|
|
|
635 |
0170: GOTO 174
|
|
|
636 |
0171: MOVLW 00
|
|
|
637 |
0172: MOVWF 0D
|
|
|
638 |
0173: GOTO 198
|
|
|
639 |
.................... delay_us(3*IMPULS); // pockej na rozhodovaci misto
|
|
|
640 |
0174: MOVLW F9
|
|
|
641 |
0175: MOVWF 0C
|
|
|
642 |
0176: DECFSZ 0C,F
|
|
|
643 |
0177: GOTO 176
|
|
|
644 |
0178: NOP
|
|
|
645 |
0179: NOP
|
|
|
646 |
.................... if (input(PRIJIMAC)) *bit=0; else *bit=1; // dekoduj 1 nebo 0
|
|
|
647 |
017A: BSF 03.5
|
|
|
648 |
017B: BSF 05.3
|
|
|
649 |
017C: BCF 03.5
|
|
|
650 |
017D: BTFSS 05.3
|
|
|
651 |
017E: GOTO 183
|
|
|
652 |
017F: MOVF 1A,W
|
|
|
653 |
0180: MOVWF 04
|
|
|
654 |
0181: CLRF 00
|
|
|
655 |
0182: GOTO 187
|
|
|
656 |
0183: MOVF 1A,W
|
|
|
657 |
0184: MOVWF 04
|
|
|
658 |
0185: MOVLW 01
|
|
|
659 |
0186: MOVWF 00
|
|
|
660 |
.................... delay_us(IMPULS); // pockej na konec znaku
|
|
|
661 |
0187: MOVLW 53
|
|
|
662 |
0188: MOVWF 0C
|
|
|
663 |
0189: DECFSZ 0C,F
|
|
|
664 |
018A: GOTO 189
|
|
|
665 |
....................
|
|
|
666 |
.................... output_bit(PIN_A0, *bit); // kontrolni vystup
|
|
|
667 |
018B: MOVF 1A,W
|
|
|
668 |
018C: MOVWF 04
|
|
|
669 |
018D: MOVF 00,F
|
|
|
670 |
018E: BTFSS 03.2
|
|
|
671 |
018F: GOTO 192
|
|
|
672 |
0190: BCF 05.0
|
|
|
673 |
0191: GOTO 193
|
|
|
674 |
0192: BSF 05.0
|
|
|
675 |
0193: BSF 03.5
|
|
|
676 |
0194: BCF 05.0
|
|
|
677 |
....................
|
|
|
678 |
.................... return(true); // vrat, ze se cteni povedlo
|
|
|
679 |
0195: MOVLW 01
|
|
|
680 |
0196: BCF 03.5
|
|
|
681 |
0197: MOVWF 0D
|
|
|
682 |
0198: RETLW 00
|
|
|
683 |
.................... }
|
|
|
684 |
....................
|
|
|
685 |
.................... int8 read_nibble(int8* value)
|
|
|
686 |
.................... {
|
|
|
687 |
.................... int8 n; // citac
|
|
|
688 |
.................... int8 bit; // pomocna promenna
|
|
|
689 |
....................
|
|
|
690 |
.................... *value=0;
|
|
|
691 |
0199: MOVF 17,W
|
|
|
692 |
019A: MOVWF 04
|
|
|
693 |
019B: CLRF 00
|
|
|
694 |
.................... for (n=1; n<=4; n++) // prijmi 4 bity
|
|
|
695 |
019C: MOVLW 01
|
|
|
696 |
019D: MOVWF 18
|
|
|
697 |
019E: MOVF 18,W
|
|
|
698 |
019F: SUBLW 04
|
|
|
699 |
01A0: BTFSS 03.0
|
|
|
700 |
01A1: GOTO 1BE
|
|
|
701 |
.................... {
|
|
|
702 |
.................... *value >>= 1; // posun jiz prectene do leva
|
|
|
703 |
01A2: MOVF 17,W
|
|
|
704 |
01A3: MOVWF 04
|
|
|
705 |
01A4: BCF 03.0
|
|
|
706 |
01A5: RRF 00,W
|
|
|
707 |
01A6: MOVWF 0C
|
|
|
708 |
01A7: MOVWF 00
|
|
|
709 |
.................... if (0==prijmout(&bit)) return(false); // prijmi bit; pri chybe cteni vrat chybu
|
|
|
710 |
01A8: MOVLW 19
|
|
|
711 |
01A9: MOVWF 1A
|
|
|
712 |
01AA: CALL 162
|
|
|
713 |
01AB: MOVF 0D,F
|
|
|
714 |
01AC: BTFSS 03.2
|
|
|
715 |
01AD: GOTO 1B1
|
|
|
716 |
01AE: MOVLW 00
|
|
|
717 |
01AF: MOVWF 0D
|
|
|
718 |
01B0: GOTO 1C0
|
|
|
719 |
.................... *value |= bit << 3; // pridej bit do nibblu
|
|
|
720 |
01B1: MOVF 17,W
|
|
|
721 |
01B2: MOVWF 04
|
|
|
722 |
01B3: RLF 19,W
|
|
|
723 |
01B4: MOVWF 0C
|
|
|
724 |
01B5: RLF 0C,F
|
|
|
725 |
01B6: RLF 0C,F
|
|
|
726 |
01B7: MOVLW F8
|
|
|
727 |
01B8: ANDWF 0C,F
|
|
|
728 |
01B9: MOVF 0C,W
|
|
|
729 |
01BA: IORWF 00,W
|
|
|
730 |
01BB: MOVWF 00
|
|
|
731 |
.................... };
|
|
|
732 |
01BC: INCF 18,F
|
|
|
733 |
01BD: GOTO 19E
|
|
|
734 |
.................... return(true); // vrat 1, jako ,ze je vse O.K.
|
|
|
735 |
01BE: MOVLW 01
|
|
|
736 |
01BF: MOVWF 0D
|
|
|
737 |
01C0: RETLW 00
|
|
|
738 |
.................... }
|
|
|
739 |
....................
|
|
|
740 |
.................... /*void dekodovat(void)
|
|
|
741 |
.................... {
|
|
|
742 |
.................... int8 osa, hodnota, kontrola;
|
|
|
743 |
....................
|
|
|
744 |
.................... counter=4;
|
|
|
745 |
....................
|
|
|
746 |
.................... decoder:
|
|
|
747 |
....................
|
|
|
748 |
.................... counter=0; // vynuluj citac
|
|
|
749 |
.................... do // vyhledej synchronizacni jednicky
|
|
|
750 |
.................... {
|
|
|
751 |
.................... if (!prijmout(&bit)) goto decoder; // prijmi bit; pri chybe zacni znovu
|
|
|
752 |
.................... if (1==bit) counter++; else goto decoder; // kdyz je bit 1, tak zvys citac; jinak zacni znovu
|
|
|
753 |
.................... } while(counter<4); // pockej na 4 jednicky
|
|
|
754 |
....................
|
|
|
755 |
.................... if (!read_nibble(&osa)) goto decoder; // nacti identifikator osy
|
|
|
756 |
....................
|
|
|
757 |
.................... if (!read_nibble(&hodnota)) goto decoder; // nacti 1. nibble; pri chybe zacni znovu
|
|
|
758 |
.................... if (!read_nibble(&kontrola)) goto decoder; // nacti 2. nibble; pri chybe zacni znovu
|
|
|
759 |
.................... if (hodnota != kontrola) goto decoder; // zacni znovu, pokud jsou ruzne nibble
|
|
|
760 |
....................
|
|
|
761 |
.................... switch (osa) // rozeskoc se podle adresy osy
|
|
|
762 |
.................... {
|
|
|
763 |
.................... case OSA_X:
|
|
|
764 |
.................... {
|
|
|
765 |
.................... x=hodnota;
|
|
|
766 |
.................... break;
|
|
|
767 |
.................... };
|
|
|
768 |
.................... case OSA_Y:
|
|
|
769 |
.................... {
|
|
|
770 |
.................... y=hodnota;
|
|
|
771 |
.................... break;
|
|
|
772 |
.................... };
|
|
|
773 |
.................... case TLs:
|
|
|
774 |
.................... {
|
|
|
775 |
.................... break;
|
|
|
776 |
.................... };
|
|
|
777 |
.................... };
|
|
|
778 |
.................... }
|
|
|
779 |
.................... */
|
|
|
780 |
.................... void main()
|
|
|
781 |
.................... {
|
|
|
782 |
*
|
|
|
783 |
0251: CLRF 04
|
|
|
784 |
0252: MOVLW 1F
|
|
|
785 |
0253: ANDWF 03,F
|
|
|
786 |
0254: CLRF 12
|
|
|
787 |
.................... lcd_init(); // zinicializuj LCD display
|
|
|
788 |
0255: GOTO 04D
|
|
|
789 |
....................
|
|
|
790 |
.................... while (true)
|
|
|
791 |
.................... {
|
|
|
792 |
.................... int8 osa, hodnota, kontrola;
|
|
|
793 |
....................
|
|
|
794 |
.................... counter=4;
|
|
|
795 |
0256: MOVLW 04
|
|
|
796 |
0257: MOVWF 11
|
|
|
797 |
....................
|
|
|
798 |
.................... decoder:
|
|
|
799 |
....................
|
|
|
800 |
.................... servo(x_old,SERVO_X);
|
|
|
801 |
0258: MOVF 12,W
|
|
|
802 |
0259: MOVWF 17
|
|
|
803 |
025A: MOVLW 28
|
|
|
804 |
025B: MOVWF 18
|
|
|
805 |
025C: CALL 129
|
|
|
806 |
....................
|
|
|
807 |
.................... servo(y_old,SERVO_Y);
|
|
|
808 |
025D: MOVF 13,W
|
|
|
809 |
025E: MOVWF 17
|
|
|
810 |
025F: MOVLW 29
|
|
|
811 |
0260: MOVWF 18
|
|
|
812 |
0261: CALL 129
|
|
|
813 |
....................
|
|
|
814 |
.................... counter=0; // vynuluj citac
|
|
|
815 |
0262: CLRF 11
|
|
|
816 |
.................... do // vyhledej synchronizacni jednicky
|
|
|
817 |
.................... {
|
|
|
818 |
.................... if (!prijmout(&bit)) goto decoder; // prijmi bit; pri chybe zacni znovu
|
|
|
819 |
0263: MOVLW 0E
|
|
|
820 |
0264: MOVWF 1A
|
|
|
821 |
0265: CALL 162
|
|
|
822 |
0266: MOVF 0D,F
|
|
|
823 |
0267: BTFSS 03.2
|
|
|
824 |
0268: GOTO 26A
|
|
|
825 |
0269: GOTO 258
|
|
|
826 |
.................... if (1==bit) counter++; else goto decoder; // kdyz je bit 1, tak zvys citac; jinak zacni znovu
|
|
|
827 |
026A: DECFSZ 0E,W
|
|
|
828 |
026B: GOTO 26E
|
|
|
829 |
026C: INCF 11,F
|
|
|
830 |
026D: GOTO 26F
|
|
|
831 |
026E: GOTO 258
|
|
|
832 |
.................... } while(counter<4); // pockej na 4 jednicky
|
|
|
833 |
026F: MOVF 11,W
|
|
|
834 |
0270: SUBLW 03
|
|
|
835 |
0271: BTFSC 03.0
|
|
|
836 |
0272: GOTO 263
|
|
|
837 |
....................
|
|
|
838 |
.................... if (!read_nibble(&osa)) goto decoder; // nacti identifikator osy
|
|
|
839 |
0273: MOVLW 14
|
|
|
840 |
0274: MOVWF 17
|
|
|
841 |
0275: CALL 199
|
|
|
842 |
0276: MOVF 0D,F
|
|
|
843 |
0277: BTFSS 03.2
|
|
|
844 |
0278: GOTO 27A
|
|
|
845 |
0279: GOTO 258
|
|
|
846 |
....................
|
|
|
847 |
.................... if (!read_nibble(&hodnota)) goto decoder; // nacti 1. nibble; pri chybe zacni znovu
|
|
|
848 |
027A: MOVLW 15
|
|
|
849 |
027B: MOVWF 17
|
|
|
850 |
027C: CALL 199
|
|
|
851 |
027D: MOVF 0D,F
|
|
|
852 |
027E: BTFSS 03.2
|
|
|
853 |
027F: GOTO 281
|
|
|
854 |
0280: GOTO 258
|
|
|
855 |
.................... if (!read_nibble(&kontrola)) goto decoder; // nacti 2. nibble; pri chybe zacni znovu
|
|
|
856 |
0281: MOVLW 16
|
|
|
857 |
0282: MOVWF 17
|
|
|
858 |
0283: CALL 199
|
|
|
859 |
0284: MOVF 0D,F
|
|
|
860 |
0285: BTFSS 03.2
|
|
|
861 |
0286: GOTO 288
|
|
|
862 |
0287: GOTO 258
|
|
|
863 |
.................... if (hodnota != kontrola) goto decoder; // zacni znovu, pokud jsou ruzne nibble
|
|
|
864 |
0288: MOVF 16,W
|
|
|
865 |
0289: SUBWF 15,W
|
|
|
866 |
028A: BTFSC 03.2
|
|
|
867 |
028B: GOTO 28D
|
|
|
868 |
028C: GOTO 258
|
|
|
869 |
....................
|
|
|
870 |
.................... switch (osa) // rozeskoc se podle adresy osy
|
|
|
871 |
028D: MOVF 14,W
|
|
|
872 |
028E: ADDLW FD
|
|
|
873 |
028F: BTFSC 03.0
|
|
|
874 |
0290: GOTO 29E
|
|
|
875 |
0291: ADDLW 03
|
|
|
876 |
0292: GOTO 2D3
|
|
|
877 |
.................... {
|
|
|
878 |
.................... case OSA_X:
|
|
|
879 |
.................... {
|
|
|
880 |
....................
|
|
|
881 |
.................... x=hodnota;
|
|
|
882 |
0293: MOVF 15,W
|
|
|
883 |
0294: MOVWF 0F
|
|
|
884 |
.................... x_old=x;
|
|
|
885 |
0295: MOVF 0F,W
|
|
|
886 |
0296: MOVWF 12
|
|
|
887 |
....................
|
|
|
888 |
.................... break;
|
|
|
889 |
0297: GOTO 29E
|
|
|
890 |
.................... };
|
|
|
891 |
.................... case OSA_Y:
|
|
|
892 |
.................... {
|
|
|
893 |
.................... y=hodnota;
|
|
|
894 |
0298: MOVF 15,W
|
|
|
895 |
0299: MOVWF 10
|
|
|
896 |
.................... y_old=y;
|
|
|
897 |
029A: MOVF 10,W
|
|
|
898 |
029B: MOVWF 13
|
|
|
899 |
....................
|
|
|
900 |
.................... break;
|
|
|
901 |
029C: GOTO 29E
|
|
|
902 |
.................... };
|
|
|
903 |
.................... case TLs:
|
|
|
904 |
.................... {
|
|
|
905 |
.................... break;
|
|
|
906 |
029D: GOTO 29E
|
|
|
907 |
.................... };
|
|
|
908 |
.................... };
|
|
|
909 |
*
|
|
|
910 |
02D3: BCF 0A.0
|
|
|
911 |
02D4: BSF 0A.1
|
|
|
912 |
02D5: BCF 0A.2
|
|
|
913 |
02D6: ADDWF 02,F
|
|
|
914 |
02D7: GOTO 293
|
|
|
915 |
02D8: GOTO 298
|
|
|
916 |
02D9: GOTO 29D
|
|
|
917 |
....................
|
|
|
918 |
....................
|
|
|
919 |
.................... lcd_gotoxy(1,1); // vytiskni X a Y
|
|
|
920 |
*
|
|
|
921 |
029E: MOVLW 01
|
|
|
922 |
029F: MOVWF 1A
|
|
|
923 |
02A0: MOVWF 1B
|
|
|
924 |
02A1: CALL 1C1
|
|
|
925 |
.................... printf(lcd_putc,"X: %U ", x);
|
|
|
926 |
*
|
|
|
927 |
021F: MOVF 0D,W
|
|
|
928 |
0220: MOVF 17,W
|
|
|
929 |
0221: MOVWF 19
|
|
|
930 |
0222: MOVLW 64
|
|
|
931 |
0223: MOVWF 1A
|
|
|
932 |
0224: CALL 20A
|
|
|
933 |
0225: MOVF 0C,W
|
|
|
934 |
0226: MOVWF 17
|
|
|
935 |
0227: MOVF 0D,W
|
|
|
936 |
0228: MOVLW 30
|
|
|
937 |
0229: BTFSS 03.2
|
|
|
938 |
022A: GOTO 232
|
|
|
939 |
022B: BTFSC 18.0
|
|
|
940 |
022C: BSF 18.3
|
|
|
941 |
022D: BTFSC 18.3
|
|
|
942 |
022E: GOTO 238
|
|
|
943 |
022F: BTFSC 18.4
|
|
|
944 |
0230: MOVLW 20
|
|
|
945 |
0231: GOTO 234
|
|
|
946 |
0232: BCF 18.3
|
|
|
947 |
0233: BCF 18.4
|
|
|
948 |
0234: ADDWF 0D,F
|
|
|
949 |
0235: MOVF 0D,W
|
|
|
950 |
0236: MOVWF 19
|
|
|
951 |
0237: CALL 1D2
|
|
|
952 |
0238: MOVF 17,W
|
|
|
953 |
0239: MOVWF 19
|
|
|
954 |
023A: MOVLW 0A
|
|
|
955 |
023B: MOVWF 1A
|
|
|
956 |
023C: CALL 20A
|
|
|
957 |
023D: MOVF 0C,W
|
|
|
958 |
023E: MOVWF 17
|
|
|
959 |
023F: MOVF 0D,W
|
|
|
960 |
0240: MOVLW 30
|
|
|
961 |
0241: BTFSS 03.2
|
|
|
962 |
0242: GOTO 247
|
|
|
963 |
0243: BTFSC 18.3
|
|
|
964 |
0244: GOTO 24B
|
|
|
965 |
0245: BTFSC 18.4
|
|
|
966 |
0246: MOVLW 20
|
|
|
967 |
0247: ADDWF 0D,F
|
|
|
968 |
0248: MOVF 0D,W
|
|
|
969 |
0249: MOVWF 19
|
|
|
970 |
024A: CALL 1D2
|
|
|
971 |
024B: MOVLW 30
|
|
|
972 |
024C: ADDWF 17,F
|
|
|
973 |
024D: MOVF 17,W
|
|
|
974 |
024E: MOVWF 19
|
|
|
975 |
024F: CALL 1D2
|
|
|
976 |
0250: RETLW 00
|
|
|
977 |
*
|
|
|
978 |
02A2: MOVLW 58
|
|
|
979 |
02A3: MOVWF 19
|
|
|
980 |
02A4: CALL 1D2
|
|
|
981 |
02A5: MOVLW 3A
|
|
|
982 |
02A6: MOVWF 19
|
|
|
983 |
02A7: CALL 1D2
|
|
|
984 |
02A8: MOVLW 20
|
|
|
985 |
02A9: MOVWF 19
|
|
|
986 |
02AA: CALL 1D2
|
|
|
987 |
02AB: MOVF 0F,W
|
|
|
988 |
02AC: MOVWF 17
|
|
|
989 |
02AD: MOVLW 18
|
|
|
990 |
02AE: MOVWF 18
|
|
|
991 |
02AF: CALL 21F
|
|
|
992 |
02B0: MOVLW 06
|
|
|
993 |
02B1: MOVWF 17
|
|
|
994 |
02B2: MOVLW 20
|
|
|
995 |
02B3: MOVWF 19
|
|
|
996 |
02B4: CALL 1D2
|
|
|
997 |
02B5: DECFSZ 17,F
|
|
|
998 |
02B6: GOTO 2B2
|
|
|
999 |
.................... lcd_gotoxy(1,2);
|
|
|
1000 |
02B7: MOVLW 01
|
|
|
1001 |
02B8: MOVWF 1A
|
|
|
1002 |
02B9: MOVLW 02
|
|
|
1003 |
02BA: MOVWF 1B
|
|
|
1004 |
02BB: CALL 1C1
|
|
|
1005 |
.................... printf(lcd_putc,"Y: %U ", y);
|
|
|
1006 |
02BC: MOVLW 59
|
|
|
1007 |
02BD: MOVWF 19
|
|
|
1008 |
02BE: CALL 1D2
|
|
|
1009 |
02BF: MOVLW 3A
|
|
|
1010 |
02C0: MOVWF 19
|
|
|
1011 |
02C1: CALL 1D2
|
|
|
1012 |
02C2: MOVLW 20
|
|
|
1013 |
02C3: MOVWF 19
|
|
|
1014 |
02C4: CALL 1D2
|
|
|
1015 |
02C5: MOVF 10,W
|
|
|
1016 |
02C6: MOVWF 17
|
|
|
1017 |
02C7: MOVLW 18
|
|
|
1018 |
02C8: MOVWF 18
|
|
|
1019 |
02C9: CALL 21F
|
|
|
1020 |
02CA: MOVLW 06
|
|
|
1021 |
02CB: MOVWF 17
|
|
|
1022 |
02CC: MOVLW 20
|
|
|
1023 |
02CD: MOVWF 19
|
|
|
1024 |
02CE: CALL 1D2
|
|
|
1025 |
02CF: DECFSZ 17,F
|
|
|
1026 |
02D0: GOTO 2CC
|
|
|
1027 |
.................... }
|
|
|
1028 |
02D1: GOTO 256
|
|
|
1029 |
.................... }
|
|
|
1030 |
....................
|
|
|
1031 |
02D2: SLEEP
|
|
|
1032 |
....................
|
|
|
1033 |
....................
|