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: 561 (14%)
|
|
|
6 |
Largest free fragment is 2048
|
|
|
7 |
RAM used: 11 (6%) at main() level
|
|
|
8 |
22 (11%) worst case
|
|
|
9 |
Stack: 5 locations
|
|
|
10 |
|
|
|
11 |
*
|
|
|
12 |
0000: MOVLW 00
|
|
|
13 |
0001: MOVWF 0A
|
|
|
14 |
0002: GOTO 184
|
|
|
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 |
0017: MOVLW 30
|
|
|
27 |
0018: MOVWF 04
|
|
|
28 |
0019: MOVF 00,W
|
|
|
29 |
001A: BTFSC 03.2
|
|
|
30 |
001B: GOTO 02B
|
|
|
31 |
001C: MOVLW 01
|
|
|
32 |
001D: MOVWF 21
|
|
|
33 |
001E: CLRF 20
|
|
|
34 |
001F: DECFSZ 20,F
|
|
|
35 |
0020: GOTO 01F
|
|
|
36 |
0021: DECFSZ 21,F
|
|
|
37 |
0022: GOTO 01E
|
|
|
38 |
0023: MOVLW 4A
|
|
|
39 |
0024: MOVWF 20
|
|
|
40 |
0025: DECFSZ 20,F
|
|
|
41 |
0026: GOTO 025
|
|
|
42 |
0027: NOP
|
|
|
43 |
0028: NOP
|
|
|
44 |
0029: DECFSZ 00,F
|
|
|
45 |
002A: GOTO 01C
|
|
|
46 |
002B: 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 |
002C: MOVF 06,W
|
|
|
156 |
002D: ANDLW 0F
|
|
|
157 |
002E: MOVWF 34
|
|
|
158 |
002F: SWAPF 33,W
|
|
|
159 |
0030: MOVWF 20
|
|
|
160 |
0031: MOVLW F0
|
|
|
161 |
0032: ANDWF 20,F
|
|
|
162 |
0033: MOVF 20,W
|
|
|
163 |
0034: ANDLW F0
|
|
|
164 |
0035: IORWF 34,W
|
|
|
165 |
0036: MOVWF 06
|
|
|
166 |
.................... output_bit(LCD_E,1); // vzestupna hrana
|
|
|
167 |
0037: BSF 06.2
|
|
|
168 |
0038: BSF 03.5
|
|
|
169 |
0039: BCF 06.2
|
|
|
170 |
.................... delay_us(1); // pockej alespon 450ns od e nebo alespon 195ns od dat
|
|
|
171 |
003A: NOP
|
|
|
172 |
.................... output_bit(LCD_E,0); // sestupna hrana (minimalni perioda e je 1us)
|
|
|
173 |
003B: BCF 03.5
|
|
|
174 |
003C: BCF 06.2
|
|
|
175 |
003D: BSF 03.5
|
|
|
176 |
003E: BCF 06.2
|
|
|
177 |
003F: BCF 03.5
|
|
|
178 |
0040: 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 |
0041: MOVF 31,F
|
|
|
191 |
0042: BTFSS 03.2
|
|
|
192 |
0043: GOTO 046
|
|
|
193 |
0044: BCF 06.1
|
|
|
194 |
0045: GOTO 047
|
|
|
195 |
0046: BSF 06.1
|
|
|
196 |
0047: BSF 03.5
|
|
|
197 |
0048: BCF 06.1
|
|
|
198 |
.................... swap(n);
|
|
|
199 |
0049: BCF 03.5
|
|
|
200 |
004A: SWAPF 32,F
|
|
|
201 |
.................... lcd_send_nibble(n); // posli horni pulku bajtu
|
|
|
202 |
004B: MOVF 32,W
|
|
|
203 |
004C: MOVWF 33
|
|
|
204 |
004D: CALL 02C
|
|
|
205 |
.................... swap(n);
|
|
|
206 |
004E: SWAPF 32,F
|
|
|
207 |
.................... lcd_send_nibble(n); // posli spodni pulku bajtu
|
|
|
208 |
004F: MOVF 32,W
|
|
|
209 |
0050: MOVWF 33
|
|
|
210 |
0051: CALL 02C
|
|
|
211 |
.................... delay_us(40); // minimalni doba na provedeni prikazu
|
|
|
212 |
0052: MOVLW 0D
|
|
|
213 |
0053: MOVWF 20
|
|
|
214 |
0054: DECFSZ 20,F
|
|
|
215 |
0055: GOTO 054
|
|
|
216 |
0056: 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 |
0057: MOVLW 14
|
|
|
231 |
0058: MOVWF 30
|
|
|
232 |
0059: CALL 017
|
|
|
233 |
....................
|
|
|
234 |
.................... *LCD_TRIS = *LCD_TRIS & ~LCD_MASK; // nuluj odpovidajici bity tris registru datoveho portu LCD
|
|
|
235 |
005A: MOVLW 0F
|
|
|
236 |
005B: BSF 03.5
|
|
|
237 |
005C: ANDWF 06,F
|
|
|
238 |
....................
|
|
|
239 |
.................... output_bit(LCD_RS,0); // nastav jako vystup a nastav klidovy stav
|
|
|
240 |
005D: BCF 03.5
|
|
|
241 |
005E: BCF 06.1
|
|
|
242 |
005F: BSF 03.5
|
|
|
243 |
0060: BCF 06.1
|
|
|
244 |
.................... output_bit(LCD_E,0); // nastav jako vystup a nastav klidovy stav
|
|
|
245 |
0061: BCF 03.5
|
|
|
246 |
0062: BCF 06.2
|
|
|
247 |
0063: BSF 03.5
|
|
|
248 |
0064: BCF 06.2
|
|
|
249 |
....................
|
|
|
250 |
.................... for (i=0; i<3; i++) // nastav lcd do rezimu 8 bitu sbernice
|
|
|
251 |
0065: BCF 03.5
|
|
|
252 |
0066: CLRF 2A
|
|
|
253 |
0067: MOVF 2A,W
|
|
|
254 |
0068: SUBLW 02
|
|
|
255 |
0069: BTFSS 03.0
|
|
|
256 |
006A: GOTO 073
|
|
|
257 |
.................... {
|
|
|
258 |
.................... delay_ms(2); // muze byt rozdelany prenos dat (2x 4 bity) nebo pomaly povel
|
|
|
259 |
006B: MOVLW 02
|
|
|
260 |
006C: MOVWF 30
|
|
|
261 |
006D: CALL 017
|
|
|
262 |
.................... lcd_send_nibble(3); // rezim 8 bitu
|
|
|
263 |
006E: MOVLW 03
|
|
|
264 |
006F: MOVWF 33
|
|
|
265 |
0070: CALL 02C
|
|
|
266 |
.................... }
|
|
|
267 |
0071: INCF 2A,F
|
|
|
268 |
0072: GOTO 067
|
|
|
269 |
....................
|
|
|
270 |
.................... delay_us(40); // cas na zpracovani
|
|
|
271 |
0073: MOVLW 0D
|
|
|
272 |
0074: MOVWF 20
|
|
|
273 |
0075: DECFSZ 20,F
|
|
|
274 |
0076: GOTO 075
|
|
|
275 |
.................... lcd_send_nibble(2); // nastav rezim 4 bitu (plati od nasledujiciho prenosu)
|
|
|
276 |
0077: MOVLW 02
|
|
|
277 |
0078: MOVWF 33
|
|
|
278 |
0079: CALL 02C
|
|
|
279 |
.................... delay_us(40); // cas na zpracovani
|
|
|
280 |
007A: MOVLW 0D
|
|
|
281 |
007B: MOVWF 20
|
|
|
282 |
007C: DECFSZ 20,F
|
|
|
283 |
007D: GOTO 07C
|
|
|
284 |
....................
|
|
|
285 |
.................... for (i=0;i<3;i++) // proved inicializaci (nastaveni modu, smazani apod)
|
|
|
286 |
007E: CLRF 2A
|
|
|
287 |
007F: MOVF 2A,W
|
|
|
288 |
0080: SUBLW 02
|
|
|
289 |
0081: BTFSS 03.0
|
|
|
290 |
0082: GOTO 08F
|
|
|
291 |
.................... {
|
|
|
292 |
.................... lcd_send_byte(0,LCD_INIT_STRING[i]);
|
|
|
293 |
0083: MOVF 2A,W
|
|
|
294 |
0084: CALL 004
|
|
|
295 |
0085: MOVWF 2B
|
|
|
296 |
0086: CLRF 31
|
|
|
297 |
0087: MOVF 2B,W
|
|
|
298 |
0088: MOVWF 32
|
|
|
299 |
0089: CALL 041
|
|
|
300 |
.................... delay_ms(2);
|
|
|
301 |
008A: MOVLW 02
|
|
|
302 |
008B: MOVWF 30
|
|
|
303 |
008C: CALL 017
|
|
|
304 |
.................... }
|
|
|
305 |
008D: INCF 2A,F
|
|
|
306 |
008E: GOTO 07F
|
|
|
307 |
008F: BCF 0A.3
|
|
|
308 |
0090: GOTO 1C5 (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 |
0091: MOVLW 01
|
|
|
323 |
0092: SUBWF 2D,W
|
|
|
324 |
0093: MOVWF 2F
|
|
|
325 |
.................... if(y==2)
|
|
|
326 |
0094: MOVF 2E,W
|
|
|
327 |
0095: SUBLW 02
|
|
|
328 |
0096: BTFSS 03.2
|
|
|
329 |
0097: GOTO 09A
|
|
|
330 |
.................... Adr+=LCD_LINE_2;
|
|
|
331 |
0098: MOVLW 40
|
|
|
332 |
0099: ADDWF 2F,F
|
|
|
333 |
....................
|
|
|
334 |
.................... lcd_send_byte(0,0x80|Adr);
|
|
|
335 |
009A: MOVF 2F,W
|
|
|
336 |
009B: IORLW 80
|
|
|
337 |
009C: MOVWF 30
|
|
|
338 |
009D: CLRF 31
|
|
|
339 |
009E: MOVF 30,W
|
|
|
340 |
009F: MOVWF 32
|
|
|
341 |
00A0: CALL 041
|
|
|
342 |
00A1: 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 |
00A2: MOVF 2C,W
|
|
|
353 |
00A3: MOVWF 20
|
|
|
354 |
00A4: MOVLW 0C
|
|
|
355 |
00A5: SUBWF 20,W
|
|
|
356 |
00A6: BTFSC 03.2
|
|
|
357 |
00A7: GOTO 0B5
|
|
|
358 |
00A8: MOVLW 0A
|
|
|
359 |
00A9: SUBWF 20,W
|
|
|
360 |
00AA: BTFSC 03.2
|
|
|
361 |
00AB: GOTO 0BD
|
|
|
362 |
00AC: MOVLW 0D
|
|
|
363 |
00AD: SUBWF 20,W
|
|
|
364 |
00AE: BTFSC 03.2
|
|
|
365 |
00AF: GOTO 0C3
|
|
|
366 |
00B0: MOVLW 08
|
|
|
367 |
00B1: SUBWF 20,W
|
|
|
368 |
00B2: BTFSC 03.2
|
|
|
369 |
00B3: GOTO 0C8
|
|
|
370 |
00B4: GOTO 0CD
|
|
|
371 |
.................... {
|
|
|
372 |
.................... case '\f' : lcd_send_byte(0,1); // smaz displej
|
|
|
373 |
00B5: CLRF 31
|
|
|
374 |
00B6: MOVLW 01
|
|
|
375 |
00B7: MOVWF 32
|
|
|
376 |
00B8: CALL 041
|
|
|
377 |
.................... delay_ms(2);
|
|
|
378 |
00B9: MOVLW 02
|
|
|
379 |
00BA: MOVWF 30
|
|
|
380 |
00BB: CALL 017
|
|
|
381 |
.................... break;
|
|
|
382 |
00BC: GOTO 0D9
|
|
|
383 |
.................... case '\n' : lcd_gotoxy(1,2); break; // presun se na 1. znak 2. radky
|
|
|
384 |
00BD: MOVLW 01
|
|
|
385 |
00BE: MOVWF 2D
|
|
|
386 |
00BF: MOVLW 02
|
|
|
387 |
00C0: MOVWF 2E
|
|
|
388 |
00C1: CALL 091
|
|
|
389 |
00C2: GOTO 0D9
|
|
|
390 |
.................... case '\r' : lcd_gotoxy(1,1); break; // presun home
|
|
|
391 |
00C3: MOVLW 01
|
|
|
392 |
00C4: MOVWF 2D
|
|
|
393 |
00C5: MOVWF 2E
|
|
|
394 |
00C6: CALL 091
|
|
|
395 |
00C7: GOTO 0D9
|
|
|
396 |
.................... case '\b' : lcd_send_byte(0,0x10); break; // posun kurzor o 1 zpet
|
|
|
397 |
00C8: CLRF 31
|
|
|
398 |
00C9: MOVLW 10
|
|
|
399 |
00CA: MOVWF 32
|
|
|
400 |
00CB: CALL 041
|
|
|
401 |
00CC: GOTO 0D9
|
|
|
402 |
.................... default : if (c<0x20) c&=0x7; // preklopeni definovatelnych znaku na rozsah 0 az 0x1F
|
|
|
403 |
00CD: MOVF 2C,W
|
|
|
404 |
00CE: SUBLW 1F
|
|
|
405 |
00CF: BTFSS 03.0
|
|
|
406 |
00D0: GOTO 0D3
|
|
|
407 |
00D1: MOVLW 07
|
|
|
408 |
00D2: ANDWF 2C,F
|
|
|
409 |
.................... lcd_send_byte(1,c); break; // zapis znak
|
|
|
410 |
00D3: MOVLW 01
|
|
|
411 |
00D4: MOVWF 31
|
|
|
412 |
00D5: MOVF 2C,W
|
|
|
413 |
00D6: MOVWF 32
|
|
|
414 |
00D7: CALL 041
|
|
|
415 |
00D8: GOTO 0D9
|
|
|
416 |
.................... }
|
|
|
417 |
00D9: 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 |
.................... // Odesle nulu nebo jednicku podle nejnizsiho bitu predanych dat
|
|
|
526 |
.................... // Nula je posloupnost LH a jednicka je HL
|
|
|
527 |
.................... //
|
|
|
528 |
.................... void odeslat_bit(int8 data)
|
|
|
529 |
.................... {
|
|
|
530 |
.................... output_bit(VYSILAC,bit_test(data,0));
|
|
|
531 |
*
|
|
|
532 |
0132: BTFSC 30.0
|
|
|
533 |
0133: GOTO 136
|
|
|
534 |
0134: BCF 07.3
|
|
|
535 |
0135: GOTO 137
|
|
|
536 |
0136: BSF 07.3
|
|
|
537 |
0137: BCF 25.3
|
|
|
538 |
0138: MOVF 25,W
|
|
|
539 |
0139: BSF 03.5
|
|
|
540 |
013A: MOVWF 07
|
|
|
541 |
.................... delay_us(IMPULS);
|
|
|
542 |
013B: MOVLW 53
|
|
|
543 |
013C: BCF 03.5
|
|
|
544 |
013D: MOVWF 20
|
|
|
545 |
013E: DECFSZ 20,F
|
|
|
546 |
013F: GOTO 13E
|
|
|
547 |
.................... output_bit(VYSILAC,!bit_test(data,0));
|
|
|
548 |
0140: BTFSS 30.0
|
|
|
549 |
0141: GOTO 144
|
|
|
550 |
0142: BCF 07.3
|
|
|
551 |
0143: GOTO 145
|
|
|
552 |
0144: BSF 07.3
|
|
|
553 |
0145: BCF 25.3
|
|
|
554 |
0146: MOVF 25,W
|
|
|
555 |
0147: BSF 03.5
|
|
|
556 |
0148: MOVWF 07
|
|
|
557 |
.................... delay_us(IMPULS);
|
|
|
558 |
0149: MOVLW 53
|
|
|
559 |
014A: BCF 03.5
|
|
|
560 |
014B: MOVWF 20
|
|
|
561 |
014C: DECFSZ 20,F
|
|
|
562 |
014D: GOTO 14C
|
|
|
563 |
014E: RETLW 00
|
|
|
564 |
.................... }
|
|
|
565 |
....................
|
|
|
566 |
....................
|
|
|
567 |
.................... // Odelse ramec o 4 bitech
|
|
|
568 |
.................... // Datovy ramec zacina 11, synchronizacni ramec zacina 10
|
|
|
569 |
.................... //
|
|
|
570 |
.................... void odeslat_nibble(int1 datovy, int8 data)
|
|
|
571 |
.................... {
|
|
|
572 |
.................... int i;
|
|
|
573 |
....................
|
|
|
574 |
.................... delay_ms(3); // klidovy stav na lince
|
|
|
575 |
014F: MOVLW 03
|
|
|
576 |
0150: MOVWF 30
|
|
|
577 |
0151: CALL 017
|
|
|
578 |
....................
|
|
|
579 |
.................... odeslat_bit(1); // start bit
|
|
|
580 |
0152: MOVLW 01
|
|
|
581 |
0153: MOVWF 30
|
|
|
582 |
0154: CALL 132
|
|
|
583 |
.................... odeslat_bit(datovy);
|
|
|
584 |
0155: MOVF 2D,W
|
|
|
585 |
0156: MOVWF 30
|
|
|
586 |
0157: CALL 132
|
|
|
587 |
....................
|
|
|
588 |
.................... for (i=5; --i!=0; ) // datove bity
|
|
|
589 |
0158: MOVLW 05
|
|
|
590 |
0159: MOVWF 2F
|
|
|
591 |
015A: DECF 2F,F
|
|
|
592 |
015B: BTFSC 03.2
|
|
|
593 |
015C: GOTO 163
|
|
|
594 |
.................... {
|
|
|
595 |
.................... odeslat_bit(data);
|
|
|
596 |
015D: MOVF 2E,W
|
|
|
597 |
015E: MOVWF 30
|
|
|
598 |
015F: CALL 132
|
|
|
599 |
.................... data>>=1;
|
|
|
600 |
0160: BCF 03.0
|
|
|
601 |
0161: RRF 2E,F
|
|
|
602 |
.................... }
|
|
|
603 |
0162: GOTO 15A
|
|
|
604 |
....................
|
|
|
605 |
.................... output_low(VYSILAC); // klidovy stav
|
|
|
606 |
0163: BCF 25.3
|
|
|
607 |
0164: MOVF 25,W
|
|
|
608 |
0165: BSF 03.5
|
|
|
609 |
0166: MOVWF 07
|
|
|
610 |
0167: BCF 03.5
|
|
|
611 |
0168: BCF 07.3
|
|
|
612 |
0169: RETLW 00
|
|
|
613 |
.................... }
|
|
|
614 |
....................
|
|
|
615 |
....................
|
|
|
616 |
.................... void odeslat_paket(int8 kanal, data)
|
|
|
617 |
.................... {
|
|
|
618 |
.................... int8 suma;
|
|
|
619 |
....................
|
|
|
620 |
.................... suma = kanal+data;
|
|
|
621 |
016A: MOVF 2B,W
|
|
|
622 |
016B: ADDWF 2A,W
|
|
|
623 |
016C: MOVWF 2C
|
|
|
624 |
.................... odeslat_nibble(0,0b1111); // Synchronizace
|
|
|
625 |
016D: CLRF 2D
|
|
|
626 |
016E: MOVLW 0F
|
|
|
627 |
016F: MOVWF 2E
|
|
|
628 |
0170: CALL 14F
|
|
|
629 |
.................... odeslat_nibble(1,kanal); // Identifikace osy
|
|
|
630 |
0171: MOVLW 01
|
|
|
631 |
0172: MOVWF 2D
|
|
|
632 |
0173: MOVF 2A,W
|
|
|
633 |
0174: MOVWF 2E
|
|
|
634 |
0175: CALL 14F
|
|
|
635 |
.................... odeslat_nibble(1,data); // Hodnota osy
|
|
|
636 |
0176: MOVLW 01
|
|
|
637 |
0177: MOVWF 2D
|
|
|
638 |
0178: MOVF 2B,W
|
|
|
639 |
0179: MOVWF 2E
|
|
|
640 |
017A: CALL 14F
|
|
|
641 |
.................... odeslat_nibble(1,suma); // Kontrolni soucet
|
|
|
642 |
017B: MOVLW 01
|
|
|
643 |
017C: MOVWF 2D
|
|
|
644 |
017D: MOVF 2C,W
|
|
|
645 |
017E: MOVWF 2E
|
|
|
646 |
017F: CALL 14F
|
|
|
647 |
....................
|
|
|
648 |
.................... delay_ms(10); // cas pro prijimac aby mohl zpracovat data
|
|
|
649 |
0180: MOVLW 0A
|
|
|
650 |
0181: MOVWF 30
|
|
|
651 |
0182: CALL 017
|
|
|
652 |
0183: RETLW 00
|
|
|
653 |
.................... // mozno nahradit vysilanim jednicek
|
|
|
654 |
.................... }
|
|
|
655 |
....................
|
|
|
656 |
....................
|
|
|
657 |
.................... int stredX, stredY, x, y;
|
|
|
658 |
....................
|
|
|
659 |
.................... void kalibrace()
|
|
|
660 |
.................... {
|
|
|
661 |
.................... int8 min_x;
|
|
|
662 |
.................... int8 max_x;
|
|
|
663 |
.................... int8 min_y;
|
|
|
664 |
.................... int8 max_y;
|
|
|
665 |
.................... int8 sred_x;
|
|
|
666 |
.................... int8 sred_y;
|
|
|
667 |
.................... int8 adc;
|
|
|
668 |
.................... min_x=max_x=min_y=max_y=sred_x=sred_y=128;
|
|
|
669 |
....................
|
|
|
670 |
.................... printf(lcd_putc,"Paku dejte do prostred a stisknete tlacitko");
|
|
|
671 |
.................... znovu:
|
|
|
672 |
.................... if (TTL1 || TTL2)
|
|
|
673 |
.................... {
|
|
|
674 |
.................... set_adc_channel(AD_OSA_X);
|
|
|
675 |
.................... delay_us(10);
|
|
|
676 |
.................... sred_x=read_adc();
|
|
|
677 |
.................... set_adc_channel(AD_OSA_Y);
|
|
|
678 |
.................... delay_us(10);
|
|
|
679 |
.................... sred_y=read_adc();
|
|
|
680 |
.................... };
|
|
|
681 |
....................
|
|
|
682 |
.................... //else goto znovu;
|
|
|
683 |
....................
|
|
|
684 |
.................... printf(lcd_putc,"\f");
|
|
|
685 |
.................... printf(lcd_putc,"Pak ");
|
|
|
686 |
....................
|
|
|
687 |
.................... set_adc_channel(AD_OSA_X);
|
|
|
688 |
.................... delay_us(10);
|
|
|
689 |
....................
|
|
|
690 |
.................... adc=read_adc();
|
|
|
691 |
....................
|
|
|
692 |
.................... if (max_x < adc )max_x=adc;
|
|
|
693 |
.................... if (min_x > adc )min_x=adc;
|
|
|
694 |
....................
|
|
|
695 |
.................... set_adc_channel(AD_OSA_Y);
|
|
|
696 |
.................... delay_us(10);
|
|
|
697 |
....................
|
|
|
698 |
.................... adc=read_adc();
|
|
|
699 |
....................
|
|
|
700 |
.................... if (max_y < adc )max_y=adc;
|
|
|
701 |
.................... if (min_y > adc )min_y=adc;
|
|
|
702 |
....................
|
|
|
703 |
.................... if (TTL1 || TTL2) return;
|
|
|
704 |
.................... }
|
|
|
705 |
....................
|
|
|
706 |
....................
|
|
|
707 |
.................... void main()
|
|
|
708 |
.................... {
|
|
|
709 |
0184: CLRF 04
|
|
|
710 |
0185: MOVLW 1F
|
|
|
711 |
0186: ANDWF 03,F
|
|
|
712 |
0187: MOVLW 07
|
|
|
713 |
0188: BSF 03.5
|
|
|
714 |
0189: MOVWF 1F
|
|
|
715 |
018A: MOVLW FF
|
|
|
716 |
018B: BCF 03.5
|
|
|
717 |
018C: MOVWF 25
|
|
|
718 |
....................
|
|
|
719 |
.................... setup_adc_ports(RA0_RA1_RA3_ANALOG);
|
|
|
720 |
018D: MOVLW 04
|
|
|
721 |
018E: BSF 03.5
|
|
|
722 |
018F: MOVWF 1F
|
|
|
723 |
.................... setup_adc(ADC_CLOCK_DIV_2);
|
|
|
724 |
0190: BCF 03.5
|
|
|
725 |
0191: MOVF 1F,W
|
|
|
726 |
0192: ANDLW 38
|
|
|
727 |
0193: IORLW 01
|
|
|
728 |
0194: MOVWF 1F
|
|
|
729 |
.................... setup_spi(FALSE);
|
|
|
730 |
0195: BCF 14.5
|
|
|
731 |
0196: BCF 25.5
|
|
|
732 |
0197: MOVF 25,W
|
|
|
733 |
0198: BSF 03.5
|
|
|
734 |
0199: MOVWF 07
|
|
|
735 |
019A: BCF 03.5
|
|
|
736 |
019B: BSF 25.4
|
|
|
737 |
019C: MOVF 25,W
|
|
|
738 |
019D: BSF 03.5
|
|
|
739 |
019E: MOVWF 07
|
|
|
740 |
019F: BCF 03.5
|
|
|
741 |
01A0: BCF 25.3
|
|
|
742 |
01A1: MOVF 25,W
|
|
|
743 |
01A2: BSF 03.5
|
|
|
744 |
01A3: MOVWF 07
|
|
|
745 |
01A4: MOVLW 00
|
|
|
746 |
01A5: BCF 03.5
|
|
|
747 |
01A6: MOVWF 14
|
|
|
748 |
01A7: BSF 03.5
|
|
|
749 |
01A8: MOVWF 14
|
|
|
750 |
.................... setup_counters(RTCC_INTERNAL,RTCC_DIV_2);
|
|
|
751 |
01A9: BCF 03.5
|
|
|
752 |
01AA: CLRF 20
|
|
|
753 |
01AB: BTFSS 20.3
|
|
|
754 |
01AC: GOTO 1B5
|
|
|
755 |
01AD: MOVLW 07
|
|
|
756 |
01AE: CLRF 01
|
|
|
757 |
01AF: MOVLW 81
|
|
|
758 |
01B0: MOVWF 04
|
|
|
759 |
01B1: MOVF 00,W
|
|
|
760 |
01B2: ANDLW C0
|
|
|
761 |
01B3: IORLW 0F
|
|
|
762 |
01B4: MOVWF 00
|
|
|
763 |
01B5: CLRWDT
|
|
|
764 |
01B6: MOVLW 81
|
|
|
765 |
01B7: MOVWF 04
|
|
|
766 |
01B8: MOVF 00,W
|
|
|
767 |
01B9: ANDLW C0
|
|
|
768 |
01BA: IORWF 20,W
|
|
|
769 |
01BB: MOVWF 00
|
|
|
770 |
.................... setup_timer_1(T1_DISABLED);
|
|
|
771 |
01BC: CLRF 10
|
|
|
772 |
.................... setup_timer_2(T2_DISABLED,0,1);
|
|
|
773 |
01BD: MOVLW 00
|
|
|
774 |
01BE: MOVWF 21
|
|
|
775 |
01BF: MOVWF 12
|
|
|
776 |
01C0: MOVLW 00
|
|
|
777 |
01C1: BSF 03.5
|
|
|
778 |
01C2: MOVWF 12
|
|
|
779 |
....................
|
|
|
780 |
.................... lcd_init();
|
|
|
781 |
01C3: BCF 03.5
|
|
|
782 |
01C4: GOTO 057
|
|
|
783 |
.................... printf(lcd_putc,"\fAhoj!");
|
|
|
784 |
*
|
|
|
785 |
000C: BCF 0A.0
|
|
|
786 |
000D: BCF 0A.1
|
|
|
787 |
000E: BCF 0A.2
|
|
|
788 |
000F: ADDWF 02,F
|
|
|
789 |
0010: RETLW 0C
|
|
|
790 |
0011: RETLW 41
|
|
|
791 |
0012: RETLW 68
|
|
|
792 |
0013: RETLW 6F
|
|
|
793 |
0014: RETLW 6A
|
|
|
794 |
0015: RETLW 21
|
|
|
795 |
0016: RETLW 00
|
|
|
796 |
*
|
|
|
797 |
01C5: CLRF 2A
|
|
|
798 |
01C6: MOVF 2A,W
|
|
|
799 |
01C7: CALL 00C
|
|
|
800 |
01C8: INCF 2A,F
|
|
|
801 |
01C9: MOVWF 2C
|
|
|
802 |
01CA: CALL 0A2
|
|
|
803 |
01CB: MOVLW 06
|
|
|
804 |
01CC: SUBWF 2A,W
|
|
|
805 |
01CD: BTFSS 03.2
|
|
|
806 |
01CE: GOTO 1C6
|
|
|
807 |
.................... delay_ms(300);
|
|
|
808 |
01CF: MOVLW 02
|
|
|
809 |
01D0: MOVWF 2A
|
|
|
810 |
01D1: MOVLW 96
|
|
|
811 |
01D2: MOVWF 30
|
|
|
812 |
01D3: CALL 017
|
|
|
813 |
01D4: DECFSZ 2A,F
|
|
|
814 |
01D5: GOTO 1D1
|
|
|
815 |
....................
|
|
|
816 |
.................... while(true)
|
|
|
817 |
.................... {
|
|
|
818 |
.................... set_adc_channel(AD_OSA_X);
|
|
|
819 |
01D6: MOVLW 00
|
|
|
820 |
01D7: MOVWF 21
|
|
|
821 |
01D8: MOVF 1F,W
|
|
|
822 |
01D9: ANDLW C7
|
|
|
823 |
01DA: IORWF 21,W
|
|
|
824 |
01DB: MOVWF 1F
|
|
|
825 |
.................... lcd_gotoxy(1,1);
|
|
|
826 |
01DC: MOVLW 01
|
|
|
827 |
01DD: MOVWF 2D
|
|
|
828 |
01DE: MOVWF 2E
|
|
|
829 |
01DF: CALL 091
|
|
|
830 |
.................... x=read_adc() >> 4;
|
|
|
831 |
01E0: BSF 1F.2
|
|
|
832 |
01E1: BTFSC 1F.2
|
|
|
833 |
01E2: GOTO 1E1
|
|
|
834 |
01E3: MOVF 1E,W
|
|
|
835 |
01E4: SWAPF 1E,W
|
|
|
836 |
01E5: MOVWF 28
|
|
|
837 |
01E6: MOVLW 0F
|
|
|
838 |
01E7: ANDWF 28,F
|
|
|
839 |
.................... printf(lcd_putc,"X: %D ", x);
|
|
|
840 |
*
|
|
|
841 |
00EF: MOVF 2A,W
|
|
|
842 |
00F0: MOVWF 20
|
|
|
843 |
00F1: BTFSC 2A.7
|
|
|
844 |
00F2: GOTO 0F7
|
|
|
845 |
00F3: BTFSS 2B.2
|
|
|
846 |
00F4: GOTO 101
|
|
|
847 |
00F5: MOVLW 20
|
|
|
848 |
00F6: GOTO 0FC
|
|
|
849 |
00F7: COMF 20,F
|
|
|
850 |
00F8: INCF 20,F
|
|
|
851 |
00F9: MOVF 20,W
|
|
|
852 |
00FA: MOVWF 2A
|
|
|
853 |
00FB: MOVLW 2D
|
|
|
854 |
00FC: MOVWF 21
|
|
|
855 |
00FD: MOVWF 2C
|
|
|
856 |
00FE: CALL 0A2
|
|
|
857 |
00FF: BTFSS 2B.2
|
|
|
858 |
0100: BSF 2B.3
|
|
|
859 |
0101: MOVF 2A,W
|
|
|
860 |
0102: MOVWF 2C
|
|
|
861 |
0103: MOVLW 64
|
|
|
862 |
0104: MOVWF 2D
|
|
|
863 |
0105: CALL 0DA
|
|
|
864 |
0106: MOVF 20,W
|
|
|
865 |
0107: MOVWF 2A
|
|
|
866 |
0108: MOVF 21,W
|
|
|
867 |
0109: MOVLW 30
|
|
|
868 |
010A: BTFSS 03.2
|
|
|
869 |
010B: GOTO 113
|
|
|
870 |
010C: BTFSC 2B.0
|
|
|
871 |
010D: BSF 2B.3
|
|
|
872 |
010E: BTFSC 2B.3
|
|
|
873 |
010F: GOTO 119
|
|
|
874 |
0110: BTFSC 2B.4
|
|
|
875 |
0111: MOVLW 20
|
|
|
876 |
0112: GOTO 115
|
|
|
877 |
0113: BCF 2B.3
|
|
|
878 |
0114: BCF 2B.4
|
|
|
879 |
0115: ADDWF 21,F
|
|
|
880 |
0116: MOVF 21,W
|
|
|
881 |
0117: MOVWF 2C
|
|
|
882 |
0118: CALL 0A2
|
|
|
883 |
0119: MOVF 2A,W
|
|
|
884 |
011A: MOVWF 2C
|
|
|
885 |
011B: MOVLW 0A
|
|
|
886 |
011C: MOVWF 2D
|
|
|
887 |
011D: CALL 0DA
|
|
|
888 |
011E: MOVF 20,W
|
|
|
889 |
011F: MOVWF 2A
|
|
|
890 |
0120: MOVF 21,W
|
|
|
891 |
0121: MOVLW 30
|
|
|
892 |
0122: BTFSS 03.2
|
|
|
893 |
0123: GOTO 128
|
|
|
894 |
0124: BTFSC 2B.3
|
|
|
895 |
0125: GOTO 12C
|
|
|
896 |
0126: BTFSC 2B.4
|
|
|
897 |
0127: MOVLW 20
|
|
|
898 |
0128: ADDWF 21,F
|
|
|
899 |
0129: MOVF 21,W
|
|
|
900 |
012A: MOVWF 2C
|
|
|
901 |
012B: CALL 0A2
|
|
|
902 |
012C: MOVLW 30
|
|
|
903 |
012D: ADDWF 2A,F
|
|
|
904 |
012E: MOVF 2A,W
|
|
|
905 |
012F: MOVWF 2C
|
|
|
906 |
0130: CALL 0A2
|
|
|
907 |
0131: RETLW 00
|
|
|
908 |
*
|
|
|
909 |
01E8: MOVLW 58
|
|
|
910 |
01E9: MOVWF 2C
|
|
|
911 |
01EA: CALL 0A2
|
|
|
912 |
01EB: MOVLW 3A
|
|
|
913 |
01EC: MOVWF 2C
|
|
|
914 |
01ED: CALL 0A2
|
|
|
915 |
01EE: MOVLW 20
|
|
|
916 |
01EF: MOVWF 2C
|
|
|
917 |
01F0: CALL 0A2
|
|
|
918 |
01F1: MOVF 28,W
|
|
|
919 |
01F2: MOVWF 2A
|
|
|
920 |
01F3: MOVLW 18
|
|
|
921 |
01F4: MOVWF 2B
|
|
|
922 |
01F5: CALL 0EF
|
|
|
923 |
01F6: MOVLW 06
|
|
|
924 |
01F7: MOVWF 2A
|
|
|
925 |
01F8: MOVLW 20
|
|
|
926 |
01F9: MOVWF 2C
|
|
|
927 |
01FA: CALL 0A2
|
|
|
928 |
01FB: DECFSZ 2A,F
|
|
|
929 |
01FC: GOTO 1F8
|
|
|
930 |
.................... set_adc_channel(AD_OSA_Y);
|
|
|
931 |
01FD: MOVLW 08
|
|
|
932 |
01FE: MOVWF 21
|
|
|
933 |
01FF: MOVF 1F,W
|
|
|
934 |
0200: ANDLW C7
|
|
|
935 |
0201: IORWF 21,W
|
|
|
936 |
0202: MOVWF 1F
|
|
|
937 |
.................... lcd_gotoxy(1,2);
|
|
|
938 |
0203: MOVLW 01
|
|
|
939 |
0204: MOVWF 2D
|
|
|
940 |
0205: MOVLW 02
|
|
|
941 |
0206: MOVWF 2E
|
|
|
942 |
0207: CALL 091
|
|
|
943 |
.................... y=read_adc() >> 4;
|
|
|
944 |
0208: BSF 1F.2
|
|
|
945 |
0209: BTFSC 1F.2
|
|
|
946 |
020A: GOTO 209
|
|
|
947 |
020B: MOVF 1E,W
|
|
|
948 |
020C: SWAPF 1E,W
|
|
|
949 |
020D: MOVWF 29
|
|
|
950 |
020E: MOVLW 0F
|
|
|
951 |
020F: ANDWF 29,F
|
|
|
952 |
.................... printf(lcd_putc,"Y: %D ", y);
|
|
|
953 |
0210: MOVLW 59
|
|
|
954 |
0211: MOVWF 2C
|
|
|
955 |
0212: CALL 0A2
|
|
|
956 |
0213: MOVLW 3A
|
|
|
957 |
0214: MOVWF 2C
|
|
|
958 |
0215: CALL 0A2
|
|
|
959 |
0216: MOVLW 20
|
|
|
960 |
0217: MOVWF 2C
|
|
|
961 |
0218: CALL 0A2
|
|
|
962 |
0219: MOVF 29,W
|
|
|
963 |
021A: MOVWF 2A
|
|
|
964 |
021B: MOVLW 18
|
|
|
965 |
021C: MOVWF 2B
|
|
|
966 |
021D: CALL 0EF
|
|
|
967 |
021E: MOVLW 06
|
|
|
968 |
021F: MOVWF 2A
|
|
|
969 |
0220: MOVLW 20
|
|
|
970 |
0221: MOVWF 2C
|
|
|
971 |
0222: CALL 0A2
|
|
|
972 |
0223: DECFSZ 2A,F
|
|
|
973 |
0224: GOTO 220
|
|
|
974 |
....................
|
|
|
975 |
.................... odeslat_paket(OSA_X,x);
|
|
|
976 |
0225: MOVLW 01
|
|
|
977 |
0226: MOVWF 2A
|
|
|
978 |
0227: MOVF 28,W
|
|
|
979 |
0228: MOVWF 2B
|
|
|
980 |
0229: CALL 16A
|
|
|
981 |
.................... odeslat_paket(OSA_Y,y);
|
|
|
982 |
022A: MOVLW 02
|
|
|
983 |
022B: MOVWF 2A
|
|
|
984 |
022C: MOVF 29,W
|
|
|
985 |
022D: MOVWF 2B
|
|
|
986 |
022E: CALL 16A
|
|
|
987 |
....................
|
|
|
988 |
.................... }
|
|
|
989 |
022F: GOTO 1D6
|
|
|
990 |
....................
|
|
|
991 |
.................... }
|
|
|
992 |
....................
|
|
|
993 |
0230: SLEEP
|