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