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