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