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