124 |
kapl |
1 |
CCS PCM C Compiler, Version 4.059d, 15399 28-XII-07 11:02 |
|
|
2 |
|
|
|
3 |
Filename: main.lst |
|
|
4 |
|
|
|
5 |
ROM used: 318 words (16%) |
|
|
6 |
Largest free fragment is 1730 |
|
|
7 |
RAM used: 8 (2%) at main() level |
|
|
8 |
18 (5%) worst case |
|
|
9 |
Stack: 4 locations |
|
|
10 |
|
|
|
11 |
* |
|
|
12 |
0000: MOVLW 00 |
|
|
13 |
0001: MOVWF 0A |
|
|
14 |
0002: GOTO 0EC |
|
|
15 |
0003: NOP |
|
|
16 |
.................... #include "main.h" |
|
|
17 |
.................... #include <16F877A.h> |
|
|
18 |
.................... //////// Standard Header file for the PIC16F877A device //////////////// |
|
|
19 |
.................... #device PIC16F877A |
|
|
20 |
.................... #list |
|
|
21 |
.................... |
|
|
22 |
.................... #device adc=8 |
|
|
23 |
.................... |
|
|
24 |
.................... #FUSES NOWDT //No Watch Dog Timer |
|
|
25 |
.................... #FUSES XT //Crystal osc <= 4mhz |
|
|
26 |
.................... #FUSES NOPUT //No Power Up Timer |
|
|
27 |
.................... #FUSES NOPROTECT //Code not protected from reading |
|
|
28 |
.................... #FUSES NODEBUG //No Debug mode for ICD |
|
|
29 |
.................... #FUSES NOBROWNOUT //No brownout reset |
|
|
30 |
.................... #FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O |
|
|
31 |
.................... #FUSES NOCPD //No EE protection |
|
|
32 |
.................... #FUSES NOWRT //Program memory not write protected |
|
|
33 |
.................... |
|
|
34 |
.................... #use delay(clock=4000000,RESTART_WDT) |
|
|
35 |
002A: MOVLW 23 |
|
|
36 |
002B: MOVWF 04 |
|
|
37 |
002C: BCF 03.7 |
|
|
38 |
002D: MOVF 00,W |
|
|
39 |
002E: BTFSC 03.2 |
|
|
40 |
002F: GOTO 041 |
|
|
41 |
0030: MOVLW 01 |
|
|
42 |
0031: MOVWF 78 |
|
|
43 |
0032: MOVLW BF |
|
|
44 |
0033: MOVWF 77 |
|
|
45 |
0034: CLRWDT |
|
|
46 |
0035: DECFSZ 77,F |
|
|
47 |
0036: GOTO 034 |
|
|
48 |
0037: DECFSZ 78,F |
|
|
49 |
0038: GOTO 032 |
|
|
50 |
0039: MOVLW 4A |
|
|
51 |
003A: MOVWF 77 |
|
|
52 |
003B: DECFSZ 77,F |
|
|
53 |
003C: GOTO 03B |
|
|
54 |
003D: NOP |
|
|
55 |
003E: CLRWDT |
|
|
56 |
003F: DECFSZ 00,F |
|
|
57 |
0040: GOTO 030 |
|
|
58 |
0041: RETLW 00 |
|
|
59 |
.................... #use rs232(baud=19200,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8) |
|
|
60 |
.................... |
|
|
61 |
.................... |
|
|
62 |
.................... |
|
|
63 |
.................... |
|
|
64 |
.................... |
|
|
65 |
.................... #define LCD_RS PIN_B1 // rizeni registru LCD displeje |
|
|
66 |
.................... #define LCD_E PIN_B0 // enable LCD displeje |
|
|
67 |
.................... #define LCD_DATA_LSB PIN_C0 // pripojeni LSB bitu datoveho portu LCD displeje (celkem 4 bity vzestupne za sebou) |
|
|
68 |
.................... |
|
|
69 |
.................... #include "lcd.c" |
|
|
70 |
.................... // LCD modul pro ovladani dvouradkoveho LCD modulu se standardnim Hitachi radicem |
|
|
71 |
.................... // (c)miho 2002,2005 |
|
|
72 |
.................... // |
|
|
73 |
.................... // Historie: |
|
|
74 |
.................... // |
|
|
75 |
.................... // 0.00 Uvodni verze se snadnou definici portu LCD displeje |
|
|
76 |
.................... // 0.01 Oprava portu (zapomenute stare identifikatory) |
|
|
77 |
.................... // 0.02 Doplnena moznost pripojeni datoveho portu LCD na libovolne porty |
|
|
78 |
.................... // 0.03 Doplnena procedura lcd_clr pro smazani displeje |
|
|
79 |
.................... // |
|
|
80 |
.................... // |
|
|
81 |
.................... // Funkce: |
|
|
82 |
.................... // |
|
|
83 |
.................... // lcd_init() inicializuje LCD displej a porty, nutno volat jako prvni |
|
|
84 |
.................... // |
|
|
85 |
.................... // lcd_putc(c) zapis snaku do lcd displeje, zpracovava nasledujici ridici znaky |
|
|
86 |
.................... // \f = \x0C - nova stranka - smazani displeje |
|
|
87 |
.................... // \n = \x0A - odradkovani (prechod na druhou radku) |
|
|
88 |
.................... // \b = \x08 - backspace - posunuti kurzoru o 1 pozici zpet |
|
|
89 |
.................... // \r = \x0D - goto home to position 1,1 |
|
|
90 |
.................... // \0 .. \7 - definovatelne znaky v pozicich 0 az 7 v CGRAM |
|
|
91 |
.................... // \20 .. \27 - alternativne zapsane znaky (oktalove) v pozicich 0 az 7 CGRAM |
|
|
92 |
.................... // Pozor na to, ze funkce printf konci tisk pokud narazi na \0 (konec retezce) |
|
|
93 |
.................... // |
|
|
94 |
.................... // lcd_gotoxy(x,y) presune kurzor na uvedenou adresu |
|
|
95 |
.................... // nekontroluje parametry |
|
|
96 |
.................... // |
|
|
97 |
.................... // lcd_cursor_on zapne kurzor |
|
|
98 |
.................... // lcd_cursor_off vypne kurzor |
|
|
99 |
.................... // |
|
|
100 |
.................... // lcd_clr smaze displej |
|
|
101 |
.................... // |
|
|
102 |
.................... // lcd_define_char(Index, Def) Makro, ktere definuje znaky od pozice Index obsahem definicniho |
|
|
103 |
.................... // retezce Def. Kazdych 8 znaku retezce Def definuje dalsi znak v CGRAM. |
|
|
104 |
.................... // Kapacita CGRAM je celkem 8 znaku s indexem 0 az 7. |
|
|
105 |
.................... // Na konci se provede lcd_gotoxy(1,1). |
|
|
106 |
.................... // Na konci teto knihovny je priklad pouziti definovanych znaku |
|
|
107 |
.................... // |
|
|
108 |
.................... // |
|
|
109 |
.................... // Definice portu: // Datovy port displeje pripojeny na 4 bity za sebou na jeden port |
|
|
110 |
.................... // |
|
|
111 |
.................... // #define LCD_RS PIN_B2 // rizeni registru LCD displeje |
|
|
112 |
.................... // #define LCD_E PIN_B1 // enable LCD displeje |
|
|
113 |
.................... // #define LCD_DATA_LSB PIN_C2 // pripojeni LSB bitu datoveho portu LCD displeje (celkem 4 bity vzestupne za sebou) |
|
|
114 |
.................... // |
|
|
115 |
.................... // |
|
|
116 |
.................... // Alternativni definice: // Datovy port displeje pripojeny na libovolne 4 bitove porty (vede na kod delsi asi o 25 slov) |
|
|
117 |
.................... // |
|
|
118 |
.................... // #define LCD_RS PIN_B2 // rizeni registru LCD displeje |
|
|
119 |
.................... // #define LCD_E PIN_B1 // enable LCD displeje |
|
|
120 |
.................... // #define LCD_D0 PIN_C2 // D0 - datove bity pripojene na libovolne porty |
|
|
121 |
.................... // #define LCD_D1 PIN_C3 // D1 |
|
|
122 |
.................... // #define LCD_D2 PIN_C4 // D2 |
|
|
123 |
.................... // #define LCD_D3 PIN_C5 // D3 |
|
|
124 |
.................... |
|
|
125 |
.................... |
|
|
126 |
.................... |
|
|
127 |
.................... |
|
|
128 |
.................... // Privatni sekce, cist jen v pripade, ze neco nefunguje |
|
|
129 |
.................... |
|
|
130 |
.................... |
|
|
131 |
.................... |
|
|
132 |
.................... |
|
|
133 |
.................... #ifdef LCD_DATA_LSB |
|
|
134 |
.................... // Generovane defince portu pro ucely teto knihovny aby kod generoval spravne IO operace a soucasne |
|
|
135 |
.................... // bylo mozne jednoduse deklarovat pripojene piny LCD displeje pri pouziti teto knihovny. Problem spociva |
|
|
136 |
.................... // v tom, ze se musi spravne ridit smery portu a soucasne datovy port zabira jen 4 bity ze zadaneho portu |
|
|
137 |
.................... // |
|
|
138 |
.................... #define LCD_SHIFT (LCD_DATA_LSB&7) // pocet bitu posuvu datoveho kanalu v datovem portu |
|
|
139 |
.................... #define LCD_PORT (LCD_DATA_LSB>>3) // adresa LCD datoveho portu |
|
|
140 |
.................... #define LCD_TRIS (LCD_PORT+0x80) // adresa prislusneho TRIS registru |
|
|
141 |
.................... #define LCD_MASK (0xF<<LCD_SHIFT) // maska platnych bitu |
|
|
142 |
.................... // |
|
|
143 |
.................... #if LCD_SHIFT>4 // kontrola mezi |
|
|
144 |
.................... #error LCD data port LSB bit not in range 0..4 |
|
|
145 |
.................... #endif |
|
|
146 |
.................... #endif |
|
|
147 |
.................... |
|
|
148 |
.................... |
|
|
149 |
.................... // Definice konstant pro LCD display |
|
|
150 |
.................... // |
|
|
151 |
.................... #define LCD_CURSOR_ON_ 0x0E // kurzor jako blikajici radka pod znakem |
|
|
152 |
.................... #define LCD_CURSOR_OFF_ 0x0C // zadny kurzor |
|
|
153 |
.................... #define LCD_LINE_2 0x40 // adresa 1. znaku 2. radky |
|
|
154 |
.................... |
|
|
155 |
.................... |
|
|
156 |
.................... // Definice rezimu LCD displeje |
|
|
157 |
.................... // |
|
|
158 |
.................... BYTE const LCD_INIT_STRING[4] = |
|
|
159 |
.................... { |
|
|
160 |
.................... 0x28, // intrfejs 4 bity, 2 radky, font 5x7 |
|
|
161 |
.................... LCD_CURSOR_OFF_, // display on, kurzor off, |
|
|
162 |
.................... 0x01, // clear displeje |
|
|
163 |
.................... 0x06 // inkrement pozice kurzoru (posun kurzoru doprava) |
|
|
164 |
.................... }; |
|
|
165 |
.................... |
|
|
166 |
.................... |
|
|
167 |
.................... // Odesle nibble do displeje (posle data a klikne signalem e) |
|
|
168 |
.................... // |
|
|
169 |
.................... void lcd_send_nibble( BYTE n ) |
|
|
170 |
.................... { |
|
|
171 |
.................... #ifdef LCD_DATA_LSB |
|
|
172 |
.................... // data jsou za sebou na 4 bitech jednoho portu |
|
|
173 |
.................... *LCD_PORT = (*LCD_PORT & ~LCD_MASK) | ((n << LCD_SHIFT) & LCD_MASK); // nastav datove bity portu a ostatni zachovej |
|
|
174 |
0042: MOVF 07,W |
|
|
175 |
0043: ANDLW F0 |
|
|
176 |
0044: MOVWF 2A |
|
|
177 |
0045: MOVF 29,W |
|
|
178 |
0046: ANDLW 0F |
|
|
179 |
0047: IORWF 2A,W |
|
|
180 |
0048: MOVWF 07 |
|
|
181 |
.................... #else |
|
|
182 |
.................... // data jsou na libovolnych 4 bitech libovolnych portu |
|
|
183 |
.................... output_bit(LCD_D0,bit_test(n,0)); |
|
|
184 |
.................... output_bit(LCD_D1,bit_test(n,1)); |
|
|
185 |
.................... output_bit(LCD_D2,bit_test(n,2)); |
|
|
186 |
.................... output_bit(LCD_D3,bit_test(n,3)); |
|
|
187 |
.................... #endif |
|
|
188 |
.................... output_bit(LCD_E,1); // vzestupna hrana |
|
|
189 |
0049: BSF 06.0 |
|
|
190 |
004A: BSF 03.5 |
|
|
191 |
004B: BCF 06.0 |
|
|
192 |
.................... delay_us(1); // pockej alespon 450ns od e nebo alespon 195ns od dat |
|
|
193 |
004C: CLRWDT |
|
|
194 |
.................... output_bit(LCD_E,0); // sestupna hrana (minimalni perioda e je 1us) |
|
|
195 |
004D: BCF 03.5 |
|
|
196 |
004E: BCF 06.0 |
|
|
197 |
004F: BSF 03.5 |
|
|
198 |
0050: BCF 06.0 |
|
|
199 |
.................... } |
|
|
200 |
0051: BCF 03.5 |
|
|
201 |
0052: RETLW 00 |
|
|
202 |
.................... |
|
|
203 |
.................... |
|
|
204 |
.................... // Odesle bajt do registru LCD |
|
|
205 |
.................... // |
|
|
206 |
.................... // Pokud je Adr=0 .. instrukcni registr |
|
|
207 |
.................... // Pokud je Adr=1 .. datovy registr |
|
|
208 |
.................... // |
|
|
209 |
.................... void lcd_send_byte( BOOLEAN Adr, BYTE n ) |
|
|
210 |
.................... { |
|
|
211 |
.................... output_bit(LCD_RS,Adr); // vyber registr |
|
|
212 |
0053: MOVF 27,F |
|
|
213 |
0054: BTFSS 03.2 |
|
|
214 |
0055: GOTO 058 |
|
|
215 |
0056: BCF 06.1 |
|
|
216 |
0057: GOTO 059 |
|
|
217 |
0058: BSF 06.1 |
|
|
218 |
0059: BSF 03.5 |
|
|
219 |
005A: BCF 06.1 |
|
|
220 |
.................... swap(n); |
|
|
221 |
005B: BCF 03.5 |
|
|
222 |
005C: SWAPF 28,F |
|
|
223 |
.................... lcd_send_nibble(n); // posli horni pulku bajtu |
|
|
224 |
005D: MOVF 28,W |
|
|
225 |
005E: MOVWF 29 |
|
|
226 |
005F: CALL 042 |
|
|
227 |
.................... swap(n); |
|
|
228 |
0060: SWAPF 28,F |
|
|
229 |
.................... lcd_send_nibble(n); // posli spodni pulku bajtu |
|
|
230 |
0061: MOVF 28,W |
|
|
231 |
0062: MOVWF 29 |
|
|
232 |
0063: CALL 042 |
|
|
233 |
.................... delay_us(40); // minimalni doba na provedeni prikazu |
|
|
234 |
0064: CLRWDT |
|
|
235 |
0065: MOVLW 0C |
|
|
236 |
0066: MOVWF 77 |
|
|
237 |
0067: DECFSZ 77,F |
|
|
238 |
0068: GOTO 067 |
|
|
239 |
0069: GOTO 06A |
|
|
240 |
.................... } |
|
|
241 |
006A: RETLW 00 |
|
|
242 |
.................... |
|
|
243 |
.................... |
|
|
244 |
.................... // Provede inicializaci LCD displeje, smaze obsah a nastavi mod displeje |
|
|
245 |
.................... // |
|
|
246 |
.................... // Tato procedura se musi volat pred pouzitim ostatnich lcd_ procedur |
|
|
247 |
.................... // |
|
|
248 |
.................... void lcd_init() |
|
|
249 |
.................... { |
|
|
250 |
.................... |
|
|
251 |
.................... int i; // pocitadlo cyklu |
|
|
252 |
.................... |
|
|
253 |
.................... delay_ms(20); // spozdeni pro provedeni startu displeje po zapnuti napajeni |
|
|
254 |
006B: MOVLW 14 |
|
|
255 |
006C: MOVWF 23 |
|
|
256 |
006D: CALL 02A |
|
|
257 |
.................... |
|
|
258 |
.................... #ifdef LCD_DATA_LSB |
|
|
259 |
.................... // data jsou na 4 bitech za sebou, nastav smer pro vsechny dalsi prenosy |
|
|
260 |
.................... *LCD_TRIS = *LCD_TRIS & ~LCD_MASK; // nuluj odpovidajici bity tris registru datoveho portu LCD |
|
|
261 |
006E: MOVLW F0 |
|
|
262 |
006F: BSF 03.5 |
|
|
263 |
0070: ANDWF 07,F |
|
|
264 |
.................... #endif |
|
|
265 |
.................... |
|
|
266 |
.................... output_bit(LCD_RS,0); // nastav jako vystup a nastav klidovy stav |
|
|
267 |
0071: BCF 03.5 |
|
|
268 |
0072: BCF 06.1 |
|
|
269 |
0073: BSF 03.5 |
|
|
270 |
0074: BCF 06.1 |
|
|
271 |
.................... output_bit(LCD_E, 0); // nastav jako vystup a nastav klidovy stav |
|
|
272 |
0075: BCF 03.5 |
|
|
273 |
0076: BCF 06.0 |
|
|
274 |
0077: BSF 03.5 |
|
|
275 |
0078: BCF 06.0 |
|
|
276 |
.................... |
|
|
277 |
.................... for (i=0; i<3; i++) // nastav lcd do rezimu 8 bitu sbernice |
|
|
278 |
0079: BCF 03.5 |
|
|
279 |
007A: CLRF 21 |
|
|
280 |
007B: MOVF 21,W |
|
|
281 |
007C: SUBLW 02 |
|
|
282 |
007D: BTFSS 03.0 |
|
|
283 |
007E: GOTO 087 |
|
|
284 |
.................... { |
|
|
285 |
.................... delay_ms(2); // muze byt rozdelany prenos dat (2x 4 bity) nebo pomaly povel |
|
|
286 |
007F: MOVLW 02 |
|
|
287 |
0080: MOVWF 23 |
|
|
288 |
0081: CALL 02A |
|
|
289 |
.................... lcd_send_nibble(3); // rezim 8 bitu |
|
|
290 |
0082: MOVLW 03 |
|
|
291 |
0083: MOVWF 29 |
|
|
292 |
0084: CALL 042 |
|
|
293 |
.................... } |
|
|
294 |
0085: INCF 21,F |
|
|
295 |
0086: GOTO 07B |
|
|
296 |
.................... |
|
|
297 |
.................... delay_us(40); // cas na zpracovani |
|
|
298 |
0087: CLRWDT |
|
|
299 |
0088: MOVLW 0C |
|
|
300 |
0089: MOVWF 77 |
|
|
301 |
008A: DECFSZ 77,F |
|
|
302 |
008B: GOTO 08A |
|
|
303 |
008C: GOTO 08D |
|
|
304 |
.................... lcd_send_nibble(2); // nastav rezim 4 bitu (plati od nasledujiciho prenosu) |
|
|
305 |
008D: MOVLW 02 |
|
|
306 |
008E: MOVWF 29 |
|
|
307 |
008F: CALL 042 |
|
|
308 |
.................... delay_us(40); // cas na zpracovani |
|
|
309 |
0090: CLRWDT |
|
|
310 |
0091: MOVLW 0C |
|
|
311 |
0092: MOVWF 77 |
|
|
312 |
0093: DECFSZ 77,F |
|
|
313 |
0094: GOTO 093 |
|
|
314 |
0095: GOTO 096 |
|
|
315 |
.................... |
|
|
316 |
.................... for (i=0;i<3;i++) // proved inicializaci (nastaveni modu, smazani apod) |
|
|
317 |
0096: CLRF 21 |
|
|
318 |
0097: MOVF 21,W |
|
|
319 |
0098: SUBLW 02 |
|
|
320 |
0099: BTFSS 03.0 |
|
|
321 |
009A: GOTO 0A7 |
|
|
322 |
.................... { |
|
|
323 |
.................... lcd_send_byte(0,LCD_INIT_STRING[i]); |
|
|
324 |
009B: MOVF 21,W |
|
|
325 |
009C: CALL 004 |
|
|
326 |
009D: MOVWF 22 |
|
|
327 |
009E: CLRF 27 |
|
|
328 |
009F: MOVF 22,W |
|
|
329 |
00A0: MOVWF 28 |
|
|
330 |
00A1: CALL 053 |
|
|
331 |
.................... delay_ms(2); |
|
|
332 |
00A2: MOVLW 02 |
|
|
333 |
00A3: MOVWF 23 |
|
|
334 |
00A4: CALL 02A |
|
|
335 |
.................... } |
|
|
336 |
00A5: INCF 21,F |
|
|
337 |
00A6: GOTO 097 |
|
|
338 |
.................... } |
|
|
339 |
00A7: GOTO 12E (RETURN) |
|
|
340 |
.................... |
|
|
341 |
.................... |
|
|
342 |
.................... // Proved presun kurzoru |
|
|
343 |
.................... // |
|
|
344 |
.................... // Pozice 1.1 je domu |
|
|
345 |
.................... // |
|
|
346 |
.................... void lcd_gotoxy( BYTE x, BYTE y) |
|
|
347 |
.................... { |
|
|
348 |
.................... |
|
|
349 |
.................... BYTE Adr; |
|
|
350 |
.................... |
|
|
351 |
.................... Adr=x-1; |
|
|
352 |
00A8: MOVLW 01 |
|
|
353 |
00A9: SUBWF 23,W |
|
|
354 |
00AA: MOVWF 25 |
|
|
355 |
.................... if(y==2) |
|
|
356 |
00AB: MOVF 24,W |
|
|
357 |
00AC: SUBLW 02 |
|
|
358 |
00AD: BTFSS 03.2 |
|
|
359 |
00AE: GOTO 0B1 |
|
|
360 |
.................... Adr+=LCD_LINE_2; |
|
|
361 |
00AF: MOVLW 40 |
|
|
362 |
00B0: ADDWF 25,F |
|
|
363 |
.................... |
|
|
364 |
.................... lcd_send_byte(0,0x80|Adr); |
|
|
365 |
00B1: MOVF 25,W |
|
|
366 |
00B2: IORLW 80 |
|
|
367 |
00B3: MOVWF 26 |
|
|
368 |
00B4: CLRF 27 |
|
|
369 |
00B5: MOVF 26,W |
|
|
370 |
00B6: MOVWF 28 |
|
|
371 |
00B7: CALL 053 |
|
|
372 |
.................... } |
|
|
373 |
00B8: RETLW 00 |
|
|
374 |
.................... |
|
|
375 |
.................... |
|
|
376 |
.................... // Zapis znaku na displej, zpracovani ridicich znaku |
|
|
377 |
.................... // |
|
|
378 |
.................... void lcd_putc( char c) |
|
|
379 |
.................... { |
|
|
380 |
.................... |
|
|
381 |
.................... switch (c) |
|
|
382 |
.................... { |
|
|
383 |
00B9: MOVF 22,W |
|
|
384 |
00BA: XORLW 0C |
|
|
385 |
00BB: BTFSC 03.2 |
|
|
386 |
00BC: GOTO 0C7 |
|
|
387 |
00BD: XORLW 06 |
|
|
388 |
00BE: BTFSC 03.2 |
|
|
389 |
00BF: GOTO 0CF |
|
|
390 |
00C0: XORLW 07 |
|
|
391 |
00C1: BTFSC 03.2 |
|
|
392 |
00C2: GOTO 0D5 |
|
|
393 |
00C3: XORLW 05 |
|
|
394 |
00C4: BTFSC 03.2 |
|
|
395 |
00C5: GOTO 0DA |
|
|
396 |
00C6: GOTO 0DF |
|
|
397 |
.................... case '\f' : lcd_send_byte(0,1); // smaz displej |
|
|
398 |
00C7: CLRF 27 |
|
|
399 |
00C8: MOVLW 01 |
|
|
400 |
00C9: MOVWF 28 |
|
|
401 |
00CA: CALL 053 |
|
|
402 |
.................... delay_ms(2); |
|
|
403 |
00CB: MOVLW 02 |
|
|
404 |
00CC: MOVWF 23 |
|
|
405 |
00CD: CALL 02A |
|
|
406 |
.................... break; |
|
|
407 |
00CE: GOTO 0EB |
|
|
408 |
.................... case '\n' : lcd_gotoxy(1,2); break; // presun se na 1. znak 2. radky |
|
|
409 |
00CF: MOVLW 01 |
|
|
410 |
00D0: MOVWF 23 |
|
|
411 |
00D1: MOVLW 02 |
|
|
412 |
00D2: MOVWF 24 |
|
|
413 |
00D3: CALL 0A8 |
|
|
414 |
00D4: GOTO 0EB |
|
|
415 |
.................... case '\r' : lcd_gotoxy(1,1); break; // presun home |
|
|
416 |
00D5: MOVLW 01 |
|
|
417 |
00D6: MOVWF 23 |
|
|
418 |
00D7: MOVWF 24 |
|
|
419 |
00D8: CALL 0A8 |
|
|
420 |
00D9: GOTO 0EB |
|
|
421 |
.................... case '\b' : lcd_send_byte(0,0x10); break; // posun kurzor o 1 zpet |
|
|
422 |
00DA: CLRF 27 |
|
|
423 |
00DB: MOVLW 10 |
|
|
424 |
00DC: MOVWF 28 |
|
|
425 |
00DD: CALL 053 |
|
|
426 |
00DE: GOTO 0EB |
|
|
427 |
.................... default : if (c<0x20) c&=0x7; // preklopeni definovatelnych znaku na rozsah 0 az 0x1F |
|
|
428 |
00DF: MOVF 22,W |
|
|
429 |
00E0: SUBLW 1F |
|
|
430 |
00E1: BTFSS 03.0 |
|
|
431 |
00E2: GOTO 0E5 |
|
|
432 |
00E3: MOVLW 07 |
|
|
433 |
00E4: ANDWF 22,F |
|
|
434 |
.................... lcd_send_byte(1,c); break; // zapis znak |
|
|
435 |
00E5: MOVLW 01 |
|
|
436 |
00E6: MOVWF 27 |
|
|
437 |
00E7: MOVF 22,W |
|
|
438 |
00E8: MOVWF 28 |
|
|
439 |
00E9: CALL 053 |
|
|
440 |
00EA: GOTO 0EB |
|
|
441 |
.................... } |
|
|
442 |
.................... } |
|
|
443 |
00EB: GOTO 138 (RETURN) |
|
|
444 |
.................... |
|
|
445 |
.................... |
|
|
446 |
.................... // Zapni kurzor |
|
|
447 |
.................... // |
|
|
448 |
.................... void lcd_cursor_on() |
|
|
449 |
.................... { |
|
|
450 |
.................... lcd_send_byte(0,LCD_CURSOR_ON_); |
|
|
451 |
.................... } |
|
|
452 |
.................... |
|
|
453 |
.................... |
|
|
454 |
.................... // Vypni kurzor |
|
|
455 |
.................... // |
|
|
456 |
.................... void lcd_cursor_off() |
|
|
457 |
.................... { |
|
|
458 |
.................... lcd_send_byte(0,LCD_CURSOR_OFF_); |
|
|
459 |
.................... } |
|
|
460 |
.................... |
|
|
461 |
.................... |
|
|
462 |
.................... // Smaz displej |
|
|
463 |
.................... // |
|
|
464 |
.................... void lcd_clr() |
|
|
465 |
.................... { |
|
|
466 |
.................... lcd_putc('\f'); |
|
|
467 |
.................... } |
|
|
468 |
.................... |
|
|
469 |
.................... |
|
|
470 |
.................... // Definice vlastnich fontu |
|
|
471 |
.................... // |
|
|
472 |
.................... // Vlastnich definic muze byt jen 8 do pozic 0 az 7 pameti CGRAM radice lcd displeje |
|
|
473 |
.................... // Pro snadne definovani jsou pripraveny nasledujici definice a na konci souboru je uveden |
|
|
474 |
.................... // priklad pouziti definovanych znaku. |
|
|
475 |
.................... |
|
|
476 |
.................... |
|
|
477 |
.................... // Pomocna procedura pro posilani ridicich dat do radice displeje |
|
|
478 |
.................... // |
|
|
479 |
.................... void lcd_putc2(int Data) |
|
|
480 |
.................... { |
|
|
481 |
.................... lcd_send_byte(1,Data); |
|
|
482 |
.................... } |
|
|
483 |
.................... |
|
|
484 |
.................... |
|
|
485 |
.................... // Pomocne definice pro programovani obsahu CGRAM |
|
|
486 |
.................... // |
|
|
487 |
.................... #define lcd_define_start(Code) lcd_send_byte(0,0x40+(Code<<3)); delay_ms(2) |
|
|
488 |
.................... #define lcd_define_def(String) printf(lcd_putc2,String); |
|
|
489 |
.................... #define lcd_define_end() lcd_send_byte(0,3); delay_ms(2) |
|
|
490 |
.................... |
|
|
491 |
.................... |
|
|
492 |
.................... // Vlastni vykonne makro pro definovani fontu do pozice Index CGRAM s definicnim retezcem Def |
|
|
493 |
.................... // |
|
|
494 |
.................... #define lcd_define_char(Index, Def) lcd_define_start(Index); lcd_define_def(Def); lcd_define_end(); |
|
|
495 |
.................... |
|
|
496 |
.................... |
|
|
497 |
.................... // Pripravene definice fontu vybranych znaku |
|
|
498 |
.................... // V tabulce nesmi byt 00 (konec retezce v printf()), misto toho davame 80 |
|
|
499 |
.................... // |
|
|
500 |
.................... #define LCD_CHAR_BAT100 "\x0E\x1F\x1F\x1F\x1F\x1F\x1F\x1F" /* symbol plne baterie */ |
|
|
501 |
.................... #define LCD_CHAR_BAT50 "\x0E\x1F\x11\x11\x13\x17\x1F\x1F" /* symbol polovicni baterie */ |
|
|
502 |
.................... #define LCD_CHAR_BAT0 "\x0E\x1F\x11\x11\x11\x11\x11\x1F" /* symbol vybite baterie */ |
|
|
503 |
.................... #define LCD_CHAR_UP "\x80\x04\x0E\x15\x04\x04\x04\x80" /* symbol sipka nahoru */ |
|
|
504 |
.................... #define LCD_CHAR_DOWN "\x80\x04\x04\x04\x15\x0E\x04\x80" /* symbol Sipka dolu */ |
|
|
505 |
.................... #define LCD_CHAR_LUA "\x04\x0E\x11\x11\x1F\x11\x11\x80" /* A s carkou */ |
|
|
506 |
.................... #define LCD_CHAR_LLA "\x01\x02\x0E\x01\x1F\x11\x0F\x80" /* a s carkou */ |
|
|
507 |
.................... #define LCD_CHAR_HUC "\x0A\x0E\x11\x10\x10\x11\x0E\x80" /* C s hackem */ |
|
|
508 |
.................... #define LCD_CHAR_HLC "\x0A\x04\x0E\x10\x10\x11\x0E\x80" /* c s hackem */ |
|
|
509 |
.................... #define LCD_CHAR_HUD "\x0A\x1C\x12\x11\x11\x12\x1C\x80" /* D s hackem */ |
|
|
510 |
.................... #define LCD_CHAR_HLD "\x05\x03\x0D\x13\x11\x11\x0F\x80" /* d s hackem */ |
|
|
511 |
.................... #define LCD_CHAR_LUE "\x04\x1F\x10\x10\x1E\x10\x1F\x80" /* E s carkou */ |
|
|
512 |
.................... #define LCD_CHAR_LLE "\x01\x02\x0E\x11\x1F\x10\x0E\x80" /* e s carkou */ |
|
|
513 |
.................... #define LCD_CHAR_HUE "\x0A\x1F\x10\x1E\x10\x10\x1F\x80" /* E s hackem */ |
|
|
514 |
.................... #define LCD_CHAR_HLE "\x0A\x04\x0E\x11\x1F\x10\x0E\x80" /* e s hackem */ |
|
|
515 |
.................... #define LCD_CHAR_LUI "\x04\x0E\x04\x04\x04\x04\x0E\x80" /* I s carkou */ |
|
|
516 |
.................... #define LCD_CHAR_LLI "\x02\x04\x80\x0C\x04\x04\x0E\x80" /* i s carkou */ |
|
|
517 |
.................... #define LCD_CHAR_HUN "\x0A\x15\x11\x19\x15\x13\x11\x80" /* N s hackem */ |
|
|
518 |
.................... #define LCD_CHAR_HLN "\x0A\x04\x16\x19\x11\x11\x11\x80" /* n s hackem */ |
|
|
519 |
.................... #define LCD_CHAR_LUO "\x04\x0E\x11\x11\x11\x11\x0E\x80" /* O s carkou */ |
|
|
520 |
.................... #define LCD_CHAR_LLO "\x02\x04\x0E\x11\x11\x11\x0E\x80" /* o s carkou */ |
|
|
521 |
.................... #define LCD_CHAR_HUR "\x0A\x1E\x11\x1E\x14\x12\x11\x80" /* R s hackem */ |
|
|
522 |
.................... #define LCD_CHAR_HLR "\x0A\x04\x16\x19\x10\x10\x10\x80" /* r s hackem */ |
|
|
523 |
.................... #define LCD_CHAR_HUS "\x0A\x0F\x10\x0E\x01\x01\x1E\x80" /* S s hackem */ |
|
|
524 |
.................... #define LCD_CHAR_HLS "\x0A\x04\x0E\x10\x0E\x01\x1E\x80" /* s s hackem */ |
|
|
525 |
.................... #define LCD_CHAR_HUT "\x0A\x1F\x04\x04\x04\x04\x04\x80" /* T s hackem */ |
|
|
526 |
.................... #define LCD_CHAR_HLT "\x0A\x0C\x1C\x08\x08\x09\x06\x80" /* t s hackem */ |
|
|
527 |
.................... #define LCD_CHAR_LUU "\x02\x15\x11\x11\x11\x11\x0E\x80" /* U s carkou */ |
|
|
528 |
.................... #define LCD_CHAR_LLU "\x02\x04\x11\x11\x11\x13\x0D\x80" /* u s carkou */ |
|
|
529 |
.................... #define LCD_CHAR_CUU "\x06\x17\x11\x11\x11\x11\x0E\x80" /* U s krouzkem */ |
|
|
530 |
.................... #define LCD_CHAR_CLU "\x06\x06\x11\x11\x11\x11\x0E\x80" /* u s krouzkem */ |
|
|
531 |
.................... #define LCD_CHAR_LUY "\x02\x15\x11\x0A\x04\x04\x04\x80" /* Y s carkou */ |
|
|
532 |
.................... #define LCD_CHAR_LLY "\x02\x04\x11\x11\x0F\x01\x0E\x80" /* y s carkou */ |
|
|
533 |
.................... #define LCD_CHAR_HUZ "\x0A\x1F\x01\x02\x04\x08\x1F\x80" /* Z s hackem */ |
|
|
534 |
.................... #define LCD_CHAR_HLZ "\x0A\x04\x1F\x02\x04\x08\x1F\x80" /* z s hackem */ |
|
|
535 |
.................... |
|
|
536 |
.................... |
|
|
537 |
.................... // Priklad pouziti definovanych znaku |
|
|
538 |
.................... // |
|
|
539 |
.................... // |
|
|
540 |
.................... //void lcd_sample() |
|
|
541 |
.................... //{ |
|
|
542 |
.................... // lcd_define_char(0,LCD_CHAR_BAT50); // Priklad definice znaku baterie do pozice 0 |
|
|
543 |
.................... // lcd_define_char(2,LCD_CHAR_HLE LCD_CHAR_LUI); // Priklad definice znaku e s hackem a I s carkou od pozice 2 |
|
|
544 |
.................... // // vsimnete si, ze neni carka mezi retezci s definici (oba retezce definuji |
|
|
545 |
.................... // // jediny definicni retezec) |
|
|
546 |
.................... // printf(lcd_putc,"\fZnaky:\20\22\23"); // priklad vypisu znaku z pozice 0, 2 a 3 |
|
|
547 |
.................... // delay_ms(1000); |
|
|
548 |
.................... // lcd_define_char(0,LCD_CHAR_BAT0); // Predefinovani tvaru znaku v pozici 0 |
|
|
549 |
.................... // delay_ms(1000); |
|
|
550 |
.................... //} |
|
|
551 |
.................... |
|
|
552 |
.................... |
|
|
553 |
.................... void main() |
|
|
554 |
.................... { |
|
|
555 |
00EC: CLRF 04 |
|
|
556 |
00ED: BCF 03.7 |
|
|
557 |
00EE: MOVLW 1F |
|
|
558 |
00EF: ANDWF 03,F |
|
|
559 |
00F0: MOVLW 0C |
|
|
560 |
00F1: BSF 03.5 |
|
|
561 |
00F2: MOVWF 19 |
|
|
562 |
00F3: MOVLW A6 |
|
|
563 |
00F4: MOVWF 18 |
|
|
564 |
00F5: MOVLW 90 |
|
|
565 |
00F6: BCF 03.5 |
|
|
566 |
00F7: MOVWF 18 |
|
|
567 |
00F8: BSF 03.5 |
|
|
568 |
00F9: BSF 1F.0 |
|
|
569 |
00FA: BSF 1F.1 |
|
|
570 |
00FB: BSF 1F.2 |
|
|
571 |
00FC: BCF 1F.3 |
|
|
572 |
00FD: MOVLW 07 |
|
|
573 |
00FE: MOVWF 1C |
|
|
574 |
.................... |
|
|
575 |
.................... setup_adc_ports(NO_ANALOGS); |
|
|
576 |
* |
|
|
577 |
0102: BSF 03.5 |
|
|
578 |
0103: BSF 1F.0 |
|
|
579 |
0104: BSF 1F.1 |
|
|
580 |
0105: BSF 1F.2 |
|
|
581 |
0106: BCF 1F.3 |
|
|
582 |
.................... setup_adc(ADC_OFF); |
|
|
583 |
0107: BCF 03.5 |
|
|
584 |
0108: BCF 1F.0 |
|
|
585 |
.................... setup_psp(PSP_DISABLED); |
|
|
586 |
0109: BSF 03.5 |
|
|
587 |
010A: BCF 09.4 |
|
|
588 |
.................... setup_spi(FALSE); |
|
|
589 |
* |
|
|
590 |
00FF: MOVLW FF |
|
|
591 |
0100: BCF 03.5 |
|
|
592 |
0101: MOVWF 20 |
|
|
593 |
* |
|
|
594 |
010B: BCF 03.5 |
|
|
595 |
010C: BCF 14.5 |
|
|
596 |
010D: BCF 20.5 |
|
|
597 |
010E: MOVF 20,W |
|
|
598 |
010F: BSF 03.5 |
|
|
599 |
0110: MOVWF 07 |
|
|
600 |
0111: BCF 03.5 |
|
|
601 |
0112: BSF 20.4 |
|
|
602 |
0113: MOVF 20,W |
|
|
603 |
0114: BSF 03.5 |
|
|
604 |
0115: MOVWF 07 |
|
|
605 |
0116: BCF 03.5 |
|
|
606 |
0117: BCF 20.3 |
|
|
607 |
0118: MOVF 20,W |
|
|
608 |
0119: BSF 03.5 |
|
|
609 |
011A: MOVWF 07 |
|
|
610 |
011B: MOVLW 00 |
|
|
611 |
011C: BCF 03.5 |
|
|
612 |
011D: MOVWF 14 |
|
|
613 |
011E: BSF 03.5 |
|
|
614 |
011F: MOVWF 14 |
|
|
615 |
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); |
|
|
616 |
0120: MOVF 01,W |
|
|
617 |
0121: ANDLW C7 |
|
|
618 |
0122: IORLW 08 |
|
|
619 |
0123: MOVWF 01 |
|
|
620 |
.................... setup_timer_1(T1_DISABLED); |
|
|
621 |
0124: BCF 03.5 |
|
|
622 |
0125: CLRF 10 |
|
|
623 |
.................... setup_timer_2(T2_DISABLED,0,1); |
|
|
624 |
0126: MOVLW 00 |
|
|
625 |
0127: MOVWF 78 |
|
|
626 |
0128: MOVWF 12 |
|
|
627 |
0129: MOVLW 00 |
|
|
628 |
012A: BSF 03.5 |
|
|
629 |
012B: MOVWF 12 |
|
|
630 |
.................... |
|
|
631 |
.................... lcd_init(); |
|
|
632 |
012C: BCF 03.5 |
|
|
633 |
012D: GOTO 06B |
|
|
634 |
.................... |
|
|
635 |
.................... while(true) |
|
|
636 |
.................... { |
|
|
637 |
.................... Delay_ms(100); |
|
|
638 |
012E: MOVLW 64 |
|
|
639 |
012F: MOVWF 23 |
|
|
640 |
0130: CALL 02A |
|
|
641 |
.................... |
|
|
642 |
.................... // LCD_gotoxy(1,1); |
|
|
643 |
.................... printf(lcd_putc,"\fZkouska vypisu.\nFunguje!"); |
|
|
644 |
0131: CLRF 21 |
|
|
645 |
0132: MOVF 21,W |
|
|
646 |
0133: CALL 00C |
|
|
647 |
0134: INCF 21,F |
|
|
648 |
0135: MOVWF 77 |
|
|
649 |
0136: MOVWF 22 |
|
|
650 |
0137: GOTO 0B9 |
|
|
651 |
0138: MOVLW 19 |
|
|
652 |
0139: SUBWF 21,W |
|
|
653 |
013A: BTFSS 03.2 |
|
|
654 |
013B: GOTO 132 |
|
|
655 |
.................... |
|
|
656 |
.................... } |
|
|
657 |
013C: GOTO 12E |
|
|
658 |
.................... |
|
|
659 |
.................... } |
|
|
660 |
.................... |
|
|
661 |
.................... /* |
|
|
662 |
.................... |
|
|
663 |
.................... #include "C:\RS\projekty\lcdmob\main.h" |
|
|
664 |
.................... |
|
|
665 |
.................... |
|
|
666 |
.................... void main() |
|
|
667 |
.................... { |
|
|
668 |
.................... |
|
|
669 |
.................... setup_adc_ports(NO_ANALOGS); |
|
|
670 |
.................... setup_adc(ADC_OFF); |
|
|
671 |
.................... setup_psp(PSP_DISABLED); |
|
|
672 |
.................... setup_spi(SPI_SS_DISABLED); |
|
|
673 |
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); |
|
|
674 |
.................... setup_timer_1(T1_DISABLED); |
|
|
675 |
.................... setup_timer_2(T2_DISABLED,0,1); |
|
|
676 |
.................... setup_comparator(NC_NC_NC_NC); |
|
|
677 |
.................... setup_vref(FALSE); |
|
|
678 |
.................... |
|
|
679 |
.................... // TODO: USER CODE!! |
|
|
680 |
.................... |
|
|
681 |
.................... }*/ |
|
|
682 |
013D: SLEEP |
|
|
683 |
|
|
|
684 |
Configuration Fuses: |
|
|
685 |
Word 1: 3F39 XT NOWDT NOPUT NODEBUG NOPROTECT NOBROWNOUT NOLVP NOCPD NOWRT |