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: 617 (60%)
|
|
|
6 |
Largest free fragment is 407
|
|
|
7 |
RAM used: 9 (13%) at main() level
|
|
|
8 |
25 (37%) worst case
|
|
|
9 |
Stack: 5 locations
|
|
|
10 |
|
|
|
11 |
*
|
|
|
12 |
0000: MOVLW 00
|
|
|
13 |
0001: MOVWF 0A
|
|
|
14 |
0002: GOTO 15F
|
|
|
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 1C
|
|
|
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 23
|
|
|
158 |
002D: RLF 22,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 23,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 20,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 21,F
|
|
|
202 |
.................... lcd_send_nibble(n); // posli horni pulku bajtu
|
|
|
203 |
004A: MOVF 21,W
|
|
|
204 |
004B: MOVWF 22
|
|
|
205 |
004C: CALL 02A
|
|
|
206 |
.................... swap(n);
|
|
|
207 |
004D: SWAPF 21,F
|
|
|
208 |
.................... lcd_send_nibble(n); // posli spodni pulku bajtu
|
|
|
209 |
004E: MOVF 21,W
|
|
|
210 |
004F: MOVWF 22
|
|
|
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 1C
|
|
|
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 19
|
|
|
254 |
0066: MOVF 19,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 1C
|
|
|
262 |
006C: CALL 015
|
|
|
263 |
.................... lcd_send_nibble(3); // rezim 8 bitu
|
|
|
264 |
006D: MOVLW 03
|
|
|
265 |
006E: MOVWF 22
|
|
|
266 |
006F: CALL 02A
|
|
|
267 |
.................... }
|
|
|
268 |
0070: INCF 19,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 22
|
|
|
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 19
|
|
|
288 |
007E: MOVF 19,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 19,W
|
|
|
295 |
0083: CALL 004
|
|
|
296 |
0084: MOVWF 1A
|
|
|
297 |
0085: CLRF 20
|
|
|
298 |
0086: MOVF 1A,W
|
|
|
299 |
0087: MOVWF 21
|
|
|
300 |
0088: CALL 040
|
|
|
301 |
.................... delay_ms(2);
|
|
|
302 |
0089: MOVLW 02
|
|
|
303 |
008A: MOVWF 1C
|
|
|
304 |
008B: CALL 015
|
|
|
305 |
.................... }
|
|
|
306 |
008C: INCF 19,F
|
|
|
307 |
008D: GOTO 07E
|
|
|
308 |
008E: GOTO 163 (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 1C,W
|
|
|
324 |
0091: MOVWF 1E
|
|
|
325 |
.................... if(y==2)
|
|
|
326 |
0092: MOVF 1D,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 1E,F
|
|
|
333 |
....................
|
|
|
334 |
.................... lcd_send_byte(0,0x80|Adr);
|
|
|
335 |
0098: MOVF 1E,W
|
|
|
336 |
0099: IORLW 80
|
|
|
337 |
009A: MOVWF 1F
|
|
|
338 |
009B: CLRF 20
|
|
|
339 |
009C: MOVF 1F,W
|
|
|
340 |
009D: MOVWF 21
|
|
|
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 1B,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 20
|
|
|
374 |
00B4: MOVLW 01
|
|
|
375 |
00B5: MOVWF 21
|
|
|
376 |
00B6: CALL 040
|
|
|
377 |
.................... delay_ms(2);
|
|
|
378 |
00B7: MOVLW 02
|
|
|
379 |
00B8: MOVWF 1C
|
|
|
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 1C
|
|
|
386 |
00BD: MOVLW 02
|
|
|
387 |
00BE: MOVWF 1D
|
|
|
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 1C
|
|
|
393 |
00C3: MOVWF 1D
|
|
|
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 20
|
|
|
398 |
00C7: MOVLW 10
|
|
|
399 |
00C8: MOVWF 21
|
|
|
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 1B,W
|
|
|
404 |
00CC: SUBLW 1F
|
|
|
405 |
00CD: BTFSS 03.0
|
|
|
406 |
00CE: GOTO 0D1
|
|
|
407 |
00CF: MOVLW 07
|
|
|
408 |
00D0: ANDWF 1B,F
|
|
|
409 |
.................... lcd_send_byte(1,c); break; // zapis znak
|
|
|
410 |
00D1: MOVLW 01
|
|
|
411 |
00D2: MOVWF 20
|
|
|
412 |
00D3: MOVF 1B,W
|
|
|
413 |
00D4: MOVWF 21
|
|
|
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(int8* data)
|
|
|
542 |
.................... {
|
|
|
543 |
.................... int8 i;
|
|
|
544 |
.................... int8 d;
|
|
|
545 |
....................
|
|
|
546 |
.................... d=0;
|
|
|
547 |
00D8: CLRF 1B
|
|
|
548 |
....................
|
|
|
549 |
.................... // Cekam na dlouhou nulu
|
|
|
550 |
.................... for (i=8; i>0; i--)
|
|
|
551 |
00D9: MOVLW 08
|
|
|
552 |
00DA: MOVWF 1A
|
|
|
553 |
00DB: MOVF 1A,F
|
|
|
554 |
00DC: BTFSC 03.2
|
|
|
555 |
00DD: GOTO 0EC
|
|
|
556 |
.................... {
|
|
|
557 |
.................... if (input(PRIJIMAC)) i=8;
|
|
|
558 |
00DE: BSF 03.5
|
|
|
559 |
00DF: BSF 05.3
|
|
|
560 |
00E0: BCF 03.5
|
|
|
561 |
00E1: BTFSS 05.3
|
|
|
562 |
00E2: GOTO 0E5
|
|
|
563 |
00E3: MOVLW 08
|
|
|
564 |
00E4: MOVWF 1A
|
|
|
565 |
.................... delay_us(IMPULS/2);
|
|
|
566 |
00E5: MOVLW 29
|
|
|
567 |
00E6: MOVWF 0C
|
|
|
568 |
00E7: DECFSZ 0C,F
|
|
|
569 |
00E8: GOTO 0E7
|
|
|
570 |
00E9: NOP
|
|
|
571 |
.................... }
|
|
|
572 |
00EA: DECF 1A,F
|
|
|
573 |
00EB: GOTO 0DB
|
|
|
574 |
....................
|
|
|
575 |
.................... // Cekam na jednicku (start ramce)
|
|
|
576 |
.................... for (; !input(PRIJIMAC); )
|
|
|
577 |
00EC: BSF 03.5
|
|
|
578 |
00ED: BSF 05.3
|
|
|
579 |
00EE: BCF 03.5
|
|
|
580 |
00EF: BTFSC 05.3
|
|
|
581 |
00F0: GOTO 0F7
|
|
|
582 |
.................... {
|
|
|
583 |
.................... delay_us(IMPULS/2);
|
|
|
584 |
00F1: MOVLW 29
|
|
|
585 |
00F2: MOVWF 0C
|
|
|
586 |
00F3: DECFSZ 0C,F
|
|
|
587 |
00F4: GOTO 0F3
|
|
|
588 |
00F5: NOP
|
|
|
589 |
.................... }
|
|
|
590 |
00F6: GOTO 0EC
|
|
|
591 |
....................
|
|
|
592 |
.................... delay_us(IMPULS/2);
|
|
|
593 |
00F7: MOVLW 29
|
|
|
594 |
00F8: MOVWF 0C
|
|
|
595 |
00F9: DECFSZ 0C,F
|
|
|
596 |
00FA: GOTO 0F9
|
|
|
597 |
00FB: NOP
|
|
|
598 |
....................
|
|
|
599 |
.................... // Prenasim bity
|
|
|
600 |
.................... for (i=0; i<4; i++)
|
|
|
601 |
00FC: CLRF 1A
|
|
|
602 |
00FD: MOVF 1A,W
|
|
|
603 |
00FE: SUBLW 03
|
|
|
604 |
00FF: BTFSS 03.0
|
|
|
605 |
0100: GOTO 111
|
|
|
606 |
.................... {
|
|
|
607 |
.................... delay_us(2*IMPULS);
|
|
|
608 |
0101: MOVLW A6
|
|
|
609 |
0102: MOVWF 0C
|
|
|
610 |
0103: DECFSZ 0C,F
|
|
|
611 |
0104: GOTO 103
|
|
|
612 |
0105: NOP
|
|
|
613 |
.................... d >>= 1;
|
|
|
614 |
0106: BCF 03.0
|
|
|
615 |
0107: RRF 1B,F
|
|
|
616 |
.................... if (!input(PRIJIMAC)) d +=8;
|
|
|
617 |
0108: BSF 03.5
|
|
|
618 |
0109: BSF 05.3
|
|
|
619 |
010A: BCF 03.5
|
|
|
620 |
010B: BTFSC 05.3
|
|
|
621 |
010C: GOTO 10F
|
|
|
622 |
010D: MOVLW 08
|
|
|
623 |
010E: ADDWF 1B,F
|
|
|
624 |
.................... }
|
|
|
625 |
010F: INCF 1A,F
|
|
|
626 |
0110: GOTO 0FD
|
|
|
627 |
.................... *data = d;
|
|
|
628 |
0111: MOVF 19,W
|
|
|
629 |
0112: MOVWF 04
|
|
|
630 |
0113: MOVF 1B,W
|
|
|
631 |
0114: MOVWF 00
|
|
|
632 |
.................... return TRUE;
|
|
|
633 |
0115: MOVLW 01
|
|
|
634 |
0116: MOVWF 0D
|
|
|
635 |
0117: RETLW 00
|
|
|
636 |
.................... }
|
|
|
637 |
....................
|
|
|
638 |
.................... int8 read_nibble2(int8* value)
|
|
|
639 |
.................... {
|
|
|
640 |
.................... int8 n; // citac
|
|
|
641 |
.................... int8 bit; // pomocna promenna
|
|
|
642 |
....................
|
|
|
643 |
.................... *value=0;
|
|
|
644 |
.................... for (n=1; n<=4; n++) // prijmi 4 bity
|
|
|
645 |
.................... {
|
|
|
646 |
.................... *value >>= 1; // posun jiz prectene do leva
|
|
|
647 |
.................... if (0==prijmout(&bit)) return(false); // prijmi bit; pri chybe cteni vrat chybu
|
|
|
648 |
.................... *value |= bit << 3; // pridej bit do nibblu
|
|
|
649 |
.................... };
|
|
|
650 |
.................... return(true); // vrat 1, jako ,ze je vse O.K.
|
|
|
651 |
.................... }
|
|
|
652 |
....................
|
|
|
653 |
....................
|
|
|
654 |
.................... int8 bit,x,y;
|
|
|
655 |
.................... int8 xc,yc; // pocitadla aktualizace x a y
|
|
|
656 |
....................
|
|
|
657 |
.................... void main()
|
|
|
658 |
.................... {
|
|
|
659 |
*
|
|
|
660 |
015F: CLRF 04
|
|
|
661 |
0160: MOVLW 1F
|
|
|
662 |
0161: ANDWF 03,F
|
|
|
663 |
.................... lcd_init(); // zinicializuj LCD display
|
|
|
664 |
0162: GOTO 056
|
|
|
665 |
.................... delay_ms(5);
|
|
|
666 |
0163: MOVLW 05
|
|
|
667 |
0164: MOVWF 1C
|
|
|
668 |
0165: CALL 015
|
|
|
669 |
.................... printf(lcd_putc,"Ahoj...");
|
|
|
670 |
*
|
|
|
671 |
000C: BCF 0A.0
|
|
|
672 |
000D: BCF 0A.1
|
|
|
673 |
000E: BCF 0A.2
|
|
|
674 |
000F: ADDWF 02,F
|
|
|
675 |
0010: RETLW 41
|
|
|
676 |
0011: RETLW 68
|
|
|
677 |
0012: RETLW 6F
|
|
|
678 |
0013: RETLW 6A
|
|
|
679 |
0014: RETLW 00
|
|
|
680 |
*
|
|
|
681 |
0166: CLRF 19
|
|
|
682 |
0167: MOVF 19,W
|
|
|
683 |
0168: CALL 00C
|
|
|
684 |
0169: INCF 19,F
|
|
|
685 |
016A: MOVWF 1B
|
|
|
686 |
016B: CALL 0A0
|
|
|
687 |
016C: MOVLW 04
|
|
|
688 |
016D: SUBWF 19,W
|
|
|
689 |
016E: BTFSS 03.2
|
|
|
690 |
016F: GOTO 167
|
|
|
691 |
0170: MOVLW 03
|
|
|
692 |
0171: MOVWF 1A
|
|
|
693 |
0172: MOVLW 2E
|
|
|
694 |
0173: MOVWF 1B
|
|
|
695 |
0174: CALL 0A0
|
|
|
696 |
0175: DECFSZ 1A,F
|
|
|
697 |
0176: GOTO 172
|
|
|
698 |
.................... delay_ms(1000);
|
|
|
699 |
0177: MOVLW 04
|
|
|
700 |
0178: MOVWF 19
|
|
|
701 |
0179: MOVLW FA
|
|
|
702 |
017A: MOVWF 1C
|
|
|
703 |
017B: CALL 015
|
|
|
704 |
017C: DECFSZ 19,F
|
|
|
705 |
017D: GOTO 179
|
|
|
706 |
....................
|
|
|
707 |
.................... //while(TRUE)
|
|
|
708 |
.................... //{
|
|
|
709 |
.................... // read_nibble(&x);
|
|
|
710 |
.................... // lcd_gotoxy(1,1); // vytiskni X a Y
|
|
|
711 |
.................... // printf(lcd_putc,"O:%d ",x);
|
|
|
712 |
.................... //}
|
|
|
713 |
....................
|
|
|
714 |
.................... x = 0;
|
|
|
715 |
017E: CLRF 0F
|
|
|
716 |
.................... y = 0;
|
|
|
717 |
017F: CLRF 10
|
|
|
718 |
.................... xc=0;
|
|
|
719 |
0180: CLRF 11
|
|
|
720 |
.................... yc=0;
|
|
|
721 |
0181: CLRF 12
|
|
|
722 |
....................
|
|
|
723 |
.................... while (true)
|
|
|
724 |
.................... {
|
|
|
725 |
.................... int8 osa, hodnota, kontrola;
|
|
|
726 |
.................... int counter; // pocitadlo 1 a 0 v detektoru
|
|
|
727 |
.................... int e1,e2; // pocitadla chyb - ladici
|
|
|
728 |
....................
|
|
|
729 |
.................... e1=0;
|
|
|
730 |
0182: CLRF 17
|
|
|
731 |
.................... e2=0;
|
|
|
732 |
0183: CLRF 18
|
|
|
733 |
....................
|
|
|
734 |
.................... counter=4;
|
|
|
735 |
0184: MOVLW 04
|
|
|
736 |
0185: MOVWF 16
|
|
|
737 |
....................
|
|
|
738 |
.................... decoder:
|
|
|
739 |
....................
|
|
|
740 |
.................... counter=0; // vynuluj citac
|
|
|
741 |
0186: CLRF 16
|
|
|
742 |
.................... // do // vyhledej synchronizacni jednicky
|
|
|
743 |
.................... // {
|
|
|
744 |
.................... // if (!prijmout(&bit)) goto decoder; // prijmi bit; pri chybe zacni znovu
|
|
|
745 |
.................... // if (1==bit) counter++; else goto decoder; // kdyz je bit 1, tak zvys citac; jinak zacni znovu
|
|
|
746 |
.................... // } while(counter<4); // pockej na 4 jednicky
|
|
|
747 |
.................... if (!read_nibble(&osa)) goto decoder;
|
|
|
748 |
0187: MOVLW 13
|
|
|
749 |
0188: MOVWF 19
|
|
|
750 |
0189: CALL 0D8
|
|
|
751 |
018A: MOVF 0D,F
|
|
|
752 |
018B: BTFSS 03.2
|
|
|
753 |
018C: GOTO 18E
|
|
|
754 |
018D: GOTO 186
|
|
|
755 |
.................... if (osa!=15) {e1++; goto decoder;};
|
|
|
756 |
018E: MOVF 13,W
|
|
|
757 |
018F: SUBLW 0F
|
|
|
758 |
0190: BTFSC 03.2
|
|
|
759 |
0191: GOTO 194
|
|
|
760 |
0192: INCF 17,F
|
|
|
761 |
0193: GOTO 186
|
|
|
762 |
.................... if (!read_nibble(&osa)) goto decoder; // nacti identifikator osy
|
|
|
763 |
0194: MOVLW 13
|
|
|
764 |
0195: MOVWF 19
|
|
|
765 |
0196: CALL 0D8
|
|
|
766 |
0197: MOVF 0D,F
|
|
|
767 |
0198: BTFSS 03.2
|
|
|
768 |
0199: GOTO 19B
|
|
|
769 |
019A: GOTO 186
|
|
|
770 |
....................
|
|
|
771 |
.................... if (!read_nibble(&hodnota)) goto decoder; // nacti 1. nibble; pri chybe zacni znovu
|
|
|
772 |
019B: MOVLW 14
|
|
|
773 |
019C: MOVWF 19
|
|
|
774 |
019D: CALL 0D8
|
|
|
775 |
019E: MOVF 0D,F
|
|
|
776 |
019F: BTFSS 03.2
|
|
|
777 |
01A0: GOTO 1A2
|
|
|
778 |
01A1: GOTO 186
|
|
|
779 |
.................... if (!read_nibble(&kontrola)) goto decoder; // nacti 2. nibble; pri chybe zacni znovu
|
|
|
780 |
01A2: MOVLW 15
|
|
|
781 |
01A3: MOVWF 19
|
|
|
782 |
01A4: CALL 0D8
|
|
|
783 |
01A5: MOVF 0D,F
|
|
|
784 |
01A6: BTFSS 03.2
|
|
|
785 |
01A7: GOTO 1A9
|
|
|
786 |
01A8: GOTO 186
|
|
|
787 |
.................... if (hodnota != kontrola) {e2++; goto decoder;} // zacni znovu, pokud jsou ruzne nibble
|
|
|
788 |
01A9: MOVF 15,W
|
|
|
789 |
01AA: SUBWF 14,W
|
|
|
790 |
01AB: BTFSC 03.2
|
|
|
791 |
01AC: GOTO 1AF
|
|
|
792 |
01AD: INCF 18,F
|
|
|
793 |
01AE: GOTO 186
|
|
|
794 |
....................
|
|
|
795 |
....................
|
|
|
796 |
.................... switch (osa) // rozeskoc se podle adresy osy
|
|
|
797 |
01AF: MOVLW 01
|
|
|
798 |
01B0: SUBWF 13,W
|
|
|
799 |
01B1: ADDLW FD
|
|
|
800 |
01B2: BTFSC 03.0
|
|
|
801 |
01B3: GOTO 1C0
|
|
|
802 |
01B4: ADDLW 03
|
|
|
803 |
01B5: GOTO 262
|
|
|
804 |
.................... {
|
|
|
805 |
.................... case OSA_X:
|
|
|
806 |
.................... {
|
|
|
807 |
.................... x=hodnota;
|
|
|
808 |
01B6: MOVF 14,W
|
|
|
809 |
01B7: MOVWF 0F
|
|
|
810 |
.................... xc++;
|
|
|
811 |
01B8: INCF 11,F
|
|
|
812 |
.................... break;
|
|
|
813 |
01B9: GOTO 1C0
|
|
|
814 |
.................... };
|
|
|
815 |
.................... case OSA_Y:
|
|
|
816 |
.................... {
|
|
|
817 |
.................... y=hodnota;
|
|
|
818 |
01BA: MOVF 14,W
|
|
|
819 |
01BB: MOVWF 10
|
|
|
820 |
.................... yc++;
|
|
|
821 |
01BC: INCF 12,F
|
|
|
822 |
.................... break;
|
|
|
823 |
01BD: GOTO 1C0
|
|
|
824 |
.................... };
|
|
|
825 |
.................... case TLs:
|
|
|
826 |
.................... {
|
|
|
827 |
.................... e1++;
|
|
|
828 |
01BE: INCF 17,F
|
|
|
829 |
.................... break;
|
|
|
830 |
01BF: GOTO 1C0
|
|
|
831 |
.................... };
|
|
|
832 |
.................... };
|
|
|
833 |
*
|
|
|
834 |
0262: BCF 0A.0
|
|
|
835 |
0263: BSF 0A.1
|
|
|
836 |
0264: BCF 0A.2
|
|
|
837 |
0265: ADDWF 02,F
|
|
|
838 |
0266: GOTO 1B6
|
|
|
839 |
0267: GOTO 1BA
|
|
|
840 |
0268: GOTO 1BE
|
|
|
841 |
....................
|
|
|
842 |
.................... // ladici vypisy
|
|
|
843 |
.................... lcd_gotoxy(1,1); // vytiskni X a Y
|
|
|
844 |
*
|
|
|
845 |
01C0: MOVLW 01
|
|
|
846 |
01C1: MOVWF 1C
|
|
|
847 |
01C2: MOVWF 1D
|
|
|
848 |
01C3: CALL 08F
|
|
|
849 |
.................... printf(lcd_putc,"X: %U %u %U ", x, xc, e1);
|
|
|
850 |
*
|
|
|
851 |
012D: MOVF 0D,W
|
|
|
852 |
012E: MOVF 19,W
|
|
|
853 |
012F: MOVWF 1B
|
|
|
854 |
0130: MOVLW 64
|
|
|
855 |
0131: MOVWF 1C
|
|
|
856 |
0132: CALL 118
|
|
|
857 |
0133: MOVF 0C,W
|
|
|
858 |
0134: MOVWF 19
|
|
|
859 |
0135: MOVF 0D,W
|
|
|
860 |
0136: MOVLW 30
|
|
|
861 |
0137: BTFSS 03.2
|
|
|
862 |
0138: GOTO 140
|
|
|
863 |
0139: BTFSC 1A.0
|
|
|
864 |
013A: BSF 1A.3
|
|
|
865 |
013B: BTFSC 1A.3
|
|
|
866 |
013C: GOTO 146
|
|
|
867 |
013D: BTFSC 1A.4
|
|
|
868 |
013E: MOVLW 20
|
|
|
869 |
013F: GOTO 142
|
|
|
870 |
0140: BCF 1A.3
|
|
|
871 |
0141: BCF 1A.4
|
|
|
872 |
0142: ADDWF 0D,F
|
|
|
873 |
0143: MOVF 0D,W
|
|
|
874 |
0144: MOVWF 1B
|
|
|
875 |
0145: CALL 0A0
|
|
|
876 |
0146: MOVF 19,W
|
|
|
877 |
0147: MOVWF 1B
|
|
|
878 |
0148: MOVLW 0A
|
|
|
879 |
0149: MOVWF 1C
|
|
|
880 |
014A: CALL 118
|
|
|
881 |
014B: MOVF 0C,W
|
|
|
882 |
014C: MOVWF 19
|
|
|
883 |
014D: MOVF 0D,W
|
|
|
884 |
014E: MOVLW 30
|
|
|
885 |
014F: BTFSS 03.2
|
|
|
886 |
0150: GOTO 155
|
|
|
887 |
0151: BTFSC 1A.3
|
|
|
888 |
0152: GOTO 159
|
|
|
889 |
0153: BTFSC 1A.4
|
|
|
890 |
0154: MOVLW 20
|
|
|
891 |
0155: ADDWF 0D,F
|
|
|
892 |
0156: MOVF 0D,W
|
|
|
893 |
0157: MOVWF 1B
|
|
|
894 |
0158: CALL 0A0
|
|
|
895 |
0159: MOVLW 30
|
|
|
896 |
015A: ADDWF 19,F
|
|
|
897 |
015B: MOVF 19,W
|
|
|
898 |
015C: MOVWF 1B
|
|
|
899 |
015D: CALL 0A0
|
|
|
900 |
015E: RETLW 00
|
|
|
901 |
*
|
|
|
902 |
01C4: MOVLW 58
|
|
|
903 |
01C5: MOVWF 1B
|
|
|
904 |
01C6: CALL 0A0
|
|
|
905 |
01C7: MOVLW 3A
|
|
|
906 |
01C8: MOVWF 1B
|
|
|
907 |
01C9: CALL 0A0
|
|
|
908 |
01CA: MOVLW 20
|
|
|
909 |
01CB: MOVWF 1B
|
|
|
910 |
01CC: CALL 0A0
|
|
|
911 |
01CD: MOVF 0F,W
|
|
|
912 |
01CE: MOVWF 19
|
|
|
913 |
01CF: MOVLW 18
|
|
|
914 |
01D0: MOVWF 1A
|
|
|
915 |
01D1: CALL 12D
|
|
|
916 |
01D2: MOVLW 20
|
|
|
917 |
01D3: MOVWF 1B
|
|
|
918 |
01D4: CALL 0A0
|
|
|
919 |
01D5: MOVF 11,W
|
|
|
920 |
01D6: MOVWF 19
|
|
|
921 |
01D7: MOVLW 18
|
|
|
922 |
01D8: MOVWF 1A
|
|
|
923 |
01D9: CALL 12D
|
|
|
924 |
01DA: MOVLW 20
|
|
|
925 |
01DB: MOVWF 1B
|
|
|
926 |
01DC: CALL 0A0
|
|
|
927 |
01DD: MOVF 17,W
|
|
|
928 |
01DE: MOVWF 19
|
|
|
929 |
01DF: MOVLW 18
|
|
|
930 |
01E0: MOVWF 1A
|
|
|
931 |
01E1: CALL 12D
|
|
|
932 |
01E2: MOVLW 05
|
|
|
933 |
01E3: MOVWF 19
|
|
|
934 |
01E4: MOVLW 20
|
|
|
935 |
01E5: MOVWF 1B
|
|
|
936 |
01E6: CALL 0A0
|
|
|
937 |
01E7: DECFSZ 19,F
|
|
|
938 |
01E8: GOTO 1E4
|
|
|
939 |
.................... lcd_gotoxy(1,2);
|
|
|
940 |
01E9: MOVLW 01
|
|
|
941 |
01EA: MOVWF 1C
|
|
|
942 |
01EB: MOVLW 02
|
|
|
943 |
01EC: MOVWF 1D
|
|
|
944 |
01ED: CALL 08F
|
|
|
945 |
.................... printf(lcd_putc,"Y: %U %U %U ", y, yc, e2);
|
|
|
946 |
01EE: MOVLW 59
|
|
|
947 |
01EF: MOVWF 1B
|
|
|
948 |
01F0: CALL 0A0
|
|
|
949 |
01F1: MOVLW 3A
|
|
|
950 |
01F2: MOVWF 1B
|
|
|
951 |
01F3: CALL 0A0
|
|
|
952 |
01F4: MOVLW 20
|
|
|
953 |
01F5: MOVWF 1B
|
|
|
954 |
01F6: CALL 0A0
|
|
|
955 |
01F7: MOVF 10,W
|
|
|
956 |
01F8: MOVWF 19
|
|
|
957 |
01F9: MOVLW 18
|
|
|
958 |
01FA: MOVWF 1A
|
|
|
959 |
01FB: CALL 12D
|
|
|
960 |
01FC: MOVLW 20
|
|
|
961 |
01FD: MOVWF 1B
|
|
|
962 |
01FE: CALL 0A0
|
|
|
963 |
01FF: MOVF 12,W
|
|
|
964 |
0200: MOVWF 19
|
|
|
965 |
0201: MOVLW 18
|
|
|
966 |
0202: MOVWF 1A
|
|
|
967 |
0203: CALL 12D
|
|
|
968 |
0204: MOVLW 20
|
|
|
969 |
0205: MOVWF 1B
|
|
|
970 |
0206: CALL 0A0
|
|
|
971 |
0207: MOVF 18,W
|
|
|
972 |
0208: MOVWF 19
|
|
|
973 |
0209: MOVLW 18
|
|
|
974 |
020A: MOVWF 1A
|
|
|
975 |
020B: CALL 12D
|
|
|
976 |
020C: MOVLW 05
|
|
|
977 |
020D: MOVWF 19
|
|
|
978 |
020E: MOVLW 20
|
|
|
979 |
020F: MOVWF 1B
|
|
|
980 |
0210: CALL 0A0
|
|
|
981 |
0211: DECFSZ 19,F
|
|
|
982 |
0212: GOTO 20E
|
|
|
983 |
....................
|
|
|
984 |
.................... // ovladani serv
|
|
|
985 |
.................... output_high(SERVO_X);
|
|
|
986 |
0213: BSF 03.5
|
|
|
987 |
0214: BCF 05.0
|
|
|
988 |
0215: BCF 03.5
|
|
|
989 |
0216: BSF 05.0
|
|
|
990 |
.................... delay_ms(1);
|
|
|
991 |
0217: MOVLW 01
|
|
|
992 |
0218: MOVWF 1C
|
|
|
993 |
0219: CALL 015
|
|
|
994 |
.................... for (osa=x; osa--; osa>0)
|
|
|
995 |
021A: MOVF 0F,W
|
|
|
996 |
021B: MOVWF 13
|
|
|
997 |
021C: MOVF 13,W
|
|
|
998 |
021D: DECF 13,F
|
|
|
999 |
021E: XORLW 00
|
|
|
1000 |
021F: BTFSC 03.2
|
|
|
1001 |
0220: GOTO 22B
|
|
|
1002 |
.................... delay_us(65);
|
|
|
1003 |
0221: MOVLW 15
|
|
|
1004 |
0222: MOVWF 0C
|
|
|
1005 |
0223: DECFSZ 0C,F
|
|
|
1006 |
0224: GOTO 223
|
|
|
1007 |
0225: NOP
|
|
|
1008 |
0226: MOVF 13,F
|
|
|
1009 |
0227: BTFSS 03.2
|
|
|
1010 |
0228: GOTO 22A
|
|
|
1011 |
0229: MOVLW 00
|
|
|
1012 |
022A: GOTO 21C
|
|
|
1013 |
.................... output_low(SERVO_X);
|
|
|
1014 |
022B: BSF 03.5
|
|
|
1015 |
022C: BCF 05.0
|
|
|
1016 |
022D: BCF 03.5
|
|
|
1017 |
022E: BCF 05.0
|
|
|
1018 |
....................
|
|
|
1019 |
.................... output_high(SERVO_Y);
|
|
|
1020 |
022F: BSF 03.5
|
|
|
1021 |
0230: BCF 05.1
|
|
|
1022 |
0231: BCF 03.5
|
|
|
1023 |
0232: BSF 05.1
|
|
|
1024 |
.................... delay_ms(1);
|
|
|
1025 |
0233: MOVLW 01
|
|
|
1026 |
0234: MOVWF 1C
|
|
|
1027 |
0235: CALL 015
|
|
|
1028 |
.................... for (osa=y; osa--; osa>0)
|
|
|
1029 |
0236: MOVF 10,W
|
|
|
1030 |
0237: MOVWF 13
|
|
|
1031 |
0238: MOVF 13,W
|
|
|
1032 |
0239: DECF 13,F
|
|
|
1033 |
023A: XORLW 00
|
|
|
1034 |
023B: BTFSC 03.2
|
|
|
1035 |
023C: GOTO 247
|
|
|
1036 |
.................... delay_us(65);
|
|
|
1037 |
023D: MOVLW 15
|
|
|
1038 |
023E: MOVWF 0C
|
|
|
1039 |
023F: DECFSZ 0C,F
|
|
|
1040 |
0240: GOTO 23F
|
|
|
1041 |
0241: NOP
|
|
|
1042 |
0242: MOVF 13,F
|
|
|
1043 |
0243: BTFSS 03.2
|
|
|
1044 |
0244: GOTO 246
|
|
|
1045 |
0245: MOVLW 00
|
|
|
1046 |
0246: GOTO 238
|
|
|
1047 |
.................... output_low(SERVO_Y);
|
|
|
1048 |
0247: BSF 03.5
|
|
|
1049 |
0248: BCF 05.1
|
|
|
1050 |
0249: BCF 03.5
|
|
|
1051 |
024A: BCF 05.1
|
|
|
1052 |
....................
|
|
|
1053 |
.................... for (osa=30-x-y; osa--; osa>0)
|
|
|
1054 |
024B: MOVF 0F,W
|
|
|
1055 |
024C: SUBLW 1E
|
|
|
1056 |
024D: MOVWF 0D
|
|
|
1057 |
024E: MOVF 10,W
|
|
|
1058 |
024F: SUBWF 0D,W
|
|
|
1059 |
0250: MOVWF 13
|
|
|
1060 |
0251: MOVF 13,W
|
|
|
1061 |
0252: DECF 13,F
|
|
|
1062 |
0253: XORLW 00
|
|
|
1063 |
0254: BTFSC 03.2
|
|
|
1064 |
0255: GOTO 260
|
|
|
1065 |
.................... delay_us(65);
|
|
|
1066 |
0256: MOVLW 15
|
|
|
1067 |
0257: MOVWF 0C
|
|
|
1068 |
0258: DECFSZ 0C,F
|
|
|
1069 |
0259: GOTO 258
|
|
|
1070 |
025A: NOP
|
|
|
1071 |
025B: MOVF 13,F
|
|
|
1072 |
025C: BTFSS 03.2
|
|
|
1073 |
025D: GOTO 25F
|
|
|
1074 |
025E: MOVLW 00
|
|
|
1075 |
025F: GOTO 251
|
|
|
1076 |
....................
|
|
|
1077 |
.................... }
|
|
|
1078 |
0260: GOTO 182
|
|
|
1079 |
.................... }
|
|
|
1080 |
....................
|
|
|
1081 |
0261: SLEEP
|
|
|
1082 |
....................
|
|
|
1083 |
....................
|