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