193 |
miho |
1 |
CCS PCW C Compiler, Version 3.110, 15448 |
|
|
2 |
|
|
|
3 |
Filename: c:\miho_dat\dart\lcd_term\lcd_term.LST |
|
|
4 |
|
|
|
5 |
ROM used: 422 (41%) |
|
|
6 |
Largest free fragment is 602 |
|
|
7 |
RAM used: 52 (76%) at main() level |
|
|
8 |
65 (96%) worst case |
|
|
9 |
Stack: 6 worst case (4 in main + 2 for interrupts) |
|
|
10 |
|
|
|
11 |
* |
|
|
12 |
0000: MOVLW 00 |
|
|
13 |
0001: MOVWF 0A |
|
|
14 |
0002: GOTO 158 |
|
|
15 |
0003: NOP |
|
|
16 |
0004: BTFSC 03.5 |
|
|
17 |
0005: GOTO 00A |
|
|
18 |
0006: MOVWF 0E |
|
|
19 |
0007: SWAPF 03,W |
|
|
20 |
0008: MOVWF 0F |
|
|
21 |
0009: GOTO 00F |
|
|
22 |
000A: BCF 03.5 |
|
|
23 |
000B: MOVWF 0E |
|
|
24 |
000C: SWAPF 03,W |
|
|
25 |
000D: MOVWF 0F |
|
|
26 |
000E: BSF 0F.1 |
|
|
27 |
000F: MOVF 0A,W |
|
|
28 |
0010: MOVWF 13 |
|
|
29 |
0011: CLRF 0A |
|
|
30 |
0012: BCF 03.7 |
|
|
31 |
0013: SWAPF 0E,F |
|
|
32 |
0014: MOVF 04,W |
|
|
33 |
0015: MOVWF 10 |
|
|
34 |
0016: MOVF 0C,W |
|
|
35 |
0017: MOVWF 11 |
|
|
36 |
0018: MOVF 0D,W |
|
|
37 |
0019: MOVWF 12 |
|
|
38 |
001A: BCF 03.5 |
|
|
39 |
001B: BTFSS 0B.4 |
|
|
40 |
001C: GOTO 01F |
|
|
41 |
001D: BTFSC 0B.1 |
|
|
42 |
001E: GOTO 07E |
|
|
43 |
001F: MOVF 10,W |
|
|
44 |
0020: MOVWF 04 |
|
|
45 |
0021: MOVF 11,W |
|
|
46 |
0022: MOVWF 0C |
|
|
47 |
0023: MOVF 12,W |
|
|
48 |
0024: MOVWF 0D |
|
|
49 |
0025: MOVF 13,W |
|
|
50 |
0026: MOVWF 0A |
|
|
51 |
0027: SWAPF 0F,W |
|
|
52 |
0028: MOVWF 03 |
|
|
53 |
0029: BCF 03.5 |
|
|
54 |
002A: SWAPF 0E,W |
|
|
55 |
002B: BTFSC 0F.1 |
|
|
56 |
002C: BSF 03.5 |
|
|
57 |
002D: RETFIE |
|
|
58 |
.................... // LCD Terminal pro menic pro solarni vozitko |
|
|
59 |
.................... // (c)miho 2005 |
|
|
60 |
.................... |
|
|
61 |
.................... // Pouziva PIC16F84 (mozno i jakykoli jiny, nepouzivaji se zadne specialni funkce). |
|
|
62 |
.................... // Na vstupnim vyvodu RS_IN ocekava seriovou komunikaci rychlosti RS_BOUD. Pri detekci |
|
|
63 |
.................... // start bitu pomoci preruseni dojde k programovemu prijmu znaku a jeho zarazeni do |
|
|
64 |
.................... // fronty FIFO. Po navratu z preruseni dochazi k vypisu na pripojeny dvouradkovy |
|
|
65 |
.................... // LCD displej. Program zpracovava ridici kody dle knihovny LCD.C. Pri delsich vypisech |
|
|
66 |
.................... // musi vysilajici strana ponechat (obcas) nejaky cas na zpracovani (napriklad 20ms). |
|
|
67 |
.................... |
|
|
68 |
.................... #include <16F84.h> // define standardnich konstant procesoru |
|
|
69 |
.................... //////// Standard Header file for the PIC16F84 device //////////////// |
|
|
70 |
.................... #device PIC16F84 |
|
|
71 |
.................... #list |
|
|
72 |
.................... |
|
|
73 |
.................... #use delay(clock=4000000) // standardni krystal |
|
|
74 |
* |
|
|
75 |
0096: MOVLW 41 |
|
|
76 |
0097: MOVWF 04 |
|
|
77 |
0098: MOVF 00,W |
|
|
78 |
0099: BTFSC 03.2 |
|
|
79 |
009A: GOTO 0AA |
|
|
80 |
009B: MOVLW 01 |
|
|
81 |
009C: MOVWF 0D |
|
|
82 |
009D: CLRF 0C |
|
|
83 |
009E: DECFSZ 0C,F |
|
|
84 |
009F: GOTO 09E |
|
|
85 |
00A0: DECFSZ 0D,F |
|
|
86 |
00A1: GOTO 09D |
|
|
87 |
00A2: MOVLW 4A |
|
|
88 |
00A3: MOVWF 0C |
|
|
89 |
00A4: DECFSZ 0C,F |
|
|
90 |
00A5: GOTO 0A4 |
|
|
91 |
00A6: NOP |
|
|
92 |
00A7: NOP |
|
|
93 |
00A8: DECFSZ 00,F |
|
|
94 |
00A9: GOTO 09B |
|
|
95 |
00AA: RETLW 00 |
|
|
96 |
.................... #fuses HS, NOWDT, NOPUT, NOPROTECT |
|
|
97 |
.................... |
|
|
98 |
.................... |
|
|
99 |
.................... // Parmetry komuniace |
|
|
100 |
.................... // |
|
|
101 |
.................... #define INV // definuje polaritu |
|
|
102 |
.................... #define RS_BOUD 9600 // komunikacni rychlost |
|
|
103 |
.................... #define RS_IN PIN_B0 // musi to byt vstup extrniho preruseni |
|
|
104 |
.................... |
|
|
105 |
.................... |
|
|
106 |
.................... // Pripojeni LCD displeje |
|
|
107 |
.................... // |
|
|
108 |
.................... #define LCD_RS PIN_A0 // rizeni registru LCD displeje |
|
|
109 |
.................... #define LCD_E PIN_A1 // enable LCD displeje |
|
|
110 |
.................... #define LCD_DATA_LSB PIN_B4 // pripojeni LSB bitu datoveho portu LCD displeje (celkem 4 bity vzestupne za sebou) |
|
|
111 |
.................... |
|
|
112 |
.................... #include "LCD.C" |
|
|
113 |
.................... // LCD modul pro ovladani dvouradkoveho LCD modulu se standardnim Hitachi radicem |
|
|
114 |
.................... // (c)miho 2002,2005 |
|
|
115 |
.................... // |
|
|
116 |
.................... // Historie: |
|
|
117 |
.................... // |
|
|
118 |
.................... // 0.00 Uvodni verze se snadnou definici portu LCD displeje |
|
|
119 |
.................... // 0.01 Oprava portu (zapomenute stare identifikatory) |
|
|
120 |
.................... // 0.02 Doplnena moznost pripojeni datoveho portu LCD na libovolne porty |
|
|
121 |
.................... // 0.03 Doplnena procedura lcd_clr pro smazani displeje |
|
|
122 |
.................... // |
|
|
123 |
.................... // |
|
|
124 |
.................... // Funkce: |
|
|
125 |
.................... // |
|
|
126 |
.................... // lcd_init() inicializuje LCD displej a porty, nutno volat jako prvni |
|
|
127 |
.................... // |
|
|
128 |
.................... // lcd_putc(c) zapis snaku do lcd displeje, zpracovava nasledujici ridici znaky |
|
|
129 |
.................... // \f = \x0C - nova stranka - smazani displeje |
|
|
130 |
.................... // \n = \x0A - odradkovani (prechod na druhou radku) |
|
|
131 |
.................... // \b = \x08 - backspace - posunuti kurzoru o 1 pozici zpet |
|
|
132 |
.................... // \r = \x0D - goto home to position 1,1 |
|
|
133 |
.................... // \0 .. \7 - definovatelne znaky v pozicich 0 az 7 v CGRAM |
|
|
134 |
.................... // \20 .. \27 - alternativne zapsane znaky (oktalove) v pozicich 0 az 7 CGRAM |
|
|
135 |
.................... // Pozor na to, ze funkce printf konci tisk pokud narazi na \0 (konec retezce) |
|
|
136 |
.................... // |
|
|
137 |
.................... // lcd_gotoxy(x,y) presune kurzor na uvedenou adresu |
|
|
138 |
.................... // nekontroluje parametry |
|
|
139 |
.................... // |
|
|
140 |
.................... // lcd_cursor_on zapne kurzor |
|
|
141 |
.................... // lcd_cursor_off vypne kurzor |
|
|
142 |
.................... // |
|
|
143 |
.................... // lcd_clr smaze displej |
|
|
144 |
.................... // |
|
|
145 |
.................... // lcd_define_char(Index, Def) Makro, ktere definuje znaky od pozice Index obsahem definicniho |
|
|
146 |
.................... // retezce Def. Kazdych 8 znaku retezce Def definuje dalsi znak v CGRAM. |
|
|
147 |
.................... // Kapacita CGRAM je celkem 8 znaku s indexem 0 az 7. |
|
|
148 |
.................... // Na konci se provede lcd_gotoxy(1,1). |
|
|
149 |
.................... // Na konci teto knihovny je priklad pouziti definovanych znaku |
|
|
150 |
.................... // |
|
|
151 |
.................... // |
|
|
152 |
.................... // Definice portu: // Datovy port displeje pripojeny na 4 bity za sebou na jeden port |
|
|
153 |
.................... // |
|
|
154 |
.................... // #define LCD_RS PIN_B2 // rizeni registru LCD displeje |
|
|
155 |
.................... // #define LCD_E PIN_B1 // enable LCD displeje |
|
|
156 |
.................... // #define LCD_DATA_LSB PIN_C2 // pripojeni LSB bitu datoveho portu LCD displeje (celkem 4 bity vzestupne za sebou) |
|
|
157 |
.................... // |
|
|
158 |
.................... // |
|
|
159 |
.................... // Alternativni definice: // Datovy port displeje pripojeny na libovolne 4 bitove porty (vede na kod delsi asi o 25 slov) |
|
|
160 |
.................... // |
|
|
161 |
.................... // #define LCD_RS PIN_B2 // rizeni registru LCD displeje |
|
|
162 |
.................... // #define LCD_E PIN_B1 // enable LCD displeje |
|
|
163 |
.................... // #define LCD_D0 PIN_C2 // D0 - datove bity pripojene na libovolne porty |
|
|
164 |
.................... // #define LCD_D1 PIN_C3 // D1 |
|
|
165 |
.................... // #define LCD_D2 PIN_C4 // D2 |
|
|
166 |
.................... // #define LCD_D3 PIN_C5 // D3 |
|
|
167 |
.................... |
|
|
168 |
.................... |
|
|
169 |
.................... |
|
|
170 |
.................... |
|
|
171 |
.................... // Privatni sekce, cist jen v pripade, ze neco nefunguje |
|
|
172 |
.................... |
|
|
173 |
.................... |
|
|
174 |
.................... |
|
|
175 |
.................... |
|
|
176 |
.................... #ifdef LCD_DATA_LSB |
|
|
177 |
.................... // Generovane defince portu pro ucely teto knihovny aby kod generoval spravne IO operace a soucasne |
|
|
178 |
.................... // bylo mozne jednoduse deklarovat pripojene piny LCD displeje pri pouziti teto knihovny. Problem spociva |
|
|
179 |
.................... // v tom, ze se musi spravne ridit smery portu a soucasne datovy port zabira jen 4 bity ze zadaneho portu |
|
|
180 |
.................... // |
|
|
181 |
.................... #define LCD_SHIFT (LCD_DATA_LSB&7) // pocet bitu posuvu datoveho kanalu v datovem portu |
|
|
182 |
.................... #define LCD_PORT (LCD_DATA_LSB>>3) // adresa LCD datoveho portu |
|
|
183 |
.................... #define LCD_TRIS (LCD_PORT+0x80) // adresa prislusneho TRIS registru |
|
|
184 |
.................... #define LCD_MASK (0xF<<LCD_SHIFT) // maska platnych bitu |
|
|
185 |
.................... // |
|
|
186 |
.................... #if LCD_SHIFT>4 // kontrola mezi |
|
|
187 |
.................... #error LCD data port LSB bit not in range 0..4 |
|
|
188 |
.................... #endif |
|
|
189 |
.................... #endif |
|
|
190 |
.................... |
|
|
191 |
.................... |
|
|
192 |
.................... // Definice konstant pro LCD display |
|
|
193 |
.................... // |
|
|
194 |
.................... #define LCD_CURSOR_ON_ 0x0E // kurzor jako blikajici radka pod znakem |
|
|
195 |
.................... #define LCD_CURSOR_OFF_ 0x0C // zadny kurzor |
|
|
196 |
.................... #define LCD_LINE_2 0x40 // adresa 1. znaku 2. radky |
|
|
197 |
.................... |
|
|
198 |
.................... |
|
|
199 |
.................... // Definice rezimu LCD displeje |
|
|
200 |
.................... // |
|
|
201 |
.................... BYTE const LCD_INIT_STRING[4] = |
|
|
202 |
.................... { |
|
|
203 |
.................... 0x28, // intrfejs 4 bity, 2 radky, font 5x7 |
|
|
204 |
.................... LCD_CURSOR_OFF_, // display on, kurzor off, |
|
|
205 |
.................... 0x01, // clear displeje |
|
|
206 |
.................... 0x06 // inkrement pozice kurzoru (posun kurzoru doprava) |
|
|
207 |
.................... }; |
|
|
208 |
* |
|
|
209 |
002E: BCF 0A.0 |
|
|
210 |
002F: BCF 0A.1 |
|
|
211 |
0030: BCF 0A.2 |
|
|
212 |
0031: ADDWF 02,F |
|
|
213 |
0032: RETLW 28 |
|
|
214 |
0033: RETLW 0C |
|
|
215 |
0034: RETLW 01 |
|
|
216 |
0035: RETLW 06 |
|
|
217 |
.................... |
|
|
218 |
.................... |
|
|
219 |
.................... // Odesle nibble do displeje (posle data a klikne signalem e) |
|
|
220 |
.................... // |
|
|
221 |
.................... void lcd_send_nibble( BYTE n ) |
|
|
222 |
.................... { |
|
|
223 |
.................... #ifdef LCD_DATA_LSB |
|
|
224 |
.................... // data jsou za sebou na 4 bitech jednoho portu |
|
|
225 |
.................... *LCD_PORT = (*LCD_PORT & ~LCD_MASK) | ((n << LCD_SHIFT) & LCD_MASK); // nastav datove bity portu a ostatni zachovej |
|
|
226 |
* |
|
|
227 |
00AB: MOVF 06,W |
|
|
228 |
00AC: ANDLW 0F |
|
|
229 |
00AD: MOVWF 48 |
|
|
230 |
00AE: SWAPF 47,W |
|
|
231 |
00AF: MOVWF 0C |
|
|
232 |
00B0: MOVLW F0 |
|
|
233 |
00B1: ANDWF 0C,F |
|
|
234 |
00B2: MOVF 0C,W |
|
|
235 |
00B3: ANDLW F0 |
|
|
236 |
00B4: IORWF 48,W |
|
|
237 |
00B5: MOVWF 06 |
|
|
238 |
.................... #else |
|
|
239 |
.................... // data jsou na libovolnych 4 bitech libovolnych portu |
|
|
240 |
.................... output_bit(LCD_D0,bit_test(n,0)); |
|
|
241 |
.................... output_bit(LCD_D1,bit_test(n,1)); |
|
|
242 |
.................... output_bit(LCD_D2,bit_test(n,2)); |
|
|
243 |
.................... output_bit(LCD_D3,bit_test(n,3)); |
|
|
244 |
.................... #endif |
|
|
245 |
.................... output_bit(LCD_E,1); // vzestupna hrana |
|
|
246 |
00B6: BSF 05.1 |
|
|
247 |
00B7: BSF 03.5 |
|
|
248 |
00B8: BCF 05.1 |
|
|
249 |
.................... delay_us(1); // pockej alespon 450ns od e nebo alespon 195ns od dat |
|
|
250 |
00B9: NOP |
|
|
251 |
.................... output_bit(LCD_E,0); // sestupna hrana (minimalni perioda e je 1us) |
|
|
252 |
00BA: BCF 03.5 |
|
|
253 |
00BB: BCF 05.1 |
|
|
254 |
00BC: BSF 03.5 |
|
|
255 |
00BD: BCF 05.1 |
|
|
256 |
00BE: BCF 03.5 |
|
|
257 |
00BF: RETLW 00 |
|
|
258 |
.................... } |
|
|
259 |
.................... |
|
|
260 |
.................... |
|
|
261 |
.................... // Odesle bajt do registru LCD |
|
|
262 |
.................... // |
|
|
263 |
.................... // Pokud je Adr=0 .. instrukcni registr |
|
|
264 |
.................... // Pokud je Adr=1 .. datovy registr |
|
|
265 |
.................... // |
|
|
266 |
.................... void lcd_send_byte( BOOLEAN Adr, BYTE n ) |
|
|
267 |
.................... { |
|
|
268 |
.................... output_bit(LCD_RS,Adr); // vyber registr |
|
|
269 |
00C0: MOVF 45,F |
|
|
270 |
00C1: BTFSS 03.2 |
|
|
271 |
00C2: GOTO 0C5 |
|
|
272 |
00C3: BCF 05.0 |
|
|
273 |
00C4: GOTO 0C6 |
|
|
274 |
00C5: BSF 05.0 |
|
|
275 |
00C6: BSF 03.5 |
|
|
276 |
00C7: BCF 05.0 |
|
|
277 |
.................... swap(n); |
|
|
278 |
00C8: BCF 03.5 |
|
|
279 |
00C9: SWAPF 46,F |
|
|
280 |
.................... lcd_send_nibble(n); // posli horni pulku bajtu |
|
|
281 |
00CA: MOVF 46,W |
|
|
282 |
00CB: MOVWF 47 |
|
|
283 |
00CC: CALL 0AB |
|
|
284 |
.................... swap(n); |
|
|
285 |
00CD: SWAPF 46,F |
|
|
286 |
.................... lcd_send_nibble(n); // posli spodni pulku bajtu |
|
|
287 |
00CE: MOVF 46,W |
|
|
288 |
00CF: MOVWF 47 |
|
|
289 |
00D0: CALL 0AB |
|
|
290 |
.................... delay_us(40); // minimalni doba na provedeni prikazu |
|
|
291 |
00D1: MOVLW 0D |
|
|
292 |
00D2: MOVWF 0C |
|
|
293 |
00D3: DECFSZ 0C,F |
|
|
294 |
00D4: GOTO 0D3 |
|
|
295 |
00D5: RETLW 00 |
|
|
296 |
.................... } |
|
|
297 |
.................... |
|
|
298 |
.................... |
|
|
299 |
.................... // Provede inicializaci LCD displeje, smaze obsah a nastavi mod displeje |
|
|
300 |
.................... // |
|
|
301 |
.................... // Tato procedura se musi volat pred pouzitim ostatnich lcd_ procedur |
|
|
302 |
.................... // |
|
|
303 |
.................... void lcd_init() |
|
|
304 |
.................... { |
|
|
305 |
.................... |
|
|
306 |
.................... int i; // pocitadlo cyklu |
|
|
307 |
.................... |
|
|
308 |
.................... delay_ms(20); // spozdeni pro provedeni startu displeje po zapnuti napajeni |
|
|
309 |
00D6: MOVLW 14 |
|
|
310 |
00D7: MOVWF 41 |
|
|
311 |
00D8: CALL 096 |
|
|
312 |
.................... |
|
|
313 |
.................... #ifdef LCD_DATA_LSB |
|
|
314 |
.................... // data jsou na 4 bitech za sebou, nastav smer pro vsechny dalsi prenosy |
|
|
315 |
.................... *LCD_TRIS = *LCD_TRIS & ~LCD_MASK; // nuluj odpovidajici bity tris registru datoveho portu LCD |
|
|
316 |
00D9: MOVLW 0F |
|
|
317 |
00DA: BSF 03.5 |
|
|
318 |
00DB: ANDWF 06,F |
|
|
319 |
.................... #endif |
|
|
320 |
.................... |
|
|
321 |
.................... output_bit(LCD_RS,0); // nastav jako vystup a nastav klidovy stav |
|
|
322 |
00DC: BCF 03.5 |
|
|
323 |
00DD: BCF 05.0 |
|
|
324 |
00DE: BSF 03.5 |
|
|
325 |
00DF: BCF 05.0 |
|
|
326 |
.................... output_bit(LCD_E, 0); // nastav jako vystup a nastav klidovy stav |
|
|
327 |
00E0: BCF 03.5 |
|
|
328 |
00E1: BCF 05.1 |
|
|
329 |
00E2: BSF 03.5 |
|
|
330 |
00E3: BCF 05.1 |
|
|
331 |
.................... |
|
|
332 |
.................... for (i=0; i<3; i++) // nastav lcd do rezimu 8 bitu sbernice |
|
|
333 |
00E4: BCF 03.5 |
|
|
334 |
00E5: CLRF 3F |
|
|
335 |
00E6: MOVF 3F,W |
|
|
336 |
00E7: SUBLW 02 |
|
|
337 |
00E8: BTFSS 03.0 |
|
|
338 |
00E9: GOTO 0F2 |
|
|
339 |
.................... { |
|
|
340 |
.................... delay_ms(2); // muze byt rozdelany prenos dat (2x 4 bity) nebo pomaly povel |
|
|
341 |
00EA: MOVLW 02 |
|
|
342 |
00EB: MOVWF 41 |
|
|
343 |
00EC: CALL 096 |
|
|
344 |
.................... lcd_send_nibble(3); // rezim 8 bitu |
|
|
345 |
00ED: MOVLW 03 |
|
|
346 |
00EE: MOVWF 47 |
|
|
347 |
00EF: CALL 0AB |
|
|
348 |
.................... } |
|
|
349 |
00F0: INCF 3F,F |
|
|
350 |
00F1: GOTO 0E6 |
|
|
351 |
.................... |
|
|
352 |
.................... delay_us(40); // cas na zpracovani |
|
|
353 |
00F2: MOVLW 0D |
|
|
354 |
00F3: MOVWF 0C |
|
|
355 |
00F4: DECFSZ 0C,F |
|
|
356 |
00F5: GOTO 0F4 |
|
|
357 |
.................... lcd_send_nibble(2); // nastav rezim 4 bitu (plati od nasledujiciho prenosu) |
|
|
358 |
00F6: MOVLW 02 |
|
|
359 |
00F7: MOVWF 47 |
|
|
360 |
00F8: CALL 0AB |
|
|
361 |
.................... delay_us(40); // cas na zpracovani |
|
|
362 |
00F9: MOVLW 0D |
|
|
363 |
00FA: MOVWF 0C |
|
|
364 |
00FB: DECFSZ 0C,F |
|
|
365 |
00FC: GOTO 0FB |
|
|
366 |
.................... |
|
|
367 |
.................... for (i=0;i<3;i++) // proved inicializaci (nastaveni modu, smazani apod) |
|
|
368 |
00FD: CLRF 3F |
|
|
369 |
00FE: MOVF 3F,W |
|
|
370 |
00FF: SUBLW 02 |
|
|
371 |
0100: BTFSS 03.0 |
|
|
372 |
0101: GOTO 10E |
|
|
373 |
.................... { |
|
|
374 |
.................... lcd_send_byte(0,LCD_INIT_STRING[i]); |
|
|
375 |
0102: MOVF 3F,W |
|
|
376 |
0103: CALL 02E |
|
|
377 |
0104: MOVWF 40 |
|
|
378 |
0105: CLRF 45 |
|
|
379 |
0106: MOVF 40,W |
|
|
380 |
0107: MOVWF 46 |
|
|
381 |
0108: CALL 0C0 |
|
|
382 |
.................... delay_ms(2); |
|
|
383 |
0109: MOVLW 02 |
|
|
384 |
010A: MOVWF 41 |
|
|
385 |
010B: CALL 096 |
|
|
386 |
.................... } |
|
|
387 |
010C: INCF 3F,F |
|
|
388 |
010D: GOTO 0FE |
|
|
389 |
010E: GOTO 16C (RETURN) |
|
|
390 |
.................... } |
|
|
391 |
.................... |
|
|
392 |
.................... |
|
|
393 |
.................... // Proved presun kurzoru |
|
|
394 |
.................... // |
|
|
395 |
.................... // Pozice 1.1 je domu |
|
|
396 |
.................... // |
|
|
397 |
.................... void lcd_gotoxy( BYTE x, BYTE y) |
|
|
398 |
.................... { |
|
|
399 |
.................... |
|
|
400 |
.................... BYTE Adr; |
|
|
401 |
.................... |
|
|
402 |
.................... Adr=x-1; |
|
|
403 |
010F: MOVLW 01 |
|
|
404 |
0110: SUBWF 41,W |
|
|
405 |
0111: MOVWF 43 |
|
|
406 |
.................... if(y==2) |
|
|
407 |
0112: MOVF 42,W |
|
|
408 |
0113: SUBLW 02 |
|
|
409 |
0114: BTFSS 03.2 |
|
|
410 |
0115: GOTO 118 |
|
|
411 |
.................... Adr+=LCD_LINE_2; |
|
|
412 |
0116: MOVLW 40 |
|
|
413 |
0117: ADDWF 43,F |
|
|
414 |
.................... |
|
|
415 |
.................... lcd_send_byte(0,0x80|Adr); |
|
|
416 |
0118: MOVF 43,W |
|
|
417 |
0119: IORLW 80 |
|
|
418 |
011A: MOVWF 44 |
|
|
419 |
011B: CLRF 45 |
|
|
420 |
011C: MOVF 44,W |
|
|
421 |
011D: MOVWF 46 |
|
|
422 |
011E: CALL 0C0 |
|
|
423 |
011F: RETLW 00 |
|
|
424 |
.................... } |
|
|
425 |
.................... |
|
|
426 |
.................... |
|
|
427 |
.................... // Zapis znaku na displej, zpracovani ridicich znaku |
|
|
428 |
.................... // |
|
|
429 |
.................... void lcd_putc( char c) |
|
|
430 |
.................... { |
|
|
431 |
.................... |
|
|
432 |
.................... switch (c) |
|
|
433 |
0120: MOVF 40,W |
|
|
434 |
0121: MOVWF 0C |
|
|
435 |
0122: MOVLW 0C |
|
|
436 |
0123: SUBWF 0C,W |
|
|
437 |
0124: BTFSC 03.2 |
|
|
438 |
0125: GOTO 133 |
|
|
439 |
0126: MOVLW 0A |
|
|
440 |
0127: SUBWF 0C,W |
|
|
441 |
0128: BTFSC 03.2 |
|
|
442 |
0129: GOTO 13B |
|
|
443 |
012A: MOVLW 0D |
|
|
444 |
012B: SUBWF 0C,W |
|
|
445 |
012C: BTFSC 03.2 |
|
|
446 |
012D: GOTO 141 |
|
|
447 |
012E: MOVLW 08 |
|
|
448 |
012F: SUBWF 0C,W |
|
|
449 |
0130: BTFSC 03.2 |
|
|
450 |
0131: GOTO 146 |
|
|
451 |
0132: GOTO 14B |
|
|
452 |
.................... { |
|
|
453 |
.................... case '\f' : lcd_send_byte(0,1); // smaz displej |
|
|
454 |
0133: CLRF 45 |
|
|
455 |
0134: MOVLW 01 |
|
|
456 |
0135: MOVWF 46 |
|
|
457 |
0136: CALL 0C0 |
|
|
458 |
.................... delay_ms(2); |
|
|
459 |
0137: MOVLW 02 |
|
|
460 |
0138: MOVWF 41 |
|
|
461 |
0139: CALL 096 |
|
|
462 |
.................... break; |
|
|
463 |
013A: GOTO 157 |
|
|
464 |
.................... case '\n' : lcd_gotoxy(1,2); break; // presun se na 1. znak 2. radky |
|
|
465 |
013B: MOVLW 01 |
|
|
466 |
013C: MOVWF 41 |
|
|
467 |
013D: MOVLW 02 |
|
|
468 |
013E: MOVWF 42 |
|
|
469 |
013F: CALL 10F |
|
|
470 |
0140: GOTO 157 |
|
|
471 |
.................... case '\r' : lcd_gotoxy(1,1); break; // presun home |
|
|
472 |
0141: MOVLW 01 |
|
|
473 |
0142: MOVWF 41 |
|
|
474 |
0143: MOVWF 42 |
|
|
475 |
0144: CALL 10F |
|
|
476 |
0145: GOTO 157 |
|
|
477 |
.................... case '\b' : lcd_send_byte(0,0x10); break; // posun kurzor o 1 zpet |
|
|
478 |
0146: CLRF 45 |
|
|
479 |
0147: MOVLW 10 |
|
|
480 |
0148: MOVWF 46 |
|
|
481 |
0149: CALL 0C0 |
|
|
482 |
014A: GOTO 157 |
|
|
483 |
.................... default : if (c<0x20) c&=0x7; // preklopeni definovatelnych znaku na rozsah 0 az 0x1F |
|
|
484 |
014B: MOVF 40,W |
|
|
485 |
014C: SUBLW 1F |
|
|
486 |
014D: BTFSS 03.0 |
|
|
487 |
014E: GOTO 151 |
|
|
488 |
014F: MOVLW 07 |
|
|
489 |
0150: ANDWF 40,F |
|
|
490 |
.................... lcd_send_byte(1,c); break; // zapis znak |
|
|
491 |
0151: MOVLW 01 |
|
|
492 |
0152: MOVWF 45 |
|
|
493 |
0153: MOVF 40,W |
|
|
494 |
0154: MOVWF 46 |
|
|
495 |
0155: CALL 0C0 |
|
|
496 |
0156: GOTO 157 |
|
|
497 |
.................... } |
|
|
498 |
0157: RETLW 00 |
|
|
499 |
.................... } |
|
|
500 |
.................... |
|
|
501 |
.................... |
|
|
502 |
.................... // Zapni kurzor |
|
|
503 |
.................... // |
|
|
504 |
.................... void lcd_cursor_on() |
|
|
505 |
.................... { |
|
|
506 |
.................... lcd_send_byte(0,LCD_CURSOR_ON_); |
|
|
507 |
.................... } |
|
|
508 |
.................... |
|
|
509 |
.................... |
|
|
510 |
.................... // Vypni kurzor |
|
|
511 |
.................... // |
|
|
512 |
.................... void lcd_cursor_off() |
|
|
513 |
.................... { |
|
|
514 |
.................... lcd_send_byte(0,LCD_CURSOR_OFF_); |
|
|
515 |
.................... } |
|
|
516 |
.................... |
|
|
517 |
.................... |
|
|
518 |
.................... // Smaz displej |
|
|
519 |
.................... // |
|
|
520 |
.................... void lcd_clr() |
|
|
521 |
.................... { |
|
|
522 |
.................... lcd_putc('\f'); |
|
|
523 |
.................... } |
|
|
524 |
.................... |
|
|
525 |
.................... |
|
|
526 |
.................... // Definice vlastnich fontu |
|
|
527 |
.................... // |
|
|
528 |
.................... // Vlastnich definic muze byt jen 8 do pozic 0 az 7 pameti CGRAM radice lcd displeje |
|
|
529 |
.................... // Pro snadne definovani jsou pripraveny nasledujici definice a na konci souboru je uveden |
|
|
530 |
.................... // priklad pouziti definovanych znaku. |
|
|
531 |
.................... |
|
|
532 |
.................... |
|
|
533 |
.................... // Pomocna procedura pro posilani ridicich dat do radice displeje |
|
|
534 |
.................... // |
|
|
535 |
.................... void lcd_putc2(int Data) |
|
|
536 |
.................... { |
|
|
537 |
.................... lcd_send_byte(1,Data); |
|
|
538 |
.................... } |
|
|
539 |
.................... |
|
|
540 |
.................... |
|
|
541 |
.................... // Pomocne definice pro programovani obsahu CGRAM |
|
|
542 |
.................... // |
|
|
543 |
.................... #define lcd_define_start(Code) lcd_send_byte(0,0x40+(Code<<3)); delay_ms(2) |
|
|
544 |
.................... #define lcd_define_def(String) printf(lcd_putc2,String); |
|
|
545 |
.................... #define lcd_define_end() lcd_send_byte(0,3); delay_ms(2) |
|
|
546 |
.................... |
|
|
547 |
.................... |
|
|
548 |
.................... // Vlastni vykonne makro pro definovani fontu do pozice Index CGRAM s definicnim retezcem Def |
|
|
549 |
.................... // |
|
|
550 |
.................... #define lcd_define_char(Index, Def) lcd_define_start(Index); lcd_define_def(Def); lcd_define_end(); |
|
|
551 |
.................... |
|
|
552 |
.................... |
|
|
553 |
.................... // Pripravene definice fontu vybranych znaku |
|
|
554 |
.................... // V tabulce nesmi byt 00 (konec retezce v printf()), misto toho davame 80 |
|
|
555 |
.................... // |
|
|
556 |
.................... #define LCD_CHAR_BAT100 "\x0E\x1F\x1F\x1F\x1F\x1F\x1F\x1F" /* symbol plne baterie */ |
|
|
557 |
.................... #define LCD_CHAR_BAT50 "\x0E\x1F\x11\x11\x13\x17\x1F\x1F" /* symbol polovicni baterie */ |
|
|
558 |
.................... #define LCD_CHAR_BAT0 "\x0E\x1F\x11\x11\x11\x11\x11\x1F" /* symbol vybite baterie */ |
|
|
559 |
.................... #define LCD_CHAR_UP "\x80\x04\x0E\x15\x04\x04\x04\x80" /* symbol sipka nahoru */ |
|
|
560 |
.................... #define LCD_CHAR_DOWN "\x80\x04\x04\x04\x15\x0E\x04\x80" /* symbol Sipka dolu */ |
|
|
561 |
.................... #define LCD_CHAR_LUA "\x04\x0E\x11\x11\x1F\x11\x11\x80" /* A s carkou */ |
|
|
562 |
.................... #define LCD_CHAR_LLA "\x01\x02\x0E\x01\x1F\x11\x0F\x80" /* a s carkou */ |
|
|
563 |
.................... #define LCD_CHAR_HUC "\x0A\x0E\x11\x10\x10\x11\x0E\x80" /* C s hackem */ |
|
|
564 |
.................... #define LCD_CHAR_HLC "\x0A\x04\x0E\x10\x10\x11\x0E\x80" /* c s hackem */ |
|
|
565 |
.................... #define LCD_CHAR_HUD "\x0A\x1C\x12\x11\x11\x12\x1C\x80" /* D s hackem */ |
|
|
566 |
.................... #define LCD_CHAR_HLD "\x05\x03\x0D\x13\x11\x11\x0F\x80" /* d s hackem */ |
|
|
567 |
.................... #define LCD_CHAR_LUE "\x04\x1F\x10\x10\x1E\x10\x1F\x80" /* E s carkou */ |
|
|
568 |
.................... #define LCD_CHAR_LLE "\x01\x02\x0E\x11\x1F\x10\x0E\x80" /* e s carkou */ |
|
|
569 |
.................... #define LCD_CHAR_HUE "\x0A\x1F\x10\x1E\x10\x10\x1F\x80" /* E s hackem */ |
|
|
570 |
.................... #define LCD_CHAR_HLE "\x0A\x04\x0E\x11\x1F\x10\x0E\x80" /* e s hackem */ |
|
|
571 |
.................... #define LCD_CHAR_LUI "\x04\x0E\x04\x04\x04\x04\x0E\x80" /* I s carkou */ |
|
|
572 |
.................... #define LCD_CHAR_LLI "\x02\x04\x80\x0C\x04\x04\x0E\x80" /* i s carkou */ |
|
|
573 |
.................... #define LCD_CHAR_HUN "\x0A\x15\x11\x19\x15\x13\x11\x80" /* N s hackem */ |
|
|
574 |
.................... #define LCD_CHAR_HLN "\x0A\x04\x16\x19\x11\x11\x11\x80" /* n s hackem */ |
|
|
575 |
.................... #define LCD_CHAR_LUO "\x04\x0E\x11\x11\x11\x11\x0E\x80" /* O s carkou */ |
|
|
576 |
.................... #define LCD_CHAR_LLO "\x02\x04\x0E\x11\x11\x11\x0E\x80" /* o s carkou */ |
|
|
577 |
.................... #define LCD_CHAR_HUR "\x0A\x1E\x11\x1E\x14\x12\x11\x80" /* R s hackem */ |
|
|
578 |
.................... #define LCD_CHAR_HLR "\x0A\x04\x16\x19\x10\x10\x10\x80" /* r s hackem */ |
|
|
579 |
.................... #define LCD_CHAR_HUS "\x0A\x0F\x10\x0E\x01\x01\x1E\x80" /* S s hackem */ |
|
|
580 |
.................... #define LCD_CHAR_HLS "\x0A\x04\x0E\x10\x0E\x01\x1E\x80" /* s s hackem */ |
|
|
581 |
.................... #define LCD_CHAR_HUT "\x0A\x1F\x04\x04\x04\x04\x04\x80" /* T s hackem */ |
|
|
582 |
.................... #define LCD_CHAR_HLT "\x0A\x0C\x1C\x08\x08\x09\x06\x80" /* t s hackem */ |
|
|
583 |
.................... #define LCD_CHAR_LUU "\x02\x15\x11\x11\x11\x11\x0E\x80" /* U s carkou */ |
|
|
584 |
.................... #define LCD_CHAR_LLU "\x02\x04\x11\x11\x11\x13\x0D\x80" /* u s carkou */ |
|
|
585 |
.................... #define LCD_CHAR_CUU "\x06\x17\x11\x11\x11\x11\x0E\x80" /* U s krouzkem */ |
|
|
586 |
.................... #define LCD_CHAR_CLU "\x06\x06\x11\x11\x11\x11\x0E\x80" /* u s krouzkem */ |
|
|
587 |
.................... #define LCD_CHAR_LUY "\x02\x15\x11\x0A\x04\x04\x04\x80" /* Y s carkou */ |
|
|
588 |
.................... #define LCD_CHAR_LLY "\x02\x04\x11\x11\x0F\x01\x0E\x80" /* y s carkou */ |
|
|
589 |
.................... #define LCD_CHAR_HUZ "\x0A\x1F\x01\x02\x04\x08\x1F\x80" /* Z s hackem */ |
|
|
590 |
.................... #define LCD_CHAR_HLZ "\x0A\x04\x1F\x02\x04\x08\x1F\x80" /* z s hackem */ |
|
|
591 |
.................... |
|
|
592 |
.................... |
|
|
593 |
.................... // Priklad pouziti definovanych znaku |
|
|
594 |
.................... // |
|
|
595 |
.................... // |
|
|
596 |
.................... //void lcd_sample() |
|
|
597 |
.................... //{ |
|
|
598 |
.................... // lcd_define_char(0,LCD_CHAR_BAT50); // Priklad definice znaku baterie do pozice 0 |
|
|
599 |
.................... // lcd_define_char(2,LCD_CHAR_HLE LCD_CHAR_LUI); // Priklad definice znaku e s hackem a I s carkou od pozice 2 |
|
|
600 |
.................... // // vsimnete si, ze neni carka mezi retezci s definici (oba retezce definuji |
|
|
601 |
.................... // // jediny definicni retezec) |
|
|
602 |
.................... // printf(lcd_putc,"\fZnaky:\20\22\23"); // priklad vypisu znaku z pozice 0, 2 a 3 |
|
|
603 |
.................... // delay_ms(1000); |
|
|
604 |
.................... // lcd_define_char(0,LCD_CHAR_BAT0); // Predefinovani tvaru znaku v pozici 0 |
|
|
605 |
.................... // delay_ms(1000); |
|
|
606 |
.................... //} |
|
|
607 |
.................... |
|
|
608 |
.................... |
|
|
609 |
.................... |
|
|
610 |
.................... // Vstup seriovky |
|
|
611 |
.................... // |
|
|
612 |
.................... #ifdef INV |
|
|
613 |
.................... #use RS232 (BAUD=RS_BOUD, RCV=RS_IN, PARITY=N, INVERT) |
|
|
614 |
* |
|
|
615 |
0059: MOVLW 08 |
|
|
616 |
005A: MOVWF 0C |
|
|
617 |
005B: BSF 03.5 |
|
|
618 |
005C: BSF 06.0 |
|
|
619 |
005D: BCF 03.5 |
|
|
620 |
005E: BTFSS 06.0 |
|
|
621 |
005F: GOTO 05E |
|
|
622 |
0060: CLRF 4C |
|
|
623 |
0061: BSF 0C.7 |
|
|
624 |
0062: GOTO 071 |
|
|
625 |
0063: BCF 0C.7 |
|
|
626 |
0064: GOTO 071 |
|
|
627 |
0065: BCF 03.0 |
|
|
628 |
0066: BTFSS 06.0 |
|
|
629 |
0067: BSF 03.0 |
|
|
630 |
0068: RRF 4C,F |
|
|
631 |
0069: BSF 0C.6 |
|
|
632 |
006A: GOTO 071 |
|
|
633 |
006B: BCF 0C.6 |
|
|
634 |
006C: DECFSZ 0C,F |
|
|
635 |
006D: GOTO 065 |
|
|
636 |
006E: MOVF 4C,W |
|
|
637 |
006F: MOVWF 0D |
|
|
638 |
0070: GOTO 07D |
|
|
639 |
0071: MOVLW 1C |
|
|
640 |
0072: BTFSC 0C.7 |
|
|
641 |
0073: MOVLW 07 |
|
|
642 |
0074: MOVWF 0D |
|
|
643 |
0075: DECFSZ 0D,F |
|
|
644 |
0076: GOTO 075 |
|
|
645 |
0077: NOP |
|
|
646 |
0078: BTFSC 0C.7 |
|
|
647 |
0079: GOTO 063 |
|
|
648 |
007A: BTFSC 0C.6 |
|
|
649 |
007B: GOTO 06B |
|
|
650 |
007C: GOTO 065 |
|
|
651 |
007D: GOTO 083 (RETURN) |
|
|
652 |
.................... #else |
|
|
653 |
.................... #use RS232 (BAUD=RS_BOUD, RCV=RS_IN, PARITY=N) |
|
|
654 |
.................... #endif |
|
|
655 |
.................... |
|
|
656 |
.................... |
|
|
657 |
.................... // Buffer FIFO |
|
|
658 |
.................... // |
|
|
659 |
.................... #define MAX 40 // delka bufferu |
|
|
660 |
.................... |
|
|
661 |
.................... char c[MAX]; // bufer FIFO |
|
|
662 |
.................... unsigned int ci; // ukazatel na bunku kam se bude ukladat novy znak |
|
|
663 |
.................... unsigned int co; // ukazatel na bunku odkud se bude cist znak |
|
|
664 |
.................... |
|
|
665 |
.................... // Preruseni - ukladani dat ze seriovky do bufferu |
|
|
666 |
.................... // |
|
|
667 |
.................... #int_ext // preruseni od zacatku znaku (start bit) |
|
|
668 |
.................... void Interupt() |
|
|
669 |
.................... { |
|
|
670 |
.................... c[ci]=getc(); // nacti znak (asynchronni cteni programem) |
|
|
671 |
007E: MOVLW 14 |
|
|
672 |
007F: ADDWF 3C,W |
|
|
673 |
0080: MOVWF 04 |
|
|
674 |
0081: MOVWF 4B |
|
|
675 |
0082: GOTO 059 |
|
|
676 |
0083: MOVF 4B,W |
|
|
677 |
0084: MOVWF 04 |
|
|
678 |
0085: MOVF 0D,W |
|
|
679 |
0086: MOVWF 00 |
|
|
680 |
.................... |
|
|
681 |
.................... if (ci<(MAX-1)) ci++; else ci=0; // posun ukazovatko do FIFO |
|
|
682 |
0087: MOVF 3C,W |
|
|
683 |
0088: SUBLW 26 |
|
|
684 |
0089: BTFSS 03.0 |
|
|
685 |
008A: GOTO 08D |
|
|
686 |
008B: INCF 3C,F |
|
|
687 |
008C: GOTO 08E |
|
|
688 |
008D: CLRF 3C |
|
|
689 |
.................... |
|
|
690 |
.................... #ifdef INV |
|
|
691 |
.................... while(input(PIN_B0)); // pockej na konec posledniho bitu |
|
|
692 |
008E: BSF 03.5 |
|
|
693 |
008F: BSF 06.0 |
|
|
694 |
0090: BCF 03.5 |
|
|
695 |
0091: BTFSC 06.0 |
|
|
696 |
0092: GOTO 08E |
|
|
697 |
.................... #else |
|
|
698 |
.................... while(~input(PIN_B0)); // pockej na konec posledniho bitu |
|
|
699 |
.................... #endif |
|
|
700 |
0093: BCF 0B.1 |
|
|
701 |
0094: BCF 0A.3 |
|
|
702 |
0095: GOTO 01F |
|
|
703 |
.................... } |
|
|
704 |
.................... |
|
|
705 |
.................... |
|
|
706 |
.................... // Hlavni smycka |
|
|
707 |
.................... // |
|
|
708 |
.................... void main() |
|
|
709 |
.................... { |
|
|
710 |
.................... char ch; // pomocna promenna pro 1 znak |
|
|
711 |
* |
|
|
712 |
0158: CLRF 04 |
|
|
713 |
0159: MOVLW 1F |
|
|
714 |
015A: ANDWF 03,F |
|
|
715 |
015B: BSF 03.5 |
|
|
716 |
015C: BCF 05.0 |
|
|
717 |
015D: BCF 03.5 |
|
|
718 |
015E: BCF 05.0 |
|
|
719 |
.................... |
|
|
720 |
.................... // Inicializace portu |
|
|
721 |
.................... output_a(0); // vsechny porty vystupni |
|
|
722 |
015F: MOVLW 00 |
|
|
723 |
0160: BSF 03.5 |
|
|
724 |
0161: MOVWF 05 |
|
|
725 |
0162: BCF 03.5 |
|
|
726 |
0163: CLRF 05 |
|
|
727 |
.................... output_b(0); // a nulove krome |
|
|
728 |
0164: BSF 03.5 |
|
|
729 |
0165: MOVWF 06 |
|
|
730 |
0166: BCF 03.5 |
|
|
731 |
0167: CLRF 06 |
|
|
732 |
.................... output_float(RS_IN); // portu pro RS232 (a preruseni) |
|
|
733 |
0168: BSF 03.5 |
|
|
734 |
0169: BSF 06.0 |
|
|
735 |
.................... |
|
|
736 |
.................... // Inicializace LCD |
|
|
737 |
.................... lcd_init(); // inicializace LCD |
|
|
738 |
016A: BCF 03.5 |
|
|
739 |
016B: GOTO 0D6 |
|
|
740 |
.................... printf(lcd_putc,"LCD Terminal 1.0"); // standardni vypis |
|
|
741 |
* |
|
|
742 |
0036: BCF 0A.0 |
|
|
743 |
0037: BCF 0A.1 |
|
|
744 |
0038: BCF 0A.2 |
|
|
745 |
0039: ADDWF 02,F |
|
|
746 |
003A: RETLW 4C |
|
|
747 |
003B: RETLW 43 |
|
|
748 |
003C: RETLW 44 |
|
|
749 |
003D: RETLW 20 |
|
|
750 |
003E: RETLW 54 |
|
|
751 |
003F: RETLW 65 |
|
|
752 |
0040: RETLW 72 |
|
|
753 |
0041: RETLW 6D |
|
|
754 |
0042: RETLW 69 |
|
|
755 |
0043: RETLW 6E |
|
|
756 |
0044: RETLW 61 |
|
|
757 |
0045: RETLW 6C |
|
|
758 |
0046: RETLW 20 |
|
|
759 |
0047: RETLW 31 |
|
|
760 |
0048: RETLW 2E |
|
|
761 |
0049: RETLW 30 |
|
|
762 |
004A: RETLW 00 |
|
|
763 |
* |
|
|
764 |
016C: CLRF 3F |
|
|
765 |
016D: MOVF 3F,W |
|
|
766 |
016E: CALL 036 |
|
|
767 |
016F: INCF 3F,F |
|
|
768 |
0170: MOVWF 40 |
|
|
769 |
0171: CALL 120 |
|
|
770 |
0172: MOVLW 10 |
|
|
771 |
0173: SUBWF 3F,W |
|
|
772 |
0174: BTFSS 03.2 |
|
|
773 |
0175: GOTO 16D |
|
|
774 |
.................... #ifdef INV |
|
|
775 |
.................... printf(lcd_putc,"\nInverted"); // oznameni o inverzni variante |
|
|
776 |
* |
|
|
777 |
004B: BCF 0A.0 |
|
|
778 |
004C: BCF 0A.1 |
|
|
779 |
004D: BCF 0A.2 |
|
|
780 |
004E: ADDWF 02,F |
|
|
781 |
004F: RETLW 0A |
|
|
782 |
0050: RETLW 49 |
|
|
783 |
0051: RETLW 6E |
|
|
784 |
0052: RETLW 76 |
|
|
785 |
0053: RETLW 65 |
|
|
786 |
0054: RETLW 72 |
|
|
787 |
0055: RETLW 74 |
|
|
788 |
0056: RETLW 65 |
|
|
789 |
0057: RETLW 64 |
|
|
790 |
0058: RETLW 00 |
|
|
791 |
* |
|
|
792 |
0176: CLRF 3F |
|
|
793 |
0177: MOVF 3F,W |
|
|
794 |
0178: CALL 04B |
|
|
795 |
0179: INCF 3F,F |
|
|
796 |
017A: MOVWF 40 |
|
|
797 |
017B: CALL 120 |
|
|
798 |
017C: MOVLW 09 |
|
|
799 |
017D: SUBWF 3F,W |
|
|
800 |
017E: BTFSS 03.2 |
|
|
801 |
017F: GOTO 177 |
|
|
802 |
.................... #else |
|
|
803 |
.................... printf(lcd_putc,"\nStandard"); // oznameni o inverzni variante |
|
|
804 |
.................... #endif |
|
|
805 |
.................... delay_ms(300); // cas na precteni |
|
|
806 |
0180: MOVLW 02 |
|
|
807 |
0181: MOVWF 3F |
|
|
808 |
0182: MOVLW 96 |
|
|
809 |
0183: MOVWF 41 |
|
|
810 |
0184: CALL 096 |
|
|
811 |
0185: DECFSZ 3F,F |
|
|
812 |
0186: GOTO 182 |
|
|
813 |
.................... printf(lcd_putc,"\f"); // smazani displeje |
|
|
814 |
0187: MOVLW 0C |
|
|
815 |
0188: MOVWF 40 |
|
|
816 |
0189: CALL 120 |
|
|
817 |
.................... |
|
|
818 |
.................... // Inicializace FIFO ukazatelu |
|
|
819 |
.................... ci=0; |
|
|
820 |
018A: CLRF 3C |
|
|
821 |
.................... co=0; |
|
|
822 |
018B: CLRF 3D |
|
|
823 |
.................... |
|
|
824 |
.................... // Inicializace preruseni |
|
|
825 |
.................... #ifdef INV // dle polarity kominkace polarita preruseni |
|
|
826 |
.................... ext_int_edge(L_TO_H); |
|
|
827 |
018C: BSF 03.5 |
|
|
828 |
018D: BSF 01.6 |
|
|
829 |
.................... #else |
|
|
830 |
.................... ext_int_edge(H_TO_L); |
|
|
831 |
.................... #endif |
|
|
832 |
.................... enable_interrupts(int_ext); // povoleni preruseni od INT0 |
|
|
833 |
018E: BCF 03.5 |
|
|
834 |
018F: BSF 0B.4 |
|
|
835 |
.................... enable_interrupts(global); // povoleni globalniho preruseni |
|
|
836 |
0190: BSF 0B.7 |
|
|
837 |
.................... |
|
|
838 |
.................... // Hlavni smycka |
|
|
839 |
.................... while (1) |
|
|
840 |
.................... { |
|
|
841 |
.................... |
|
|
842 |
.................... // Test na neprazdny buffer |
|
|
843 |
.................... while (ci==co); |
|
|
844 |
0191: MOVF 3D,W |
|
|
845 |
0192: SUBWF 3C,W |
|
|
846 |
0193: BTFSS 03.2 |
|
|
847 |
0194: GOTO 196 |
|
|
848 |
0195: GOTO 191 |
|
|
849 |
.................... |
|
|
850 |
.................... // Zobrazeni znaku |
|
|
851 |
.................... lcd_putc(c[co]); |
|
|
852 |
0196: MOVLW 14 |
|
|
853 |
0197: ADDWF 3D,W |
|
|
854 |
0198: MOVWF 04 |
|
|
855 |
0199: MOVF 00,W |
|
|
856 |
019A: MOVWF 3F |
|
|
857 |
019B: MOVWF 40 |
|
|
858 |
019C: CALL 120 |
|
|
859 |
.................... |
|
|
860 |
.................... // Posunuti ukazovatka |
|
|
861 |
.................... if (co<(MAX-1)) co++; else co=0; |
|
|
862 |
019D: MOVF 3D,W |
|
|
863 |
019E: SUBLW 26 |
|
|
864 |
019F: BTFSS 03.0 |
|
|
865 |
01A0: GOTO 1A3 |
|
|
866 |
01A1: INCF 3D,F |
|
|
867 |
01A2: GOTO 1A4 |
|
|
868 |
01A3: CLRF 3D |
|
|
869 |
.................... } |
|
|
870 |
01A4: GOTO 191 |
|
|
871 |
.................... } |
|
|
872 |
.................... |
|
|
873 |
01A5: SLEEP |