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