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 |
24 (35%) 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 1B
|
|
|
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 22
|
|
|
161 |
002D: RLF 21,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 22,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 1F,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 20,F
|
|
|
205 |
.................... lcd_send_nibble(n); // posli horni pulku bajtu
|
|
|
206 |
004A: MOVF 20,W
|
|
|
207 |
004B: MOVWF 21
|
|
|
208 |
004C: CALL 02A
|
|
|
209 |
.................... swap(n);
|
|
|
210 |
004D: SWAPF 20,F
|
|
|
211 |
.................... lcd_send_nibble(n); // posli spodni pulku bajtu
|
|
|
212 |
004E: MOVF 20,W
|
|
|
213 |
004F: MOVWF 21
|
|
|
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 1B
|
|
|
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 18
|
|
|
257 |
0066: MOVF 18,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 1B
|
|
|
265 |
006C: CALL 015
|
|
|
266 |
.................... lcd_send_nibble(3); // rezim 8 bitu
|
|
|
267 |
006D: MOVLW 03
|
|
|
268 |
006E: MOVWF 21
|
|
|
269 |
006F: CALL 02A
|
|
|
270 |
.................... }
|
|
|
271 |
0070: INCF 18,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 21
|
|
|
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 18
|
|
|
291 |
007E: MOVF 18,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 18,W
|
|
|
298 |
0083: CALL 004
|
|
|
299 |
0084: MOVWF 19
|
|
|
300 |
0085: CLRF 1F
|
|
|
301 |
0086: MOVF 19,W
|
|
|
302 |
0087: MOVWF 20
|
|
|
303 |
0088: CALL 040
|
|
|
304 |
.................... delay_ms(2);
|
|
|
305 |
0089: MOVLW 02
|
|
|
306 |
008A: MOVWF 1B
|
|
|
307 |
008B: CALL 015
|
|
|
308 |
.................... }
|
|
|
309 |
008C: INCF 18,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 1B,W
|
|
|
327 |
0091: MOVWF 1D
|
|
|
328 |
.................... if(y==2)
|
|
|
329 |
0092: MOVF 1C,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 1D,F
|
|
|
336 |
....................
|
|
|
337 |
.................... lcd_send_byte(0,0x80|Adr);
|
|
|
338 |
0098: MOVF 1D,W
|
|
|
339 |
0099: IORLW 80
|
|
|
340 |
009A: MOVWF 1E
|
|
|
341 |
009B: CLRF 1F
|
|
|
342 |
009C: MOVF 1E,W
|
|
|
343 |
009D: MOVWF 20
|
|
|
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 1A,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 1F
|
|
|
377 |
00B4: MOVLW 01
|
|
|
378 |
00B5: MOVWF 20
|
|
|
379 |
00B6: CALL 040
|
|
|
380 |
.................... delay_ms(2);
|
|
|
381 |
00B7: MOVLW 02
|
|
|
382 |
00B8: MOVWF 1B
|
|
|
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 1B
|
|
|
389 |
00BD: MOVLW 02
|
|
|
390 |
00BE: MOVWF 1C
|
|
|
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 1B
|
|
|
396 |
00C3: MOVWF 1C
|
|
|
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 1F
|
|
|
401 |
00C7: MOVLW 10
|
|
|
402 |
00C8: MOVWF 20
|
|
|
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 1A,W
|
|
|
407 |
00CC: SUBLW 1F
|
|
|
408 |
00CD: BTFSS 03.0
|
|
|
409 |
00CE: GOTO 0D1
|
|
|
410 |
00CF: MOVLW 07
|
|
|
411 |
00D0: ANDWF 1A,F
|
|
|
412 |
.................... lcd_send_byte(1,c); break; // zapis znak
|
|
|
413 |
00D1: MOVLW 01
|
|
|
414 |
00D2: MOVWF 1F
|
|
|
415 |
00D3: MOVF 1A,W
|
|
|
416 |
00D4: MOVWF 20
|
|
|
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 1D,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 1E
|
|
|
545 |
00DD: MOVF 1E,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 1E
|
|
|
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 1E,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 1C,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 1E
|
|
|
599 |
0103: MOVF 1E,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 1D,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 1D,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 1F.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 1F,F
|
|
|
642 |
.................... #ELSE
|
|
|
643 |
.................... delay_us(20);
|
|
|
644 |
.................... #ENDIF
|
|
|
645 |
.................... }
|
|
|
646 |
0126: INCF 1E,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 kod chyby
|
|
|
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 1A
|
|
|
668 |
012C: MOVWF 1C
|
|
|
669 |
012D: MOVF 19,W
|
|
|
670 |
012E: MOVWF 1D
|
|
|
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 1A,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 19,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 1A
|
|
|
699 |
0143: MOVWF 1C
|
|
|
700 |
0144: MOVF 18,W
|
|
|
701 |
0145: MOVWF 1D
|
|
|
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 1A,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 1A
|
|
|
720 |
0154: MOVWF 1C
|
|
|
721 |
0155: MOVF 19,W
|
|
|
722 |
0156: MOVWF 1D
|
|
|
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 1A,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 1A
|
|
|
741 |
0165: MOVWF 1C
|
|
|
742 |
0166: MOVLW 1B
|
|
|
743 |
0167: MOVWF 1D
|
|
|
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 1A,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 |
.................... if (((*kanal+*data) & 0b1111) != suma) return 3; // chyba kontrolniho souctu
|
|
|
761 |
0175: MOVF 18,W
|
|
|
762 |
0176: MOVWF 04
|
|
|
763 |
0177: MOVF 00,W
|
|
|
764 |
0178: MOVWF 1C
|
|
|
765 |
0179: MOVF 19,W
|
|
|
766 |
017A: MOVWF 04
|
|
|
767 |
017B: MOVF 00,W
|
|
|
768 |
017C: ADDWF 1C,W
|
|
|
769 |
017D: ANDLW 0F
|
|
|
770 |
017E: SUBWF 1B,W
|
|
|
771 |
017F: BTFSC 03.2
|
|
|
772 |
0180: GOTO 184
|
|
|
773 |
0181: MOVLW 03
|
|
|
774 |
0182: MOVWF 0D
|
|
|
775 |
0183: GOTO 186
|
|
|
776 |
....................
|
|
|
777 |
.................... return 0;
|
|
|
778 |
0184: MOVLW 00
|
|
|
779 |
0185: MOVWF 0D
|
|
|
780 |
0186: GOTO 1FA (RETURN)
|
|
|
781 |
.................... }
|
|
|
782 |
....................
|
|
|
783 |
....................
|
|
|
784 |
....................
|
|
|
785 |
.................... int8 x,y;
|
|
|
786 |
.................... int8 xc,yc; // pocitadla aktualizace x a y
|
|
|
787 |
.................... int e1,e2,e3,e4; // pocitadla chyb - ladici
|
|
|
788 |
....................
|
|
|
789 |
.................... void main()
|
|
|
790 |
.................... {
|
|
|
791 |
*
|
|
|
792 |
01CE: CLRF 04
|
|
|
793 |
01CF: MOVLW 1F
|
|
|
794 |
01D0: ANDWF 03,F
|
|
|
795 |
.................... lcd_init(); // zinicializuj LCD display
|
|
|
796 |
01D1: GOTO 056
|
|
|
797 |
.................... delay_ms(5);
|
|
|
798 |
01D2: MOVLW 05
|
|
|
799 |
01D3: MOVWF 1B
|
|
|
800 |
01D4: CALL 015
|
|
|
801 |
.................... printf(lcd_putc,"Ahoj...");
|
|
|
802 |
*
|
|
|
803 |
000C: BCF 0A.0
|
|
|
804 |
000D: BCF 0A.1
|
|
|
805 |
000E: BCF 0A.2
|
|
|
806 |
000F: ADDWF 02,F
|
|
|
807 |
0010: RETLW 41
|
|
|
808 |
0011: RETLW 68
|
|
|
809 |
0012: RETLW 6F
|
|
|
810 |
0013: RETLW 6A
|
|
|
811 |
0014: RETLW 00
|
|
|
812 |
*
|
|
|
813 |
01D5: CLRF 18
|
|
|
814 |
01D6: MOVF 18,W
|
|
|
815 |
01D7: CALL 00C
|
|
|
816 |
01D8: INCF 18,F
|
|
|
817 |
01D9: MOVWF 1A
|
|
|
818 |
01DA: CALL 0A0
|
|
|
819 |
01DB: MOVLW 04
|
|
|
820 |
01DC: SUBWF 18,W
|
|
|
821 |
01DD: BTFSS 03.2
|
|
|
822 |
01DE: GOTO 1D6
|
|
|
823 |
01DF: MOVLW 03
|
|
|
824 |
01E0: MOVWF 19
|
|
|
825 |
01E1: MOVLW 2E
|
|
|
826 |
01E2: MOVWF 1A
|
|
|
827 |
01E3: CALL 0A0
|
|
|
828 |
01E4: DECFSZ 19,F
|
|
|
829 |
01E5: GOTO 1E1
|
|
|
830 |
.................... delay_ms(300);
|
|
|
831 |
01E6: MOVLW 02
|
|
|
832 |
01E7: MOVWF 18
|
|
|
833 |
01E8: MOVLW 96
|
|
|
834 |
01E9: MOVWF 1B
|
|
|
835 |
01EA: CALL 015
|
|
|
836 |
01EB: DECFSZ 18,F
|
|
|
837 |
01EC: GOTO 1E8
|
|
|
838 |
....................
|
|
|
839 |
.................... x = 0;
|
|
|
840 |
01ED: CLRF 0E
|
|
|
841 |
.................... y = 0;
|
|
|
842 |
01EE: CLRF 0F
|
|
|
843 |
.................... xc = 0;
|
|
|
844 |
01EF: CLRF 10
|
|
|
845 |
.................... yc = 0;
|
|
|
846 |
01F0: CLRF 11
|
|
|
847 |
.................... e1 = 0;
|
|
|
848 |
01F1: CLRF 12
|
|
|
849 |
.................... e2 = 0;
|
|
|
850 |
01F2: CLRF 13
|
|
|
851 |
.................... e3 = 0;
|
|
|
852 |
01F3: CLRF 14
|
|
|
853 |
.................... e4 = 0;
|
|
|
854 |
01F4: CLRF 15
|
|
|
855 |
....................
|
|
|
856 |
.................... while (true)
|
|
|
857 |
.................... {
|
|
|
858 |
.................... int8 kanal, data;
|
|
|
859 |
....................
|
|
|
860 |
.................... if (prijmi_ramec(&kanal,&data))
|
|
|
861 |
01F5: MOVLW 16
|
|
|
862 |
01F6: MOVWF 18
|
|
|
863 |
01F7: MOVLW 17
|
|
|
864 |
01F8: MOVWF 19
|
|
|
865 |
01F9: GOTO 12B
|
|
|
866 |
01FA: MOVF 0D,F
|
|
|
867 |
01FB: BTFSC 03.2
|
|
|
868 |
01FC: GOTO 1FF
|
|
|
869 |
.................... e1++;
|
|
|
870 |
01FD: INCF 12,F
|
|
|
871 |
.................... else
|
|
|
872 |
01FE: GOTO 2A6
|
|
|
873 |
.................... {
|
|
|
874 |
.................... switch (kanal) // rozeskoc se podle adresy osy
|
|
|
875 |
01FF: MOVLW 01
|
|
|
876 |
0200: SUBWF 16,W
|
|
|
877 |
0201: ADDLW FD
|
|
|
878 |
0202: BTFSC 03.0
|
|
|
879 |
0203: GOTO 210
|
|
|
880 |
0204: ADDLW 03
|
|
|
881 |
0205: GOTO 2A8
|
|
|
882 |
.................... {
|
|
|
883 |
.................... case OSA_X:
|
|
|
884 |
.................... {
|
|
|
885 |
.................... x=data;
|
|
|
886 |
0206: MOVF 17,W
|
|
|
887 |
0207: MOVWF 0E
|
|
|
888 |
.................... xc++;
|
|
|
889 |
0208: INCF 10,F
|
|
|
890 |
.................... break;
|
|
|
891 |
0209: GOTO 210
|
|
|
892 |
.................... };
|
|
|
893 |
.................... case OSA_Y:
|
|
|
894 |
.................... {
|
|
|
895 |
.................... y=data;
|
|
|
896 |
020A: MOVF 17,W
|
|
|
897 |
020B: MOVWF 0F
|
|
|
898 |
.................... yc++;
|
|
|
899 |
020C: INCF 11,F
|
|
|
900 |
.................... break;
|
|
|
901 |
020D: GOTO 210
|
|
|
902 |
.................... };
|
|
|
903 |
.................... case TLs:
|
|
|
904 |
.................... {
|
|
|
905 |
.................... e4++;
|
|
|
906 |
020E: INCF 15,F
|
|
|
907 |
.................... break;
|
|
|
908 |
020F: GOTO 210
|
|
|
909 |
.................... };
|
|
|
910 |
.................... };
|
|
|
911 |
*
|
|
|
912 |
02A8: BCF 0A.0
|
|
|
913 |
02A9: BSF 0A.1
|
|
|
914 |
02AA: BCF 0A.2
|
|
|
915 |
02AB: ADDWF 02,F
|
|
|
916 |
02AC: GOTO 206
|
|
|
917 |
02AD: GOTO 20A
|
|
|
918 |
02AE: GOTO 20E
|
|
|
919 |
....................
|
|
|
920 |
.................... // ladici vypisy
|
|
|
921 |
.................... lcd_gotoxy(1,1); // vytiskni X a Y
|
|
|
922 |
*
|
|
|
923 |
0210: MOVLW 01
|
|
|
924 |
0211: MOVWF 1B
|
|
|
925 |
0212: MOVWF 1C
|
|
|
926 |
0213: CALL 08F
|
|
|
927 |
.................... printf(lcd_putc,"X%2U %3U%3U%3U ", x, xc, e1, e2);
|
|
|
928 |
*
|
|
|
929 |
019C: MOVF 0D,W
|
|
|
930 |
019D: MOVF 18,W
|
|
|
931 |
019E: MOVWF 1A
|
|
|
932 |
019F: MOVLW 64
|
|
|
933 |
01A0: MOVWF 1B
|
|
|
934 |
01A1: CALL 187
|
|
|
935 |
01A2: MOVF 0C,W
|
|
|
936 |
01A3: MOVWF 18
|
|
|
937 |
01A4: MOVF 0D,W
|
|
|
938 |
01A5: MOVLW 30
|
|
|
939 |
01A6: BTFSS 03.2
|
|
|
940 |
01A7: GOTO 1AF
|
|
|
941 |
01A8: BTFSC 19.0
|
|
|
942 |
01A9: BSF 19.3
|
|
|
943 |
01AA: BTFSC 19.3
|
|
|
944 |
01AB: GOTO 1B5
|
|
|
945 |
01AC: BTFSC 19.4
|
|
|
946 |
01AD: MOVLW 20
|
|
|
947 |
01AE: GOTO 1B1
|
|
|
948 |
01AF: BCF 19.3
|
|
|
949 |
01B0: BCF 19.4
|
|
|
950 |
01B1: ADDWF 0D,F
|
|
|
951 |
01B2: MOVF 0D,W
|
|
|
952 |
01B3: MOVWF 1A
|
|
|
953 |
01B4: CALL 0A0
|
|
|
954 |
01B5: MOVF 18,W
|
|
|
955 |
01B6: MOVWF 1A
|
|
|
956 |
01B7: MOVLW 0A
|
|
|
957 |
01B8: MOVWF 1B
|
|
|
958 |
01B9: CALL 187
|
|
|
959 |
01BA: MOVF 0C,W
|
|
|
960 |
01BB: MOVWF 18
|
|
|
961 |
01BC: MOVF 0D,W
|
|
|
962 |
01BD: MOVLW 30
|
|
|
963 |
01BE: BTFSS 03.2
|
|
|
964 |
01BF: GOTO 1C4
|
|
|
965 |
01C0: BTFSC 19.3
|
|
|
966 |
01C1: GOTO 1C8
|
|
|
967 |
01C2: BTFSC 19.4
|
|
|
968 |
01C3: MOVLW 20
|
|
|
969 |
01C4: ADDWF 0D,F
|
|
|
970 |
01C5: MOVF 0D,W
|
|
|
971 |
01C6: MOVWF 1A
|
|
|
972 |
01C7: CALL 0A0
|
|
|
973 |
01C8: MOVLW 30
|
|
|
974 |
01C9: ADDWF 18,F
|
|
|
975 |
01CA: MOVF 18,W
|
|
|
976 |
01CB: MOVWF 1A
|
|
|
977 |
01CC: CALL 0A0
|
|
|
978 |
01CD: RETLW 00
|
|
|
979 |
*
|
|
|
980 |
0214: MOVLW 58
|
|
|
981 |
0215: MOVWF 1A
|
|
|
982 |
0216: CALL 0A0
|
|
|
983 |
0217: MOVF 0E,W
|
|
|
984 |
0218: MOVWF 18
|
|
|
985 |
0219: MOVLW 11
|
|
|
986 |
021A: MOVWF 19
|
|
|
987 |
021B: CALL 19C
|
|
|
988 |
021C: MOVLW 20
|
|
|
989 |
021D: MOVWF 1A
|
|
|
990 |
021E: CALL 0A0
|
|
|
991 |
021F: MOVF 10,W
|
|
|
992 |
0220: MOVWF 18
|
|
|
993 |
0221: MOVLW 10
|
|
|
994 |
0222: MOVWF 19
|
|
|
995 |
0223: CALL 19C
|
|
|
996 |
0224: MOVF 12,W
|
|
|
997 |
0225: MOVWF 18
|
|
|
998 |
0226: MOVLW 10
|
|
|
999 |
0227: MOVWF 19
|
|
|
1000 |
0228: CALL 19C
|
|
|
1001 |
0229: MOVF 13,W
|
|
|
1002 |
022A: MOVWF 18
|
|
|
1003 |
022B: MOVLW 10
|
|
|
1004 |
022C: MOVWF 19
|
|
|
1005 |
022D: CALL 19C
|
|
|
1006 |
022E: MOVLW 20
|
|
|
1007 |
022F: MOVWF 1A
|
|
|
1008 |
0230: CALL 0A0
|
|
|
1009 |
0231: MOVLW 20
|
|
|
1010 |
0232: MOVWF 1A
|
|
|
1011 |
0233: CALL 0A0
|
|
|
1012 |
.................... lcd_gotoxy(1,2);
|
|
|
1013 |
0234: MOVLW 01
|
|
|
1014 |
0235: MOVWF 1B
|
|
|
1015 |
0236: MOVLW 02
|
|
|
1016 |
0237: MOVWF 1C
|
|
|
1017 |
0238: CALL 08F
|
|
|
1018 |
.................... printf(lcd_putc,"Y%2U %3U%3U%3U ", y, yc, e3, e4);
|
|
|
1019 |
0239: MOVLW 59
|
|
|
1020 |
023A: MOVWF 1A
|
|
|
1021 |
023B: CALL 0A0
|
|
|
1022 |
023C: MOVF 0F,W
|
|
|
1023 |
023D: MOVWF 18
|
|
|
1024 |
023E: MOVLW 11
|
|
|
1025 |
023F: MOVWF 19
|
|
|
1026 |
0240: CALL 19C
|
|
|
1027 |
0241: MOVLW 20
|
|
|
1028 |
0242: MOVWF 1A
|
|
|
1029 |
0243: CALL 0A0
|
|
|
1030 |
0244: MOVF 11,W
|
|
|
1031 |
0245: MOVWF 18
|
|
|
1032 |
0246: MOVLW 10
|
|
|
1033 |
0247: MOVWF 19
|
|
|
1034 |
0248: CALL 19C
|
|
|
1035 |
0249: MOVF 14,W
|
|
|
1036 |
024A: MOVWF 18
|
|
|
1037 |
024B: MOVLW 10
|
|
|
1038 |
024C: MOVWF 19
|
|
|
1039 |
024D: CALL 19C
|
|
|
1040 |
024E: MOVF 15,W
|
|
|
1041 |
024F: MOVWF 18
|
|
|
1042 |
0250: MOVLW 10
|
|
|
1043 |
0251: MOVWF 19
|
|
|
1044 |
0252: CALL 19C
|
|
|
1045 |
0253: MOVLW 20
|
|
|
1046 |
0254: MOVWF 1A
|
|
|
1047 |
0255: CALL 0A0
|
|
|
1048 |
0256: MOVLW 20
|
|
|
1049 |
0257: MOVWF 1A
|
|
|
1050 |
0258: CALL 0A0
|
|
|
1051 |
....................
|
|
|
1052 |
.................... // ovladani serv
|
|
|
1053 |
.................... output_high(SERVO_X);
|
|
|
1054 |
0259: BSF 03.5
|
|
|
1055 |
025A: BCF 05.0
|
|
|
1056 |
025B: BCF 03.5
|
|
|
1057 |
025C: BSF 05.0
|
|
|
1058 |
.................... delay_ms(1);
|
|
|
1059 |
025D: MOVLW 01
|
|
|
1060 |
025E: MOVWF 1B
|
|
|
1061 |
025F: CALL 015
|
|
|
1062 |
.................... for (data=x; data--; data>0)
|
|
|
1063 |
0260: MOVF 0E,W
|
|
|
1064 |
0261: MOVWF 17
|
|
|
1065 |
0262: MOVF 17,W
|
|
|
1066 |
0263: DECF 17,F
|
|
|
1067 |
0264: XORLW 00
|
|
|
1068 |
0265: BTFSC 03.2
|
|
|
1069 |
0266: GOTO 271
|
|
|
1070 |
.................... delay_us(65);
|
|
|
1071 |
0267: MOVLW 15
|
|
|
1072 |
0268: MOVWF 0C
|
|
|
1073 |
0269: DECFSZ 0C,F
|
|
|
1074 |
026A: GOTO 269
|
|
|
1075 |
026B: NOP
|
|
|
1076 |
026C: MOVF 17,F
|
|
|
1077 |
026D: BTFSS 03.2
|
|
|
1078 |
026E: GOTO 270
|
|
|
1079 |
026F: MOVLW 00
|
|
|
1080 |
0270: GOTO 262
|
|
|
1081 |
.................... output_low(SERVO_X);
|
|
|
1082 |
0271: BSF 03.5
|
|
|
1083 |
0272: BCF 05.0
|
|
|
1084 |
0273: BCF 03.5
|
|
|
1085 |
0274: BCF 05.0
|
|
|
1086 |
....................
|
|
|
1087 |
.................... output_high(SERVO_Y);
|
|
|
1088 |
0275: BSF 03.5
|
|
|
1089 |
0276: BCF 05.1
|
|
|
1090 |
0277: BCF 03.5
|
|
|
1091 |
0278: BSF 05.1
|
|
|
1092 |
.................... delay_ms(1);
|
|
|
1093 |
0279: MOVLW 01
|
|
|
1094 |
027A: MOVWF 1B
|
|
|
1095 |
027B: CALL 015
|
|
|
1096 |
.................... for (data=y; data--; data>0)
|
|
|
1097 |
027C: MOVF 0F,W
|
|
|
1098 |
027D: MOVWF 17
|
|
|
1099 |
027E: MOVF 17,W
|
|
|
1100 |
027F: DECF 17,F
|
|
|
1101 |
0280: XORLW 00
|
|
|
1102 |
0281: BTFSC 03.2
|
|
|
1103 |
0282: GOTO 28D
|
|
|
1104 |
.................... delay_us(65);
|
|
|
1105 |
0283: MOVLW 15
|
|
|
1106 |
0284: MOVWF 0C
|
|
|
1107 |
0285: DECFSZ 0C,F
|
|
|
1108 |
0286: GOTO 285
|
|
|
1109 |
0287: NOP
|
|
|
1110 |
0288: MOVF 17,F
|
|
|
1111 |
0289: BTFSS 03.2
|
|
|
1112 |
028A: GOTO 28C
|
|
|
1113 |
028B: MOVLW 00
|
|
|
1114 |
028C: GOTO 27E
|
|
|
1115 |
.................... output_low(SERVO_Y);
|
|
|
1116 |
028D: BSF 03.5
|
|
|
1117 |
028E: BCF 05.1
|
|
|
1118 |
028F: BCF 03.5
|
|
|
1119 |
0290: BCF 05.1
|
|
|
1120 |
....................
|
|
|
1121 |
.................... for (data=30-x-y; data--; data>0)
|
|
|
1122 |
0291: MOVF 0E,W
|
|
|
1123 |
0292: SUBLW 1E
|
|
|
1124 |
0293: MOVWF 0D
|
|
|
1125 |
0294: MOVF 0F,W
|
|
|
1126 |
0295: SUBWF 0D,W
|
|
|
1127 |
0296: MOVWF 17
|
|
|
1128 |
0297: MOVF 17,W
|
|
|
1129 |
0298: DECF 17,F
|
|
|
1130 |
0299: XORLW 00
|
|
|
1131 |
029A: BTFSC 03.2
|
|
|
1132 |
029B: GOTO 2A6
|
|
|
1133 |
.................... delay_us(65);
|
|
|
1134 |
029C: MOVLW 15
|
|
|
1135 |
029D: MOVWF 0C
|
|
|
1136 |
029E: DECFSZ 0C,F
|
|
|
1137 |
029F: GOTO 29E
|
|
|
1138 |
02A0: NOP
|
|
|
1139 |
02A1: MOVF 17,F
|
|
|
1140 |
02A2: BTFSS 03.2
|
|
|
1141 |
02A3: GOTO 2A5
|
|
|
1142 |
02A4: MOVLW 00
|
|
|
1143 |
02A5: GOTO 297
|
|
|
1144 |
....................
|
|
|
1145 |
.................... }
|
|
|
1146 |
.................... }
|
|
|
1147 |
02A6: GOTO 1F5
|
|
|
1148 |
.................... }
|
|
|
1149 |
....................
|
|
|
1150 |
02A7: SLEEP
|
|
|
1151 |
....................
|
|
|
1152 |
....................
|