6 |
kaklik |
1 |
CCS PCM C Compiler, Version 3.221, 27853 19-XII-05 23:22
|
|
|
2 |
|
|
|
3 |
Filename: D:\KAKLIK\programy\PIC_C\mereni\PS2mys\PIC16F88\mys.LST
|
|
|
4 |
|
|
|
5 |
ROM used: 953 words (23%)
|
|
|
6 |
Largest free fragment is 2048
|
|
|
7 |
RAM used: 19 (11%) at main() level
|
|
|
8 |
33 (19%) worst case
|
|
|
9 |
Stack: 5 locations
|
|
|
10 |
|
|
|
11 |
*
|
|
|
12 |
0000: MOVLW 00
|
|
|
13 |
0001: MOVWF 0A
|
|
|
14 |
0002: GOTO 2E2
|
|
|
15 |
0003: NOP
|
|
|
16 |
.................... #include "D:\KAKLIK\programy\PIC_C\mereni\PS2mys\PIC16F88\mys.h"
|
|
|
17 |
.................... #include <16F88.h>
|
|
|
18 |
.................... //////// Standard Header file for the PIC16F88 device ////////////////
|
|
|
19 |
.................... #device PIC16F88
|
|
|
20 |
.................... #list
|
|
|
21 |
....................
|
|
|
22 |
.................... #device adc=8
|
|
|
23 |
.................... #fuses NOWDT,INTRC_IO, NOPUT, MCLR, BROWNOUT, NOLVP, NOCPD, NOWRT, NODEBUG, NOPROTECT, FCMEN, IESO
|
|
|
24 |
.................... #use delay(clock=4000000)
|
|
|
25 |
*
|
|
|
26 |
0033: MOVLW 34
|
|
|
27 |
0034: MOVWF 04
|
|
|
28 |
0035: MOVF 00,W
|
|
|
29 |
0036: BTFSC 03.2
|
|
|
30 |
0037: GOTO 047
|
|
|
31 |
0038: MOVLW 01
|
|
|
32 |
0039: MOVWF 78
|
|
|
33 |
003A: CLRF 77
|
|
|
34 |
003B: DECFSZ 77,F
|
|
|
35 |
003C: GOTO 03B
|
|
|
36 |
003D: DECFSZ 78,F
|
|
|
37 |
003E: GOTO 03A
|
|
|
38 |
003F: MOVLW 4A
|
|
|
39 |
0040: MOVWF 77
|
|
|
40 |
0041: DECFSZ 77,F
|
|
|
41 |
0042: GOTO 041
|
|
|
42 |
0043: NOP
|
|
|
43 |
0044: NOP
|
|
|
44 |
0045: DECFSZ 00,F
|
|
|
45 |
0046: GOTO 038
|
|
|
46 |
0047: RETLW 00
|
|
|
47 |
....................
|
|
|
48 |
....................
|
|
|
49 |
....................
|
|
|
50 |
.................... #define LCD_RS PIN_A0 // rizeni registru LCD displeje
|
|
|
51 |
.................... #define LCD_E PIN_A1 // enable LCD displeje
|
|
|
52 |
.................... #define LCD_DATA_LSB PIN_B0 // pripojeni LSB bitu datoveho portu LCD displeje (celkem 4 bity vzestupne za sebou)
|
|
|
53 |
.................... #include "C:\library\CCS\lcd.c"
|
|
|
54 |
.................... // LCD modul pro ovladani dvouradkoveho LCD modulu se standardnim Hitachi radicem
|
|
|
55 |
.................... // (c)miho 2002,2005
|
|
|
56 |
.................... //
|
|
|
57 |
.................... // Historie:
|
|
|
58 |
.................... //
|
|
|
59 |
.................... // 0.00 Uvodni verze se snadnou definici portu LCD displeje
|
|
|
60 |
.................... // 0.01 Oprava portu (zapomenute stare identifikatory)
|
|
|
61 |
.................... // 0.02 Doplnena moznost pripojeni datoveho portu LCD na libovolne porty
|
|
|
62 |
.................... // 0.03 Doplnena procedura lcd_clr pro smazani displeje
|
|
|
63 |
.................... //
|
|
|
64 |
.................... //
|
|
|
65 |
.................... // Funkce:
|
|
|
66 |
.................... //
|
|
|
67 |
.................... // lcd_init() inicializuje LCD displej a porty, nutno volat jako prvni
|
|
|
68 |
.................... //
|
|
|
69 |
.................... // lcd_putc(c) zapis snaku do lcd displeje, zpracovava nasledujici ridici znaky
|
|
|
70 |
.................... // \f = \x0C - nova stranka - smazani displeje
|
|
|
71 |
.................... // \n = \x0A - odradkovani (prechod na druhou radku)
|
|
|
72 |
.................... // \b = \x08 - backspace - posunuti kurzoru o 1 pozici zpet
|
|
|
73 |
.................... // \r = \x0D - goto home to position 1,1
|
|
|
74 |
.................... // \0 .. \7 - definovatelne znaky v pozicich 0 az 7 v CGRAM
|
|
|
75 |
.................... // \20 .. \27 - alternativne zapsane znaky (oktalove) v pozicich 0 az 7 CGRAM
|
|
|
76 |
.................... // Pozor na to, ze funkce printf konci tisk pokud narazi na \0 (konec retezce)
|
|
|
77 |
.................... //
|
|
|
78 |
.................... // lcd_gotoxy(x,y) presune kurzor na uvedenou adresu
|
|
|
79 |
.................... // nekontroluje parametry
|
|
|
80 |
.................... //
|
|
|
81 |
.................... // lcd_cursor_on zapne kurzor
|
|
|
82 |
.................... // lcd_cursor_off vypne kurzor
|
|
|
83 |
.................... //
|
|
|
84 |
.................... // lcd_clr smaze displej
|
|
|
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 |
.................... //
|
|
|
93 |
.................... // Definice portu: // Datovy port displeje pripojeny na 4 bity za sebou na jeden port
|
|
|
94 |
.................... //
|
|
|
95 |
.................... // #define LCD_RS PIN_B2 // rizeni registru LCD displeje
|
|
|
96 |
.................... // #define LCD_E PIN_B1 // enable LCD displeje
|
|
|
97 |
.................... // #define LCD_DATA_LSB PIN_C2 // pripojeni LSB bitu datoveho portu LCD displeje (celkem 4 bity vzestupne za sebou)
|
|
|
98 |
.................... //
|
|
|
99 |
.................... //
|
|
|
100 |
.................... // Alternativni definice: // Datovy port displeje pripojeny na libovolne 4 bitove porty (vede na kod delsi asi o 25 slov)
|
|
|
101 |
.................... //
|
|
|
102 |
.................... // #define LCD_RS PIN_B2 // rizeni registru LCD displeje
|
|
|
103 |
.................... // #define LCD_E PIN_B1 // enable LCD displeje
|
|
|
104 |
.................... // #define LCD_D0 PIN_C2 // D0 - datove bity pripojene na libovolne porty
|
|
|
105 |
.................... // #define LCD_D1 PIN_C3 // D1
|
|
|
106 |
.................... // #define LCD_D2 PIN_C4 // D2
|
|
|
107 |
.................... // #define LCD_D3 PIN_C5 // D3
|
|
|
108 |
....................
|
|
|
109 |
....................
|
|
|
110 |
....................
|
|
|
111 |
....................
|
|
|
112 |
.................... // Privatni sekce, cist jen v pripade, ze neco nefunguje
|
|
|
113 |
....................
|
|
|
114 |
....................
|
|
|
115 |
....................
|
|
|
116 |
....................
|
|
|
117 |
.................... #ifdef LCD_DATA_LSB
|
|
|
118 |
.................... // Generovane defince portu pro ucely teto knihovny aby kod generoval spravne IO operace a soucasne
|
|
|
119 |
.................... // bylo mozne jednoduse deklarovat pripojene piny LCD displeje pri pouziti teto knihovny. Problem spociva
|
|
|
120 |
.................... // v tom, ze se musi spravne ridit smery portu a soucasne datovy port zabira jen 4 bity ze zadaneho portu
|
|
|
121 |
.................... //
|
|
|
122 |
.................... #define LCD_SHIFT (LCD_DATA_LSB&7) // pocet bitu posuvu datoveho kanalu v datovem portu
|
|
|
123 |
.................... #define LCD_PORT (LCD_DATA_LSB>>3) // adresa LCD datoveho portu
|
|
|
124 |
.................... #define LCD_TRIS (LCD_PORT+0x80) // adresa prislusneho TRIS registru
|
|
|
125 |
.................... #define LCD_MASK (0xF<<LCD_SHIFT) // maska platnych bitu
|
|
|
126 |
.................... //
|
|
|
127 |
.................... #if LCD_SHIFT>4 // kontrola mezi
|
|
|
128 |
.................... #error LCD data port LSB bit not in range 0..4
|
|
|
129 |
.................... #endif
|
|
|
130 |
.................... #endif
|
|
|
131 |
....................
|
|
|
132 |
....................
|
|
|
133 |
.................... // Definice konstant pro LCD display
|
|
|
134 |
.................... //
|
|
|
135 |
.................... #define LCD_CURSOR_ON_ 0x0E // kurzor jako blikajici radka pod znakem
|
|
|
136 |
.................... #define LCD_CURSOR_OFF_ 0x0C // zadny kurzor
|
|
|
137 |
.................... #define LCD_LINE_2 0x40 // adresa 1. znaku 2. radky
|
|
|
138 |
....................
|
|
|
139 |
....................
|
|
|
140 |
.................... // Definice rezimu LCD displeje
|
|
|
141 |
.................... //
|
|
|
142 |
.................... BYTE const LCD_INIT_STRING[4] =
|
|
|
143 |
.................... {
|
|
|
144 |
.................... 0x28, // intrfejs 4 bity, 2 radky, font 5x7
|
|
|
145 |
.................... LCD_CURSOR_OFF_, // display on, kurzor off,
|
|
|
146 |
.................... 0x01, // clear displeje
|
|
|
147 |
.................... 0x06 // inkrement pozice kurzoru (posun kurzoru doprava)
|
|
|
148 |
.................... };
|
|
|
149 |
....................
|
|
|
150 |
....................
|
|
|
151 |
.................... // Odesle nibble do displeje (posle data a klikne signalem e)
|
|
|
152 |
.................... //
|
|
|
153 |
.................... void lcd_send_nibble( BYTE n )
|
|
|
154 |
.................... {
|
|
|
155 |
.................... #ifdef LCD_DATA_LSB
|
|
|
156 |
.................... // data jsou za sebou na 4 bitech jednoho portu
|
|
|
157 |
.................... *LCD_PORT = (*LCD_PORT & ~LCD_MASK) | ((n << LCD_SHIFT) & LCD_MASK); // nastav datove bity portu a ostatni zachovej
|
|
|
158 |
0048: MOVF 06,W
|
|
|
159 |
0049: ANDLW F0
|
|
|
160 |
004A: MOVWF 3B
|
|
|
161 |
004B: MOVF 3A,W
|
|
|
162 |
004C: ANDLW 0F
|
|
|
163 |
004D: IORWF 3B,W
|
|
|
164 |
004E: MOVWF 06
|
|
|
165 |
.................... #else
|
|
|
166 |
.................... // data jsou na libovolnych 4 bitech libovolnych portu
|
|
|
167 |
.................... output_bit(LCD_D0,bit_test(n,0));
|
|
|
168 |
.................... output_bit(LCD_D1,bit_test(n,1));
|
|
|
169 |
.................... output_bit(LCD_D2,bit_test(n,2));
|
|
|
170 |
.................... output_bit(LCD_D3,bit_test(n,3));
|
|
|
171 |
.................... #endif
|
|
|
172 |
.................... output_bit(LCD_E,1); // vzestupna hrana
|
|
|
173 |
004F: BSF 05.1
|
|
|
174 |
0050: BSF 03.5
|
|
|
175 |
0051: BCF 05.1
|
|
|
176 |
.................... delay_us(1); // pockej alespon 450ns od e nebo alespon 195ns od dat
|
|
|
177 |
0052: NOP
|
|
|
178 |
.................... output_bit(LCD_E,0); // sestupna hrana (minimalni perioda e je 1us)
|
|
|
179 |
0053: BCF 03.5
|
|
|
180 |
0054: BCF 05.1
|
|
|
181 |
0055: BSF 03.5
|
|
|
182 |
0056: BCF 05.1
|
|
|
183 |
.................... }
|
|
|
184 |
0057: BCF 03.5
|
|
|
185 |
0058: RETLW 00
|
|
|
186 |
....................
|
|
|
187 |
....................
|
|
|
188 |
.................... // Odesle bajt do registru LCD
|
|
|
189 |
.................... //
|
|
|
190 |
.................... // Pokud je Adr=0 .. instrukcni registr
|
|
|
191 |
.................... // Pokud je Adr=1 .. datovy registr
|
|
|
192 |
.................... //
|
|
|
193 |
.................... void lcd_send_byte( BOOLEAN Adr, BYTE n )
|
|
|
194 |
.................... {
|
|
|
195 |
.................... output_bit(LCD_RS,Adr); // vyber registr
|
|
|
196 |
0059: MOVF 38,F
|
|
|
197 |
005A: BTFSS 03.2
|
|
|
198 |
005B: GOTO 05E
|
|
|
199 |
005C: BCF 05.0
|
|
|
200 |
005D: GOTO 05F
|
|
|
201 |
005E: BSF 05.0
|
|
|
202 |
005F: BSF 03.5
|
|
|
203 |
0060: BCF 05.0
|
|
|
204 |
.................... swap(n);
|
|
|
205 |
0061: BCF 03.5
|
|
|
206 |
0062: SWAPF 39,F
|
|
|
207 |
.................... lcd_send_nibble(n); // posli horni pulku bajtu
|
|
|
208 |
0063: MOVF 39,W
|
|
|
209 |
0064: MOVWF 3A
|
|
|
210 |
0065: CALL 048
|
|
|
211 |
.................... swap(n);
|
|
|
212 |
0066: SWAPF 39,F
|
|
|
213 |
.................... lcd_send_nibble(n); // posli spodni pulku bajtu
|
|
|
214 |
0067: MOVF 39,W
|
|
|
215 |
0068: MOVWF 3A
|
|
|
216 |
0069: CALL 048
|
|
|
217 |
.................... delay_us(40); // minimalni doba na provedeni prikazu
|
|
|
218 |
006A: MOVLW 0D
|
|
|
219 |
006B: MOVWF 77
|
|
|
220 |
006C: DECFSZ 77,F
|
|
|
221 |
006D: GOTO 06C
|
|
|
222 |
.................... }
|
|
|
223 |
006E: RETLW 00
|
|
|
224 |
....................
|
|
|
225 |
....................
|
|
|
226 |
.................... // Provede inicializaci LCD displeje, smaze obsah a nastavi mod displeje
|
|
|
227 |
.................... //
|
|
|
228 |
.................... // Tato procedura se musi volat pred pouzitim ostatnich lcd_ procedur
|
|
|
229 |
.................... //
|
|
|
230 |
.................... void lcd_init()
|
|
|
231 |
.................... {
|
|
|
232 |
....................
|
|
|
233 |
.................... int i; // pocitadlo cyklu
|
|
|
234 |
....................
|
|
|
235 |
.................... delay_ms(20); // spozdeni pro provedeni startu displeje po zapnuti napajeni
|
|
|
236 |
006F: MOVLW 14
|
|
|
237 |
0070: MOVWF 34
|
|
|
238 |
0071: CALL 033
|
|
|
239 |
....................
|
|
|
240 |
.................... #ifdef LCD_DATA_LSB
|
|
|
241 |
.................... // data jsou na 4 bitech za sebou, nastav smer pro vsechny dalsi prenosy
|
|
|
242 |
.................... *LCD_TRIS = *LCD_TRIS & ~LCD_MASK; // nuluj odpovidajici bity tris registru datoveho portu LCD
|
|
|
243 |
0072: MOVLW F0
|
|
|
244 |
0073: BSF 03.5
|
|
|
245 |
0074: ANDWF 06,F
|
|
|
246 |
.................... #endif
|
|
|
247 |
....................
|
|
|
248 |
.................... output_bit(LCD_RS,0); // nastav jako vystup a nastav klidovy stav
|
|
|
249 |
0075: BCF 03.5
|
|
|
250 |
0076: BCF 05.0
|
|
|
251 |
0077: BSF 03.5
|
|
|
252 |
0078: BCF 05.0
|
|
|
253 |
.................... output_bit(LCD_E, 0); // nastav jako vystup a nastav klidovy stav
|
|
|
254 |
0079: BCF 03.5
|
|
|
255 |
007A: BCF 05.1
|
|
|
256 |
007B: BSF 03.5
|
|
|
257 |
007C: BCF 05.1
|
|
|
258 |
....................
|
|
|
259 |
.................... for (i=0; i<3; i++) // nastav lcd do rezimu 8 bitu sbernice
|
|
|
260 |
007D: BCF 03.5
|
|
|
261 |
007E: CLRF 2B
|
|
|
262 |
007F: MOVF 2B,W
|
|
|
263 |
0080: SUBLW 02
|
|
|
264 |
0081: BTFSS 03.0
|
|
|
265 |
0082: GOTO 08B
|
|
|
266 |
.................... {
|
|
|
267 |
.................... delay_ms(2); // muze byt rozdelany prenos dat (2x 4 bity) nebo pomaly povel
|
|
|
268 |
0083: MOVLW 02
|
|
|
269 |
0084: MOVWF 34
|
|
|
270 |
0085: CALL 033
|
|
|
271 |
.................... lcd_send_nibble(3); // rezim 8 bitu
|
|
|
272 |
0086: MOVLW 03
|
|
|
273 |
0087: MOVWF 3A
|
|
|
274 |
0088: CALL 048
|
|
|
275 |
.................... }
|
|
|
276 |
0089: INCF 2B,F
|
|
|
277 |
008A: GOTO 07F
|
|
|
278 |
....................
|
|
|
279 |
.................... delay_us(40); // cas na zpracovani
|
|
|
280 |
008B: MOVLW 0D
|
|
|
281 |
008C: MOVWF 77
|
|
|
282 |
008D: DECFSZ 77,F
|
|
|
283 |
008E: GOTO 08D
|
|
|
284 |
.................... lcd_send_nibble(2); // nastav rezim 4 bitu (plati od nasledujiciho prenosu)
|
|
|
285 |
008F: MOVLW 02
|
|
|
286 |
0090: MOVWF 3A
|
|
|
287 |
0091: CALL 048
|
|
|
288 |
.................... delay_us(40); // cas na zpracovani
|
|
|
289 |
0092: MOVLW 0D
|
|
|
290 |
0093: MOVWF 77
|
|
|
291 |
0094: DECFSZ 77,F
|
|
|
292 |
0095: GOTO 094
|
|
|
293 |
....................
|
|
|
294 |
.................... for (i=0;i<3;i++) // proved inicializaci (nastaveni modu, smazani apod)
|
|
|
295 |
0096: CLRF 2B
|
|
|
296 |
0097: MOVF 2B,W
|
|
|
297 |
0098: SUBLW 02
|
|
|
298 |
0099: BTFSS 03.0
|
|
|
299 |
009A: GOTO 0A7
|
|
|
300 |
.................... {
|
|
|
301 |
.................... lcd_send_byte(0,LCD_INIT_STRING[i]);
|
|
|
302 |
009B: MOVF 2B,W
|
|
|
303 |
009C: CALL 004
|
|
|
304 |
009D: MOVWF 2C
|
|
|
305 |
009E: CLRF 38
|
|
|
306 |
009F: MOVF 2C,W
|
|
|
307 |
00A0: MOVWF 39
|
|
|
308 |
00A1: CALL 059
|
|
|
309 |
.................... delay_ms(2);
|
|
|
310 |
00A2: MOVLW 02
|
|
|
311 |
00A3: MOVWF 34
|
|
|
312 |
00A4: CALL 033
|
|
|
313 |
.................... }
|
|
|
314 |
00A5: INCF 2B,F
|
|
|
315 |
00A6: GOTO 097
|
|
|
316 |
.................... }
|
|
|
317 |
00A7: BCF 0A.3
|
|
|
318 |
00A8: GOTO 324 (RETURN)
|
|
|
319 |
....................
|
|
|
320 |
....................
|
|
|
321 |
.................... // Proved presun kurzoru
|
|
|
322 |
.................... //
|
|
|
323 |
.................... // Pozice 1.1 je domu
|
|
|
324 |
.................... //
|
|
|
325 |
.................... void lcd_gotoxy( BYTE x, BYTE y)
|
|
|
326 |
.................... {
|
|
|
327 |
....................
|
|
|
328 |
.................... BYTE Adr;
|
|
|
329 |
....................
|
|
|
330 |
.................... Adr=x-1;
|
|
|
331 |
*
|
|
|
332 |
0108: MOVLW 01
|
|
|
333 |
0109: SUBWF 34,W
|
|
|
334 |
010A: MOVWF 36
|
|
|
335 |
.................... if(y==2)
|
|
|
336 |
010B: MOVF 35,W
|
|
|
337 |
010C: SUBLW 02
|
|
|
338 |
010D: BTFSS 03.2
|
|
|
339 |
010E: GOTO 111
|
|
|
340 |
.................... Adr+=LCD_LINE_2;
|
|
|
341 |
010F: MOVLW 40
|
|
|
342 |
0110: ADDWF 36,F
|
|
|
343 |
....................
|
|
|
344 |
.................... lcd_send_byte(0,0x80|Adr);
|
|
|
345 |
0111: MOVF 36,W
|
|
|
346 |
0112: IORLW 80
|
|
|
347 |
0113: MOVWF 37
|
|
|
348 |
0114: CLRF 38
|
|
|
349 |
0115: MOVF 37,W
|
|
|
350 |
0116: MOVWF 39
|
|
|
351 |
0117: CALL 059
|
|
|
352 |
.................... }
|
|
|
353 |
0118: RETLW 00
|
|
|
354 |
....................
|
|
|
355 |
....................
|
|
|
356 |
.................... // Zapis znaku na displej, zpracovani ridicich znaku
|
|
|
357 |
.................... //
|
|
|
358 |
.................... void lcd_putc( char c)
|
|
|
359 |
.................... {
|
|
|
360 |
....................
|
|
|
361 |
.................... switch (c)
|
|
|
362 |
.................... {
|
|
|
363 |
0119: MOVF 33,W
|
|
|
364 |
011A: XORLW 0C
|
|
|
365 |
011B: BTFSC 03.2
|
|
|
366 |
011C: GOTO 127
|
|
|
367 |
011D: XORLW 06
|
|
|
368 |
011E: BTFSC 03.2
|
|
|
369 |
011F: GOTO 12F
|
|
|
370 |
0120: XORLW 07
|
|
|
371 |
0121: BTFSC 03.2
|
|
|
372 |
0122: GOTO 135
|
|
|
373 |
0123: XORLW 05
|
|
|
374 |
0124: BTFSC 03.2
|
|
|
375 |
0125: GOTO 13A
|
|
|
376 |
0126: GOTO 13F
|
|
|
377 |
.................... case '\f' : lcd_send_byte(0,1); // smaz displej
|
|
|
378 |
0127: CLRF 38
|
|
|
379 |
0128: MOVLW 01
|
|
|
380 |
0129: MOVWF 39
|
|
|
381 |
012A: CALL 059
|
|
|
382 |
.................... delay_ms(2);
|
|
|
383 |
012B: MOVLW 02
|
|
|
384 |
012C: MOVWF 34
|
|
|
385 |
012D: CALL 033
|
|
|
386 |
.................... break;
|
|
|
387 |
012E: GOTO 14B
|
|
|
388 |
.................... case '\n' : lcd_gotoxy(1,2); break; // presun se na 1. znak 2. radky
|
|
|
389 |
012F: MOVLW 01
|
|
|
390 |
0130: MOVWF 34
|
|
|
391 |
0131: MOVLW 02
|
|
|
392 |
0132: MOVWF 35
|
|
|
393 |
0133: CALL 108
|
|
|
394 |
0134: GOTO 14B
|
|
|
395 |
.................... case '\r' : lcd_gotoxy(1,1); break; // presun home
|
|
|
396 |
0135: MOVLW 01
|
|
|
397 |
0136: MOVWF 34
|
|
|
398 |
0137: MOVWF 35
|
|
|
399 |
0138: CALL 108
|
|
|
400 |
0139: GOTO 14B
|
|
|
401 |
.................... case '\b' : lcd_send_byte(0,0x10); break; // posun kurzor o 1 zpet
|
|
|
402 |
013A: CLRF 38
|
|
|
403 |
013B: MOVLW 10
|
|
|
404 |
013C: MOVWF 39
|
|
|
405 |
013D: CALL 059
|
|
|
406 |
013E: GOTO 14B
|
|
|
407 |
.................... default : if (c<0x20) c&=0x7; // preklopeni definovatelnych znaku na rozsah 0 az 0x1F
|
|
|
408 |
013F: MOVF 33,W
|
|
|
409 |
0140: SUBLW 1F
|
|
|
410 |
0141: BTFSS 03.0
|
|
|
411 |
0142: GOTO 145
|
|
|
412 |
0143: MOVLW 07
|
|
|
413 |
0144: ANDWF 33,F
|
|
|
414 |
.................... lcd_send_byte(1,c); break; // zapis znak
|
|
|
415 |
0145: MOVLW 01
|
|
|
416 |
0146: MOVWF 38
|
|
|
417 |
0147: MOVF 33,W
|
|
|
418 |
0148: MOVWF 39
|
|
|
419 |
0149: CALL 059
|
|
|
420 |
014A: GOTO 14B
|
|
|
421 |
.................... }
|
|
|
422 |
.................... }
|
|
|
423 |
014B: RETLW 00
|
|
|
424 |
....................
|
|
|
425 |
....................
|
|
|
426 |
.................... // Zapni kurzor
|
|
|
427 |
.................... //
|
|
|
428 |
.................... void lcd_cursor_on()
|
|
|
429 |
.................... {
|
|
|
430 |
.................... lcd_send_byte(0,LCD_CURSOR_ON_);
|
|
|
431 |
.................... }
|
|
|
432 |
....................
|
|
|
433 |
....................
|
|
|
434 |
.................... // Vypni kurzor
|
|
|
435 |
.................... //
|
|
|
436 |
.................... void lcd_cursor_off()
|
|
|
437 |
.................... {
|
|
|
438 |
.................... lcd_send_byte(0,LCD_CURSOR_OFF_);
|
|
|
439 |
.................... }
|
|
|
440 |
....................
|
|
|
441 |
....................
|
|
|
442 |
.................... // Smaz displej
|
|
|
443 |
.................... //
|
|
|
444 |
.................... void lcd_clr()
|
|
|
445 |
.................... {
|
|
|
446 |
.................... lcd_putc('\f');
|
|
|
447 |
.................... }
|
|
|
448 |
....................
|
|
|
449 |
....................
|
|
|
450 |
.................... // Definice vlastnich fontu
|
|
|
451 |
.................... //
|
|
|
452 |
.................... // Vlastnich definic muze byt jen 8 do pozic 0 az 7 pameti CGRAM radice lcd displeje
|
|
|
453 |
.................... // Pro snadne definovani jsou pripraveny nasledujici definice a na konci souboru je uveden
|
|
|
454 |
.................... // priklad pouziti definovanych znaku.
|
|
|
455 |
....................
|
|
|
456 |
....................
|
|
|
457 |
.................... // Pomocna procedura pro posilani ridicich dat do radice displeje
|
|
|
458 |
.................... //
|
|
|
459 |
.................... void lcd_putc2(int Data)
|
|
|
460 |
.................... {
|
|
|
461 |
.................... lcd_send_byte(1,Data);
|
|
|
462 |
.................... }
|
|
|
463 |
....................
|
|
|
464 |
....................
|
|
|
465 |
.................... // Pomocne definice pro programovani obsahu CGRAM
|
|
|
466 |
.................... //
|
|
|
467 |
.................... #define lcd_define_start(Code) lcd_send_byte(0,0x40+(Code<<3)); delay_ms(2)
|
|
|
468 |
.................... #define lcd_define_def(String) printf(lcd_putc2,String);
|
|
|
469 |
.................... #define lcd_define_end() lcd_send_byte(0,3); delay_ms(2)
|
|
|
470 |
....................
|
|
|
471 |
....................
|
|
|
472 |
.................... // Vlastni vykonne makro pro definovani fontu do pozice Index CGRAM s definicnim retezcem Def
|
|
|
473 |
.................... //
|
|
|
474 |
.................... #define lcd_define_char(Index, Def) lcd_define_start(Index); lcd_define_def(Def); lcd_define_end();
|
|
|
475 |
....................
|
|
|
476 |
....................
|
|
|
477 |
.................... // Pripravene definice fontu vybranych znaku
|
|
|
478 |
.................... // V tabulce nesmi byt 00 (konec retezce v printf()), misto toho davame 80
|
|
|
479 |
.................... //
|
|
|
480 |
.................... #define LCD_CHAR_BAT100 "\x0E\x1F\x1F\x1F\x1F\x1F\x1F\x1F" /* symbol plne baterie */
|
|
|
481 |
.................... #define LCD_CHAR_BAT50 "\x0E\x1F\x11\x11\x13\x17\x1F\x1F" /* symbol polovicni baterie */
|
|
|
482 |
.................... #define LCD_CHAR_BAT0 "\x0E\x1F\x11\x11\x11\x11\x11\x1F" /* symbol vybite baterie */
|
|
|
483 |
.................... #define LCD_CHAR_UP "\x80\x04\x0E\x15\x04\x04\x04\x80" /* symbol sipka nahoru */
|
|
|
484 |
.................... #define LCD_CHAR_DOWN "\x80\x04\x04\x04\x15\x0E\x04\x80" /* symbol Sipka dolu */
|
|
|
485 |
.................... #define LCD_CHAR_LUA "\x04\x0E\x11\x11\x1F\x11\x11\x80" /* A s carkou */
|
|
|
486 |
.................... #define LCD_CHAR_LLA "\x01\x02\x0E\x01\x1F\x11\x0F\x80" /* a s carkou */
|
|
|
487 |
.................... #define LCD_CHAR_HUC "\x0A\x0E\x11\x10\x10\x11\x0E\x80" /* C s hackem */
|
|
|
488 |
.................... #define LCD_CHAR_HLC "\x0A\x04\x0E\x10\x10\x11\x0E\x80" /* c s hackem */
|
|
|
489 |
.................... #define LCD_CHAR_HUD "\x0A\x1C\x12\x11\x11\x12\x1C\x80" /* D s hackem */
|
|
|
490 |
.................... #define LCD_CHAR_HLD "\x05\x03\x0D\x13\x11\x11\x0F\x80" /* d s hackem */
|
|
|
491 |
.................... #define LCD_CHAR_LUE "\x04\x1F\x10\x10\x1E\x10\x1F\x80" /* E s carkou */
|
|
|
492 |
.................... #define LCD_CHAR_LLE "\x01\x02\x0E\x11\x1F\x10\x0E\x80" /* e s carkou */
|
|
|
493 |
.................... #define LCD_CHAR_HUE "\x0A\x1F\x10\x1E\x10\x10\x1F\x80" /* E s hackem */
|
|
|
494 |
.................... #define LCD_CHAR_HLE "\x0A\x04\x0E\x11\x1F\x10\x0E\x80" /* e s hackem */
|
|
|
495 |
.................... #define LCD_CHAR_LUI "\x04\x0E\x04\x04\x04\x04\x0E\x80" /* I s carkou */
|
|
|
496 |
.................... #define LCD_CHAR_LLI "\x02\x04\x80\x0C\x04\x04\x0E\x80" /* i s carkou */
|
|
|
497 |
.................... #define LCD_CHAR_HUN "\x0A\x15\x11\x19\x15\x13\x11\x80" /* N s hackem */
|
|
|
498 |
.................... #define LCD_CHAR_HLN "\x0A\x04\x16\x19\x11\x11\x11\x80" /* n s hackem */
|
|
|
499 |
.................... #define LCD_CHAR_LUO "\x04\x0E\x11\x11\x11\x11\x0E\x80" /* O s carkou */
|
|
|
500 |
.................... #define LCD_CHAR_LLO "\x02\x04\x0E\x11\x11\x11\x0E\x80" /* o s carkou */
|
|
|
501 |
.................... #define LCD_CHAR_HUR "\x0A\x1E\x11\x1E\x14\x12\x11\x80" /* R s hackem */
|
|
|
502 |
.................... #define LCD_CHAR_HLR "\x0A\x04\x16\x19\x10\x10\x10\x80" /* r s hackem */
|
|
|
503 |
.................... #define LCD_CHAR_HUS "\x0A\x0F\x10\x0E\x01\x01\x1E\x80" /* S s hackem */
|
|
|
504 |
.................... #define LCD_CHAR_HLS "\x0A\x04\x0E\x10\x0E\x01\x1E\x80" /* s s hackem */
|
|
|
505 |
.................... #define LCD_CHAR_HUT "\x0A\x1F\x04\x04\x04\x04\x04\x80" /* T s hackem */
|
|
|
506 |
.................... #define LCD_CHAR_HLT "\x0A\x0C\x1C\x08\x08\x09\x06\x80" /* t s hackem */
|
|
|
507 |
.................... #define LCD_CHAR_LUU "\x02\x15\x11\x11\x11\x11\x0E\x80" /* U s carkou */
|
|
|
508 |
.................... #define LCD_CHAR_LLU "\x02\x04\x11\x11\x11\x13\x0D\x80" /* u s carkou */
|
|
|
509 |
.................... #define LCD_CHAR_CUU "\x06\x17\x11\x11\x11\x11\x0E\x80" /* U s krouzkem */
|
|
|
510 |
.................... #define LCD_CHAR_CLU "\x06\x06\x11\x11\x11\x11\x0E\x80" /* u s krouzkem */
|
|
|
511 |
.................... #define LCD_CHAR_LUY "\x02\x15\x11\x0A\x04\x04\x04\x80" /* Y s carkou */
|
|
|
512 |
.................... #define LCD_CHAR_LLY "\x02\x04\x11\x11\x0F\x01\x0E\x80" /* y s carkou */
|
|
|
513 |
.................... #define LCD_CHAR_HUZ "\x0A\x1F\x01\x02\x04\x08\x1F\x80" /* Z s hackem */
|
|
|
514 |
.................... #define LCD_CHAR_HLZ "\x0A\x04\x1F\x02\x04\x08\x1F\x80" /* z s hackem */
|
|
|
515 |
....................
|
|
|
516 |
....................
|
|
|
517 |
.................... // Priklad pouziti definovanych znaku
|
|
|
518 |
.................... //
|
|
|
519 |
.................... //
|
|
|
520 |
.................... //void lcd_sample()
|
|
|
521 |
.................... //{
|
|
|
522 |
.................... // lcd_define_char(0,LCD_CHAR_BAT50); // Priklad definice znaku baterie do pozice 0
|
|
|
523 |
.................... // lcd_define_char(2,LCD_CHAR_HLE LCD_CHAR_LUI); // Priklad definice znaku e s hackem a I s carkou od pozice 2
|
|
|
524 |
.................... // // vsimnete si, ze neni carka mezi retezci s definici (oba retezce definuji
|
|
|
525 |
.................... // // jediny definicni retezec)
|
|
|
526 |
.................... // printf(lcd_putc,"\fZnaky:\20\22\23"); // priklad vypisu znaku z pozice 0, 2 a 3
|
|
|
527 |
.................... // delay_ms(1000);
|
|
|
528 |
.................... // lcd_define_char(0,LCD_CHAR_BAT0); // Predefinovani tvaru znaku v pozici 0
|
|
|
529 |
.................... // delay_ms(1000);
|
|
|
530 |
.................... //}
|
|
|
531 |
....................
|
|
|
532 |
....................
|
|
|
533 |
.................... #define TRIGGER_PIN PIN_B4
|
|
|
534 |
....................
|
|
|
535 |
.................... #DEFINE DATA PIN_B5 // musi byt definovan kanal DATA
|
|
|
536 |
.................... #DEFINE CLK PIN_B6 // a taky hodiny CLK
|
|
|
537 |
.................... #include "C:\library\kaklik\CCS\ps2.c"
|
|
|
538 |
.................... ////////////////////////////////////////////////////////////////////////////////
|
|
|
539 |
.................... // Modul pro komunikaci s PS/2 mysi
|
|
|
540 |
.................... //
|
|
|
541 |
.................... // #DEFINE DATA PIN_B0 // musi byt definovan kanal DATA
|
|
|
542 |
.................... // #DEFINE CLK PIN_B1 // a taky hodiny CLK
|
|
|
543 |
.................... //
|
|
|
544 |
.................... ////////////////////////////////////////////////////////////////////////////////
|
|
|
545 |
....................
|
|
|
546 |
.................... #define PRVNI 1000 // nastaveni prodlevy pred zacatkem vysilani bajtu
|
|
|
547 |
.................... #define DRUHY 2
|
|
|
548 |
.................... #define TRETI DRUHY
|
|
|
549 |
....................
|
|
|
550 |
.................... // prikazy
|
|
|
551 |
.................... #define RESET 0xFF
|
|
|
552 |
.................... #define ENABLE_DATA_REPORTING 0xF4
|
|
|
553 |
.................... #define READ_DATA 0xEB
|
|
|
554 |
.................... #define STATUS_REQUEST 0xE9
|
|
|
555 |
.................... #define SET_REMOTE_MODE 0xF0
|
|
|
556 |
.................... #define SET_STREAM_MODE 0xEA
|
|
|
557 |
.................... #define GET_DEVICE_ID 0xF2
|
|
|
558 |
....................
|
|
|
559 |
....................
|
|
|
560 |
.................... void send(byte command)
|
|
|
561 |
.................... {
|
|
|
562 |
.................... unsigned int8 n;
|
|
|
563 |
.................... unsigned int8 parity=0;
|
|
|
564 |
*
|
|
|
565 |
00A9: CLRF 2D
|
|
|
566 |
....................
|
|
|
567 |
.................... //Request-to-send
|
|
|
568 |
.................... output_float(DATA);
|
|
|
569 |
00AA: BSF 03.5
|
|
|
570 |
00AB: BSF 06.5
|
|
|
571 |
.................... output_low(CLK);
|
|
|
572 |
00AC: BCF 06.6
|
|
|
573 |
00AD: BCF 03.5
|
|
|
574 |
00AE: BCF 06.6
|
|
|
575 |
.................... delay_us(100);
|
|
|
576 |
00AF: MOVLW 21
|
|
|
577 |
00B0: MOVWF 77
|
|
|
578 |
00B1: DECFSZ 77,F
|
|
|
579 |
00B2: GOTO 0B1
|
|
|
580 |
.................... // start bit
|
|
|
581 |
.................... output_low(DATA);
|
|
|
582 |
00B3: BSF 03.5
|
|
|
583 |
00B4: BCF 06.5
|
|
|
584 |
00B5: BCF 03.5
|
|
|
585 |
00B6: BCF 06.5
|
|
|
586 |
.................... while(input(CLK)); // ceka se na hodiny od mysi (mys zataha za hodiny)
|
|
|
587 |
00B7: BSF 03.5
|
|
|
588 |
00B8: BSF 06.6
|
|
|
589 |
00B9: BCF 03.5
|
|
|
590 |
00BA: BTFSC 06.6
|
|
|
591 |
00BB: GOTO 0B7
|
|
|
592 |
.................... // 8 bitu
|
|
|
593 |
.................... for(n=0; n<8; n++)
|
|
|
594 |
00BC: CLRF 2C
|
|
|
595 |
00BD: MOVF 2C,W
|
|
|
596 |
00BE: SUBLW 07
|
|
|
597 |
00BF: BTFSS 03.0
|
|
|
598 |
00C0: GOTO 0DA
|
|
|
599 |
.................... {
|
|
|
600 |
.................... while(input(CLK));
|
|
|
601 |
00C1: BSF 03.5
|
|
|
602 |
00C2: BSF 06.6
|
|
|
603 |
00C3: BCF 03.5
|
|
|
604 |
00C4: BTFSC 06.6
|
|
|
605 |
00C5: GOTO 0C1
|
|
|
606 |
.................... output_bit(DATA, command & 1);
|
|
|
607 |
00C6: BTFSC 2B.0
|
|
|
608 |
00C7: GOTO 0CA
|
|
|
609 |
00C8: BCF 06.5
|
|
|
610 |
00C9: GOTO 0CB
|
|
|
611 |
00CA: BSF 06.5
|
|
|
612 |
00CB: BSF 03.5
|
|
|
613 |
00CC: BCF 06.5
|
|
|
614 |
.................... parity += command & 1;
|
|
|
615 |
00CD: BCF 03.5
|
|
|
616 |
00CE: MOVF 2B,W
|
|
|
617 |
00CF: ANDLW 01
|
|
|
618 |
00D0: ADDWF 2D,F
|
|
|
619 |
.................... command >>= 1;
|
|
|
620 |
00D1: BCF 03.0
|
|
|
621 |
00D2: RRF 2B,F
|
|
|
622 |
.................... while(!input(CLK));
|
|
|
623 |
00D3: BSF 03.5
|
|
|
624 |
00D4: BSF 06.6
|
|
|
625 |
00D5: BCF 03.5
|
|
|
626 |
00D6: BTFSS 06.6
|
|
|
627 |
00D7: GOTO 0D3
|
|
|
628 |
.................... };
|
|
|
629 |
00D8: INCF 2C,F
|
|
|
630 |
00D9: GOTO 0BD
|
|
|
631 |
.................... // parita
|
|
|
632 |
.................... while(input(CLK));
|
|
|
633 |
00DA: BSF 03.5
|
|
|
634 |
00DB: BSF 06.6
|
|
|
635 |
00DC: BCF 03.5
|
|
|
636 |
00DD: BTFSC 06.6
|
|
|
637 |
00DE: GOTO 0DA
|
|
|
638 |
.................... output_bit(DATA, ~parity & 1);
|
|
|
639 |
00DF: MOVF 2D,W
|
|
|
640 |
00E0: XORLW FF
|
|
|
641 |
00E1: ANDLW 01
|
|
|
642 |
00E2: XORLW 00
|
|
|
643 |
00E3: BTFSS 03.2
|
|
|
644 |
00E4: GOTO 0E7
|
|
|
645 |
00E5: BCF 06.5
|
|
|
646 |
00E6: GOTO 0E8
|
|
|
647 |
00E7: BSF 06.5
|
|
|
648 |
00E8: BSF 03.5
|
|
|
649 |
00E9: BCF 06.5
|
|
|
650 |
.................... while(!input(CLK));
|
|
|
651 |
00EA: BSF 06.6
|
|
|
652 |
00EB: BCF 03.5
|
|
|
653 |
00EC: BTFSC 06.6
|
|
|
654 |
00ED: GOTO 0F0
|
|
|
655 |
00EE: BSF 03.5
|
|
|
656 |
00EF: GOTO 0EA
|
|
|
657 |
....................
|
|
|
658 |
.................... // stop bit
|
|
|
659 |
.................... output_float(DATA);
|
|
|
660 |
00F0: BSF 03.5
|
|
|
661 |
00F1: BSF 06.5
|
|
|
662 |
.................... while(input(DATA)); // mys musi sama jeste jednou zatahat za hodiny a data
|
|
|
663 |
00F2: BSF 06.5
|
|
|
664 |
00F3: BCF 03.5
|
|
|
665 |
00F4: BTFSS 06.5
|
|
|
666 |
00F5: GOTO 0F8
|
|
|
667 |
00F6: BSF 03.5
|
|
|
668 |
00F7: GOTO 0F2
|
|
|
669 |
.................... while(input(CLK));
|
|
|
670 |
00F8: BSF 03.5
|
|
|
671 |
00F9: BSF 06.6
|
|
|
672 |
00FA: BCF 03.5
|
|
|
673 |
00FB: BTFSC 06.6
|
|
|
674 |
00FC: GOTO 0F8
|
|
|
675 |
....................
|
|
|
676 |
.................... // ceka se az nastane klidovy stav
|
|
|
677 |
.................... while(!input(CLK) || !input(DATA));
|
|
|
678 |
00FD: BSF 03.5
|
|
|
679 |
00FE: BSF 06.6
|
|
|
680 |
00FF: BCF 03.5
|
|
|
681 |
0100: BTFSS 06.6
|
|
|
682 |
0101: GOTO 0FD
|
|
|
683 |
0102: BSF 03.5
|
|
|
684 |
0103: BSF 06.5
|
|
|
685 |
0104: BCF 03.5
|
|
|
686 |
0105: BTFSS 06.5
|
|
|
687 |
0106: GOTO 0FD
|
|
|
688 |
.................... }
|
|
|
689 |
0107: RETLW 00
|
|
|
690 |
....................
|
|
|
691 |
....................
|
|
|
692 |
.................... int8 read_byte() // dodelat paritu
|
|
|
693 |
.................... {
|
|
|
694 |
.................... unsigned int8 bajt;
|
|
|
695 |
.................... unsigned int8 i;
|
|
|
696 |
.................... int1 parity=0;
|
|
|
697 |
*
|
|
|
698 |
023A: BCF 35.0
|
|
|
699 |
....................
|
|
|
700 |
.................... // cekani na startbit
|
|
|
701 |
.................... while(input(CLK) || input(DATA)); // oba signaly musi byt v 0
|
|
|
702 |
023B: BSF 03.5
|
|
|
703 |
023C: BSF 06.6
|
|
|
704 |
023D: BCF 03.5
|
|
|
705 |
023E: BTFSC 06.6
|
|
|
706 |
023F: GOTO 23B
|
|
|
707 |
0240: BSF 03.5
|
|
|
708 |
0241: BSF 06.5
|
|
|
709 |
0242: BCF 03.5
|
|
|
710 |
0243: BTFSC 06.5
|
|
|
711 |
0244: GOTO 23B
|
|
|
712 |
.................... while(!input(CLK)); // ceka se na nabeznou hranu hodin
|
|
|
713 |
0245: BSF 03.5
|
|
|
714 |
0246: BSF 06.6
|
|
|
715 |
0247: BCF 03.5
|
|
|
716 |
0248: BTFSS 06.6
|
|
|
717 |
0249: GOTO 245
|
|
|
718 |
....................
|
|
|
719 |
.................... bajt = 0;
|
|
|
720 |
024A: CLRF 33
|
|
|
721 |
.................... for(i=0; i<8; i++)
|
|
|
722 |
024B: CLRF 34
|
|
|
723 |
024C: MOVF 34,W
|
|
|
724 |
024D: SUBLW 07
|
|
|
725 |
024E: BTFSS 03.0
|
|
|
726 |
024F: GOTO 27C
|
|
|
727 |
.................... {
|
|
|
728 |
.................... while(input(CLK)); // ceka na nulu hodin
|
|
|
729 |
0250: BSF 03.5
|
|
|
730 |
0251: BSF 06.6
|
|
|
731 |
0252: BCF 03.5
|
|
|
732 |
0253: BTFSC 06.6
|
|
|
733 |
0254: GOTO 250
|
|
|
734 |
....................
|
|
|
735 |
.................... bajt >>= 1;
|
|
|
736 |
0255: BCF 03.0
|
|
|
737 |
0256: RRF 33,F
|
|
|
738 |
.................... bajt |= input(DATA) << 7; // zapise se stav do promene
|
|
|
739 |
0257: BSF 03.5
|
|
|
740 |
0258: BSF 06.5
|
|
|
741 |
0259: MOVLW 00
|
|
|
742 |
025A: BCF 03.5
|
|
|
743 |
025B: BTFSC 06.5
|
|
|
744 |
025C: MOVLW 01
|
|
|
745 |
025D: MOVWF 77
|
|
|
746 |
025E: RRF 77,W
|
|
|
747 |
025F: CLRF 77
|
|
|
748 |
0260: BTFSC 03.0
|
|
|
749 |
0261: BSF 77.7
|
|
|
750 |
0262: MOVF 77,W
|
|
|
751 |
0263: IORWF 33,F
|
|
|
752 |
.................... parity^=input(DATA);
|
|
|
753 |
0264: MOVLW 00
|
|
|
754 |
0265: BTFSC 35.0
|
|
|
755 |
0266: MOVLW 01
|
|
|
756 |
0267: MOVWF 36
|
|
|
757 |
0268: BSF 03.5
|
|
|
758 |
0269: BSF 06.5
|
|
|
759 |
026A: MOVLW 00
|
|
|
760 |
026B: BCF 03.5
|
|
|
761 |
026C: BTFSC 06.5
|
|
|
762 |
026D: MOVLW 01
|
|
|
763 |
026E: XORWF 36,W
|
|
|
764 |
026F: MOVWF 78
|
|
|
765 |
0270: BTFSC 78.0
|
|
|
766 |
0271: GOTO 274
|
|
|
767 |
0272: BCF 35.0
|
|
|
768 |
0273: GOTO 275
|
|
|
769 |
0274: BSF 35.0
|
|
|
770 |
....................
|
|
|
771 |
.................... while(!input(CLK)); // ceka na jednicku hodin
|
|
|
772 |
0275: BSF 03.5
|
|
|
773 |
0276: BSF 06.6
|
|
|
774 |
0277: BCF 03.5
|
|
|
775 |
0278: BTFSS 06.6
|
|
|
776 |
0279: GOTO 275
|
|
|
777 |
.................... };
|
|
|
778 |
027A: INCF 34,F
|
|
|
779 |
027B: GOTO 24C
|
|
|
780 |
.................... while(input(CLK));
|
|
|
781 |
027C: BSF 03.5
|
|
|
782 |
027D: BSF 06.6
|
|
|
783 |
027E: BCF 03.5
|
|
|
784 |
027F: BTFSC 06.6
|
|
|
785 |
0280: GOTO 27C
|
|
|
786 |
.................... parity^=input(DATA);
|
|
|
787 |
0281: MOVLW 00
|
|
|
788 |
0282: BTFSC 35.0
|
|
|
789 |
0283: MOVLW 01
|
|
|
790 |
0284: MOVWF 36
|
|
|
791 |
0285: BSF 03.5
|
|
|
792 |
0286: BSF 06.5
|
|
|
793 |
0287: MOVLW 00
|
|
|
794 |
0288: BCF 03.5
|
|
|
795 |
0289: BTFSC 06.5
|
|
|
796 |
028A: MOVLW 01
|
|
|
797 |
028B: XORWF 36,W
|
|
|
798 |
028C: MOVWF 78
|
|
|
799 |
028D: BTFSC 78.0
|
|
|
800 |
028E: GOTO 291
|
|
|
801 |
028F: BCF 35.0
|
|
|
802 |
0290: GOTO 292
|
|
|
803 |
0291: BSF 35.0
|
|
|
804 |
.................... // if (parity)
|
|
|
805 |
.................... while(!input(CLK)); // ceka na jednicku hodin
|
|
|
806 |
0292: BSF 03.5
|
|
|
807 |
0293: BSF 06.6
|
|
|
808 |
0294: BCF 03.5
|
|
|
809 |
0295: BTFSS 06.6
|
|
|
810 |
0296: GOTO 292
|
|
|
811 |
.................... while(input(CLK));
|
|
|
812 |
0297: BSF 03.5
|
|
|
813 |
0298: BSF 06.6
|
|
|
814 |
0299: BCF 03.5
|
|
|
815 |
029A: BTFSC 06.6
|
|
|
816 |
029B: GOTO 297
|
|
|
817 |
.................... while(!input(CLK)); // ceka na jednicku hodin
|
|
|
818 |
029C: BSF 03.5
|
|
|
819 |
029D: BSF 06.6
|
|
|
820 |
029E: BCF 03.5
|
|
|
821 |
029F: BTFSS 06.6
|
|
|
822 |
02A0: GOTO 29C
|
|
|
823 |
.................... return (bajt);
|
|
|
824 |
02A1: MOVF 33,W
|
|
|
825 |
02A2: MOVWF 78
|
|
|
826 |
.................... }
|
|
|
827 |
02A3: RETLW 00
|
|
|
828 |
....................
|
|
|
829 |
....................
|
|
|
830 |
.................... void read_standard_byte(signed int8 *x,*y,unsigned int8 *tl1,*tl2,*tl3)
|
|
|
831 |
.................... {
|
|
|
832 |
.................... unsigned int8 st,nd,rd;
|
|
|
833 |
....................
|
|
|
834 |
.................... st = read_byte();
|
|
|
835 |
02A4: CALL 23A
|
|
|
836 |
02A5: MOVF 78,W
|
|
|
837 |
02A6: MOVWF 30
|
|
|
838 |
.................... nd = read_byte();
|
|
|
839 |
02A7: CALL 23A
|
|
|
840 |
02A8: MOVF 78,W
|
|
|
841 |
02A9: MOVWF 31
|
|
|
842 |
.................... rd = read_byte();
|
|
|
843 |
02AA: CALL 23A
|
|
|
844 |
02AB: MOVF 78,W
|
|
|
845 |
02AC: MOVWF 32
|
|
|
846 |
....................
|
|
|
847 |
.................... if ((st & 0b1000) == 0b1000) *x=-nd; else *x=nd;
|
|
|
848 |
02AD: MOVF 30,W
|
|
|
849 |
02AE: ANDLW 08
|
|
|
850 |
02AF: SUBLW 08
|
|
|
851 |
02B0: BTFSS 03.2
|
|
|
852 |
02B1: GOTO 2B8
|
|
|
853 |
02B2: MOVF 2B,W
|
|
|
854 |
02B3: MOVWF 04
|
|
|
855 |
02B4: MOVF 31,W
|
|
|
856 |
02B5: SUBLW 00
|
|
|
857 |
02B6: MOVWF 00
|
|
|
858 |
02B7: GOTO 2BC
|
|
|
859 |
02B8: MOVF 2B,W
|
|
|
860 |
02B9: MOVWF 04
|
|
|
861 |
02BA: MOVF 31,W
|
|
|
862 |
02BB: MOVWF 00
|
|
|
863 |
.................... if ((st & 0b10000) == 0b10000) *y=-rd; else *y=rd;
|
|
|
864 |
02BC: MOVF 30,W
|
|
|
865 |
02BD: ANDLW 10
|
|
|
866 |
02BE: SUBLW 10
|
|
|
867 |
02BF: BTFSS 03.2
|
|
|
868 |
02C0: GOTO 2C7
|
|
|
869 |
02C1: MOVF 2C,W
|
|
|
870 |
02C2: MOVWF 04
|
|
|
871 |
02C3: MOVF 32,W
|
|
|
872 |
02C4: SUBLW 00
|
|
|
873 |
02C5: MOVWF 00
|
|
|
874 |
02C6: GOTO 2CB
|
|
|
875 |
02C7: MOVF 2C,W
|
|
|
876 |
02C8: MOVWF 04
|
|
|
877 |
02C9: MOVF 32,W
|
|
|
878 |
02CA: MOVWF 00
|
|
|
879 |
....................
|
|
|
880 |
.................... *tl1=st & 1;
|
|
|
881 |
02CB: MOVF 2D,W
|
|
|
882 |
02CC: MOVWF 04
|
|
|
883 |
02CD: MOVF 30,W
|
|
|
884 |
02CE: ANDLW 01
|
|
|
885 |
02CF: MOVWF 00
|
|
|
886 |
.................... *tl2=(st >> 1) & 1;
|
|
|
887 |
02D0: MOVF 2E,W
|
|
|
888 |
02D1: MOVWF 04
|
|
|
889 |
02D2: BCF 03.0
|
|
|
890 |
02D3: RRF 30,W
|
|
|
891 |
02D4: ANDLW 01
|
|
|
892 |
02D5: MOVWF 00
|
|
|
893 |
.................... *tl3=(st >> 2) & 1;
|
|
|
894 |
02D6: MOVF 2F,W
|
|
|
895 |
02D7: MOVWF 04
|
|
|
896 |
02D8: RRF 30,W
|
|
|
897 |
02D9: MOVWF 77
|
|
|
898 |
02DA: RRF 77,F
|
|
|
899 |
02DB: MOVLW 3F
|
|
|
900 |
02DC: ANDWF 77,F
|
|
|
901 |
02DD: MOVF 77,W
|
|
|
902 |
02DE: ANDLW 01
|
|
|
903 |
02DF: MOVWF 00
|
|
|
904 |
.................... }
|
|
|
905 |
02E0: BCF 0A.3
|
|
|
906 |
02E1: GOTO 3A5 (RETURN)
|
|
|
907 |
.................... void ps2break()
|
|
|
908 |
.................... {
|
|
|
909 |
.................... output_low(CLK);
|
|
|
910 |
.................... }
|
|
|
911 |
.................... void ps2enable()
|
|
|
912 |
.................... {
|
|
|
913 |
.................... output_float(CLK);
|
|
|
914 |
.................... }
|
|
|
915 |
....................
|
|
|
916 |
....................
|
|
|
917 |
....................
|
|
|
918 |
....................
|
|
|
919 |
.................... void trigger()
|
|
|
920 |
.................... {
|
|
|
921 |
.................... output_high(TRIGGER_PIN);
|
|
|
922 |
.................... delay_us(50);
|
|
|
923 |
.................... output_low(TRIGGER_PIN);
|
|
|
924 |
.................... }
|
|
|
925 |
....................
|
|
|
926 |
.................... void main()
|
|
|
927 |
.................... {
|
|
|
928 |
02E2: CLRF 04
|
|
|
929 |
02E3: MOVLW 1F
|
|
|
930 |
02E4: ANDWF 03,F
|
|
|
931 |
02E5: BSF 03.5
|
|
|
932 |
02E6: BCF 1F.4
|
|
|
933 |
02E7: BCF 1F.5
|
|
|
934 |
02E8: MOVF 1B,W
|
|
|
935 |
02E9: ANDLW 80
|
|
|
936 |
02EA: MOVWF 1B
|
|
|
937 |
02EB: MOVLW 07
|
|
|
938 |
02EC: MOVWF 1C
|
|
|
939 |
02ED: MOVF 1C,W
|
|
|
940 |
02EE: BCF 03.5
|
|
|
941 |
02EF: BCF 0D.6
|
|
|
942 |
02F0: MOVLW 60
|
|
|
943 |
02F1: BSF 03.5
|
|
|
944 |
02F2: MOVWF 0F
|
|
|
945 |
.................... signed int16 x=0,y=0;
|
|
|
946 |
02F3: BCF 03.5
|
|
|
947 |
02F4: CLRF 21
|
|
|
948 |
02F5: CLRF 22
|
|
|
949 |
02F6: CLRF 23
|
|
|
950 |
02F7: CLRF 24
|
|
|
951 |
.................... signed int8 hodnota,dx,dy;
|
|
|
952 |
.................... unsigned int8 tl1,tl2,tl3;
|
|
|
953 |
....................
|
|
|
954 |
.................... setup_adc_ports(NO_ANALOGS|VSS_VDD);
|
|
|
955 |
02F8: BSF 03.5
|
|
|
956 |
02F9: BCF 1F.4
|
|
|
957 |
02FA: BCF 1F.5
|
|
|
958 |
02FB: MOVF 1B,W
|
|
|
959 |
02FC: ANDLW 80
|
|
|
960 |
02FD: MOVWF 1B
|
|
|
961 |
.................... setup_adc(ADC_OFF);
|
|
|
962 |
02FE: BCF 03.5
|
|
|
963 |
02FF: BCF 1F.0
|
|
|
964 |
.................... setup_spi(FALSE);
|
|
|
965 |
0300: BCF 14.5
|
|
|
966 |
0301: BSF 03.5
|
|
|
967 |
0302: BCF 06.2
|
|
|
968 |
0303: BSF 06.1
|
|
|
969 |
0304: BCF 06.4
|
|
|
970 |
0305: MOVLW 00
|
|
|
971 |
0306: BCF 03.5
|
|
|
972 |
0307: MOVWF 14
|
|
|
973 |
0308: BSF 03.5
|
|
|
974 |
0309: MOVWF 14
|
|
|
975 |
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
|
|
|
976 |
030A: MOVF 01,W
|
|
|
977 |
030B: ANDLW C7
|
|
|
978 |
030C: IORLW 08
|
|
|
979 |
030D: MOVWF 01
|
|
|
980 |
.................... setup_timer_1(T1_DISABLED);
|
|
|
981 |
030E: BCF 03.5
|
|
|
982 |
030F: CLRF 10
|
|
|
983 |
.................... setup_timer_2(T2_DISABLED,0,1);
|
|
|
984 |
0310: MOVLW 00
|
|
|
985 |
0311: MOVWF 78
|
|
|
986 |
0312: MOVWF 12
|
|
|
987 |
0313: MOVLW 00
|
|
|
988 |
0314: BSF 03.5
|
|
|
989 |
0315: MOVWF 12
|
|
|
990 |
.................... setup_comparator(NC_NC_NC_NC);
|
|
|
991 |
0316: MOVLW 07
|
|
|
992 |
0317: MOVWF 1C
|
|
|
993 |
0318: MOVF 05,W
|
|
|
994 |
0319: MOVLW 03
|
|
|
995 |
031A: MOVWF 77
|
|
|
996 |
031B: DECFSZ 77,F
|
|
|
997 |
031C: GOTO 31B
|
|
|
998 |
031D: MOVF 1C,W
|
|
|
999 |
031E: BCF 03.5
|
|
|
1000 |
031F: BCF 0D.6
|
|
|
1001 |
.................... setup_vref(FALSE);
|
|
|
1002 |
0320: BSF 03.5
|
|
|
1003 |
0321: CLRF 1D
|
|
|
1004 |
....................
|
|
|
1005 |
.................... lcd_init();
|
|
|
1006 |
0322: BCF 03.5
|
|
|
1007 |
0323: GOTO 06F
|
|
|
1008 |
.................... Delay_ms(500);
|
|
|
1009 |
0324: MOVLW 02
|
|
|
1010 |
0325: MOVWF 2B
|
|
|
1011 |
0326: MOVLW FA
|
|
|
1012 |
0327: MOVWF 34
|
|
|
1013 |
0328: CALL 033
|
|
|
1014 |
0329: DECFSZ 2B,F
|
|
|
1015 |
032A: GOTO 326
|
|
|
1016 |
....................
|
|
|
1017 |
.................... send(SET_REMOTE_MODE);
|
|
|
1018 |
032B: MOVLW F0
|
|
|
1019 |
032C: MOVWF 2B
|
|
|
1020 |
032D: CALL 0A9
|
|
|
1021 |
....................
|
|
|
1022 |
.................... while (true)
|
|
|
1023 |
.................... {
|
|
|
1024 |
.................... LCD_gotoxy(1,1);
|
|
|
1025 |
032E: MOVLW 01
|
|
|
1026 |
032F: MOVWF 34
|
|
|
1027 |
0330: MOVWF 35
|
|
|
1028 |
0331: CALL 108
|
|
|
1029 |
.................... printf(lcd_putc,"%X X=%ld Y=%ld TL1=%U TL2=%U TL3=%U",hodnota, x,y,tl1,tl2,tl3);
|
|
|
1030 |
0332: MOVF 25,W
|
|
|
1031 |
0333: MOVWF 2B
|
|
|
1032 |
0334: MOVLW 37
|
|
|
1033 |
0335: MOVWF 2C
|
|
|
1034 |
0336: GOTO 14C
|
|
|
1035 |
0337: MOVLW 20
|
|
|
1036 |
0338: MOVWF 33
|
|
|
1037 |
0339: CALL 119
|
|
|
1038 |
033A: MOVLW 58
|
|
|
1039 |
033B: MOVWF 33
|
|
|
1040 |
033C: CALL 119
|
|
|
1041 |
033D: MOVLW 3D
|
|
|
1042 |
033E: MOVWF 33
|
|
|
1043 |
033F: CALL 119
|
|
|
1044 |
0340: MOVLW 10
|
|
|
1045 |
0341: MOVWF 04
|
|
|
1046 |
0342: MOVF 22,W
|
|
|
1047 |
0343: MOVWF 2C
|
|
|
1048 |
0344: MOVF 21,W
|
|
|
1049 |
0345: MOVWF 2B
|
|
|
1050 |
0346: CALL 16E
|
|
|
1051 |
0347: MOVLW 20
|
|
|
1052 |
0348: MOVWF 33
|
|
|
1053 |
0349: CALL 119
|
|
|
1054 |
034A: MOVLW 59
|
|
|
1055 |
034B: MOVWF 33
|
|
|
1056 |
034C: CALL 119
|
|
|
1057 |
034D: MOVLW 3D
|
|
|
1058 |
034E: MOVWF 33
|
|
|
1059 |
034F: CALL 119
|
|
|
1060 |
0350: MOVLW 10
|
|
|
1061 |
0351: MOVWF 04
|
|
|
1062 |
0352: MOVF 24,W
|
|
|
1063 |
0353: MOVWF 2C
|
|
|
1064 |
0354: MOVF 23,W
|
|
|
1065 |
0355: MOVWF 2B
|
|
|
1066 |
0356: CALL 16E
|
|
|
1067 |
0357: MOVLW 0E
|
|
|
1068 |
0358: MOVWF 2B
|
|
|
1069 |
0359: MOVF 2B,W
|
|
|
1070 |
035A: CALL 00C
|
|
|
1071 |
035B: INCF 2B,F
|
|
|
1072 |
035C: MOVWF 77
|
|
|
1073 |
035D: MOVWF 33
|
|
|
1074 |
035E: CALL 119
|
|
|
1075 |
035F: MOVLW 13
|
|
|
1076 |
0360: SUBWF 2B,W
|
|
|
1077 |
0361: BTFSS 03.2
|
|
|
1078 |
0362: GOTO 359
|
|
|
1079 |
0363: MOVF 28,W
|
|
|
1080 |
0364: MOVWF 2F
|
|
|
1081 |
0365: MOVLW 18
|
|
|
1082 |
0366: MOVWF 30
|
|
|
1083 |
0367: CALL 1ED
|
|
|
1084 |
0368: MOVLW 03
|
|
|
1085 |
0369: MOVWF 2C
|
|
|
1086 |
036A: MOVLW 20
|
|
|
1087 |
036B: MOVWF 33
|
|
|
1088 |
036C: CALL 119
|
|
|
1089 |
036D: DECFSZ 2C,F
|
|
|
1090 |
036E: GOTO 36A
|
|
|
1091 |
036F: MOVLW 15
|
|
|
1092 |
0370: MOVWF 2D
|
|
|
1093 |
0371: MOVF 2D,W
|
|
|
1094 |
0372: CALL 00C
|
|
|
1095 |
0373: INCF 2D,F
|
|
|
1096 |
0374: MOVWF 77
|
|
|
1097 |
0375: MOVWF 33
|
|
|
1098 |
0376: CALL 119
|
|
|
1099 |
0377: MOVLW 19
|
|
|
1100 |
0378: SUBWF 2D,W
|
|
|
1101 |
0379: BTFSS 03.2
|
|
|
1102 |
037A: GOTO 371
|
|
|
1103 |
037B: MOVF 29,W
|
|
|
1104 |
037C: MOVWF 2F
|
|
|
1105 |
037D: MOVLW 18
|
|
|
1106 |
037E: MOVWF 30
|
|
|
1107 |
037F: CALL 1ED
|
|
|
1108 |
0380: MOVLW 1B
|
|
|
1109 |
0381: MOVWF 2E
|
|
|
1110 |
0382: MOVF 2E,W
|
|
|
1111 |
0383: CALL 00C
|
|
|
1112 |
0384: INCF 2E,F
|
|
|
1113 |
0385: MOVWF 77
|
|
|
1114 |
0386: MOVWF 33
|
|
|
1115 |
0387: CALL 119
|
|
|
1116 |
0388: MOVLW 20
|
|
|
1117 |
0389: SUBWF 2E,W
|
|
|
1118 |
038A: BTFSS 03.2
|
|
|
1119 |
038B: GOTO 382
|
|
|
1120 |
038C: MOVF 2A,W
|
|
|
1121 |
038D: MOVWF 2F
|
|
|
1122 |
038E: MOVLW 18
|
|
|
1123 |
038F: MOVWF 30
|
|
|
1124 |
0390: CALL 1ED
|
|
|
1125 |
.................... delay_ms(20);
|
|
|
1126 |
0391: MOVLW 14
|
|
|
1127 |
0392: MOVWF 34
|
|
|
1128 |
0393: CALL 033
|
|
|
1129 |
.................... send(READ_DATA);
|
|
|
1130 |
0394: MOVLW EB
|
|
|
1131 |
0395: MOVWF 2B
|
|
|
1132 |
0396: CALL 0A9
|
|
|
1133 |
.................... hodnota=read_byte();
|
|
|
1134 |
0397: CALL 23A
|
|
|
1135 |
0398: MOVF 78,W
|
|
|
1136 |
0399: MOVWF 25
|
|
|
1137 |
.................... read_standard_byte(&dx,&dy,&tl1,&tl2,&tl3);
|
|
|
1138 |
039A: MOVLW 26
|
|
|
1139 |
039B: MOVWF 2B
|
|
|
1140 |
039C: MOVLW 27
|
|
|
1141 |
039D: MOVWF 2C
|
|
|
1142 |
039E: MOVLW 28
|
|
|
1143 |
039F: MOVWF 2D
|
|
|
1144 |
03A0: MOVLW 29
|
|
|
1145 |
03A1: MOVWF 2E
|
|
|
1146 |
03A2: MOVLW 2A
|
|
|
1147 |
03A3: MOVWF 2F
|
|
|
1148 |
03A4: GOTO 2A4
|
|
|
1149 |
.................... x+=dx;
|
|
|
1150 |
03A5: CLRF 7A
|
|
|
1151 |
03A6: MOVF 26,W
|
|
|
1152 |
03A7: BTFSC 26.7
|
|
|
1153 |
03A8: DECF 7A,F
|
|
|
1154 |
03A9: ADDWF 21,F
|
|
|
1155 |
03AA: BTFSC 03.0
|
|
|
1156 |
03AB: INCF 22,F
|
|
|
1157 |
03AC: MOVF 7A,W
|
|
|
1158 |
03AD: ADDWF 22,F
|
|
|
1159 |
.................... y+=dy;
|
|
|
1160 |
03AE: CLRF 7A
|
|
|
1161 |
03AF: MOVF 27,W
|
|
|
1162 |
03B0: BTFSC 27.7
|
|
|
1163 |
03B1: DECF 7A,F
|
|
|
1164 |
03B2: ADDWF 23,F
|
|
|
1165 |
03B3: BTFSC 03.0
|
|
|
1166 |
03B4: INCF 24,F
|
|
|
1167 |
03B5: MOVF 7A,W
|
|
|
1168 |
03B6: ADDWF 24,F
|
|
|
1169 |
.................... }
|
|
|
1170 |
03B7: GOTO 32E
|
|
|
1171 |
.................... }
|
|
|
1172 |
....................
|
|
|
1173 |
03B8: SLEEP
|
|
|
1174 |
|
|
|
1175 |
Configuration Fuses:
|
|
|
1176 |
Word 1: 3F78 NOWDT NOPUT MCLR BROWNOUT NOLVP NOCPD NOWRT NODEBUG CCPB0 NOPROTECT INTRC_IO
|
|
|
1177 |
Word 2: 3FFF FCMEN IESO
|