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