169 |
kapl |
1 |
CCS PCM C Compiler, Version 4.059d, 15399 29-III-07 18:55 |
|
|
2 |
|
|
|
3 |
Filename: main.lst |
|
|
4 |
|
|
|
5 |
ROM used: 554 words (27%) |
|
|
6 |
Largest free fragment is 1494 |
|
|
7 |
RAM used: 18 (5%) at main() level |
|
|
8 |
32 (9%) worst case |
|
|
9 |
Stack: 5 locations |
|
|
10 |
|
|
|
11 |
* |
|
|
12 |
0000: MOVLW 00 |
|
|
13 |
0001: MOVWF 0A |
|
|
14 |
0002: GOTO 16F |
|
|
15 |
0003: NOP |
|
|
16 |
.................... #include "C:\RS\projekty\project1\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 |
001B: MOVLW 31 |
|
|
37 |
001C: MOVWF 04 |
|
|
38 |
001D: BCF 03.7 |
|
|
39 |
001E: MOVF 00,W |
|
|
40 |
001F: BTFSC 03.2 |
|
|
41 |
0020: GOTO 032 |
|
|
42 |
0021: MOVLW 01 |
|
|
43 |
0022: MOVWF 78 |
|
|
44 |
0023: MOVLW BF |
|
|
45 |
0024: MOVWF 77 |
|
|
46 |
0025: CLRWDT |
|
|
47 |
0026: DECFSZ 77,F |
|
|
48 |
0027: GOTO 025 |
|
|
49 |
0028: DECFSZ 78,F |
|
|
50 |
0029: GOTO 023 |
|
|
51 |
002A: MOVLW 4A |
|
|
52 |
002B: MOVWF 77 |
|
|
53 |
002C: DECFSZ 77,F |
|
|
54 |
002D: GOTO 02C |
|
|
55 |
002E: NOP |
|
|
56 |
002F: CLRWDT |
|
|
57 |
0030: DECFSZ 00,F |
|
|
58 |
0031: GOTO 021 |
|
|
59 |
0032: 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 |
0033: MOVF 07,W |
|
|
154 |
0034: ANDLW F0 |
|
|
155 |
0035: MOVWF 38 |
|
|
156 |
0036: MOVF 37,W |
|
|
157 |
0037: ANDLW 0F |
|
|
158 |
0038: IORWF 38,W |
|
|
159 |
0039: MOVWF 07 |
|
|
160 |
.................... output_bit(LCD_E,1); // vzestupna hrana |
|
|
161 |
003A: BSF 06.0 |
|
|
162 |
003B: BSF 03.5 |
|
|
163 |
003C: BCF 06.0 |
|
|
164 |
.................... delay_us(100); // pockej alespon 450ns od e nebo alespon 195ns od dat |
|
|
165 |
003D: CLRWDT |
|
|
166 |
003E: MOVLW 20 |
|
|
167 |
003F: MOVWF 77 |
|
|
168 |
0040: DECFSZ 77,F |
|
|
169 |
0041: GOTO 040 |
|
|
170 |
0042: GOTO 043 |
|
|
171 |
.................... output_bit(LCD_E,0); // sestupna hrana (minimalni perioda e je 1us) |
|
|
172 |
0043: BCF 03.5 |
|
|
173 |
0044: BCF 06.0 |
|
|
174 |
0045: BSF 03.5 |
|
|
175 |
0046: BCF 06.0 |
|
|
176 |
.................... } |
|
|
177 |
0047: BCF 03.5 |
|
|
178 |
0048: 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 |
0049: MOVF 35,F |
|
|
190 |
004A: BTFSS 03.2 |
|
|
191 |
004B: GOTO 04E |
|
|
192 |
004C: BCF 06.1 |
|
|
193 |
004D: GOTO 04F |
|
|
194 |
004E: BSF 06.1 |
|
|
195 |
004F: BSF 03.5 |
|
|
196 |
0050: BCF 06.1 |
|
|
197 |
.................... swap(n); |
|
|
198 |
0051: BCF 03.5 |
|
|
199 |
0052: SWAPF 36,F |
|
|
200 |
.................... lcd_send_nibble(n); // posli horni pulku bajtu |
|
|
201 |
0053: MOVF 36,W |
|
|
202 |
0054: MOVWF 37 |
|
|
203 |
0055: CALL 033 |
|
|
204 |
.................... swap(n); |
|
|
205 |
0056: SWAPF 36,F |
|
|
206 |
.................... lcd_send_nibble(n); // posli spodni pulku bajtu |
|
|
207 |
0057: MOVF 36,W |
|
|
208 |
0058: MOVWF 37 |
|
|
209 |
0059: CALL 033 |
|
|
210 |
.................... delay_us(200); // minimalni doba na provedeni prikazu |
|
|
211 |
005A: CLRWDT |
|
|
212 |
005B: MOVLW 42 |
|
|
213 |
005C: MOVWF 77 |
|
|
214 |
005D: DECFSZ 77,F |
|
|
215 |
005E: GOTO 05D |
|
|
216 |
.................... } |
|
|
217 |
005F: 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 |
0060: MOVLW 14 |
|
|
231 |
0061: MOVWF 31 |
|
|
232 |
0062: CALL 01B |
|
|
233 |
.................... |
|
|
234 |
.................... *LCD_TRIS = *LCD_TRIS & ~LCD_MASK; // nuluj odpovidajici bity tris registru datoveho portu LCD |
|
|
235 |
0063: MOVLW F0 |
|
|
236 |
0064: BSF 03.5 |
|
|
237 |
0065: ANDWF 07,F |
|
|
238 |
.................... |
|
|
239 |
.................... output_bit(LCD_RS,0); // nastav jako vystup a nastav klidovy stav |
|
|
240 |
0066: BCF 03.5 |
|
|
241 |
0067: BCF 06.1 |
|
|
242 |
0068: BSF 03.5 |
|
|
243 |
0069: BCF 06.1 |
|
|
244 |
.................... output_bit(LCD_E,0); // nastav jako vystup a nastav klidovy stav |
|
|
245 |
006A: BCF 03.5 |
|
|
246 |
006B: BCF 06.0 |
|
|
247 |
006C: BSF 03.5 |
|
|
248 |
006D: BCF 06.0 |
|
|
249 |
.................... |
|
|
250 |
.................... for (i=0; i<3; i++) // nastav lcd do rezimu 8 bitu sbernice |
|
|
251 |
006E: BCF 03.5 |
|
|
252 |
006F: CLRF 2A |
|
|
253 |
0070: MOVF 2A,W |
|
|
254 |
0071: SUBLW 02 |
|
|
255 |
0072: BTFSS 03.0 |
|
|
256 |
0073: GOTO 07C |
|
|
257 |
.................... { |
|
|
258 |
.................... delay_ms(2); // muze byt rozdelany prenos dat (2x 4 bity) nebo pomaly povel |
|
|
259 |
0074: MOVLW 02 |
|
|
260 |
0075: MOVWF 31 |
|
|
261 |
0076: CALL 01B |
|
|
262 |
.................... lcd_send_nibble(3); // rezim 8 bitu |
|
|
263 |
0077: MOVLW 03 |
|
|
264 |
0078: MOVWF 37 |
|
|
265 |
0079: CALL 033 |
|
|
266 |
.................... } |
|
|
267 |
007A: INCF 2A,F |
|
|
268 |
007B: GOTO 070 |
|
|
269 |
.................... |
|
|
270 |
.................... delay_us(40); // cas na zpracovani |
|
|
271 |
007C: CLRWDT |
|
|
272 |
007D: MOVLW 0C |
|
|
273 |
007E: MOVWF 77 |
|
|
274 |
007F: DECFSZ 77,F |
|
|
275 |
0080: GOTO 07F |
|
|
276 |
0081: GOTO 082 |
|
|
277 |
.................... lcd_send_nibble(2); // nastav rezim 4 bitu (plati od nasledujiciho prenosu) |
|
|
278 |
0082: MOVLW 02 |
|
|
279 |
0083: MOVWF 37 |
|
|
280 |
0084: CALL 033 |
|
|
281 |
.................... delay_us(40); // cas na zpracovani |
|
|
282 |
0085: CLRWDT |
|
|
283 |
0086: MOVLW 0C |
|
|
284 |
0087: MOVWF 77 |
|
|
285 |
0088: DECFSZ 77,F |
|
|
286 |
0089: GOTO 088 |
|
|
287 |
008A: GOTO 08B |
|
|
288 |
.................... |
|
|
289 |
.................... for (i=0;i<3;i++) // proved inicializaci (nastaveni modu, smazani apod) |
|
|
290 |
008B: CLRF 2A |
|
|
291 |
008C: MOVF 2A,W |
|
|
292 |
008D: SUBLW 02 |
|
|
293 |
008E: BTFSS 03.0 |
|
|
294 |
008F: GOTO 09C |
|
|
295 |
.................... { |
|
|
296 |
.................... lcd_send_byte(0,LCD_INIT_STRING[i]); |
|
|
297 |
0090: MOVF 2A,W |
|
|
298 |
0091: CALL 004 |
|
|
299 |
0092: MOVWF 2B |
|
|
300 |
0093: CLRF 35 |
|
|
301 |
0094: MOVF 2B,W |
|
|
302 |
0095: MOVWF 36 |
|
|
303 |
0096: CALL 049 |
|
|
304 |
.................... delay_ms(2); |
|
|
305 |
0097: MOVLW 02 |
|
|
306 |
0098: MOVWF 31 |
|
|
307 |
0099: CALL 01B |
|
|
308 |
.................... } |
|
|
309 |
009A: INCF 2A,F |
|
|
310 |
009B: GOTO 08C |
|
|
311 |
.................... } |
|
|
312 |
009C: GOTO 1C0 (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 |
009D: MOVLW 01 |
|
|
328 |
009E: SUBWF 32,W |
|
|
329 |
009F: ADDLW FC |
|
|
330 |
00A0: BTFSC 03.0 |
|
|
331 |
00A1: GOTO 0AF |
|
|
332 |
00A2: ADDLW 04 |
|
|
333 |
00A3: GOTO 0BA |
|
|
334 |
.................... case 1: Adr=0; break; |
|
|
335 |
00A4: CLRF 33 |
|
|
336 |
00A5: GOTO 0AF |
|
|
337 |
.................... case 2: Adr=0x40; break; |
|
|
338 |
00A6: MOVLW 40 |
|
|
339 |
00A7: MOVWF 33 |
|
|
340 |
00A8: GOTO 0AF |
|
|
341 |
.................... case 3: Adr=0x14; break; |
|
|
342 |
00A9: MOVLW 14 |
|
|
343 |
00AA: MOVWF 33 |
|
|
344 |
00AB: GOTO 0AF |
|
|
345 |
.................... case 4: Adr=0x54; break; |
|
|
346 |
00AC: MOVLW 54 |
|
|
347 |
00AD: MOVWF 33 |
|
|
348 |
00AE: GOTO 0AF |
|
|
349 |
.................... } |
|
|
350 |
.................... Adr+=x-1; |
|
|
351 |
00AF: MOVLW 01 |
|
|
352 |
00B0: SUBWF 31,W |
|
|
353 |
00B1: ADDWF 33,F |
|
|
354 |
.................... |
|
|
355 |
.................... lcd_send_byte(0,0x80|Adr); |
|
|
356 |
00B2: MOVF 33,W |
|
|
357 |
00B3: IORLW 80 |
|
|
358 |
00B4: MOVWF 34 |
|
|
359 |
00B5: CLRF 35 |
|
|
360 |
00B6: MOVF 34,W |
|
|
361 |
00B7: MOVWF 36 |
|
|
362 |
00B8: CALL 049 |
|
|
363 |
.................... } |
|
|
364 |
00B9: 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 |
00C2: MOVF 30,W |
|
|
377 |
00C3: XORLW 0C |
|
|
378 |
00C4: BTFSC 03.2 |
|
|
379 |
00C5: GOTO 0D0 |
|
|
380 |
00C6: XORLW 06 |
|
|
381 |
00C7: BTFSC 03.2 |
|
|
382 |
00C8: GOTO 0D8 |
|
|
383 |
00C9: XORLW 07 |
|
|
384 |
00CA: BTFSC 03.2 |
|
|
385 |
00CB: GOTO 0DE |
|
|
386 |
00CC: XORLW 05 |
|
|
387 |
00CD: BTFSC 03.2 |
|
|
388 |
00CE: GOTO 0E3 |
|
|
389 |
00CF: GOTO 0E8 |
|
|
390 |
.................... case '\f' : lcd_send_byte(0,1); // smaz displej |
|
|
391 |
00D0: CLRF 35 |
|
|
392 |
00D1: MOVLW 01 |
|
|
393 |
00D2: MOVWF 36 |
|
|
394 |
00D3: CALL 049 |
|
|
395 |
.................... delay_ms(2); |
|
|
396 |
00D4: MOVLW 02 |
|
|
397 |
00D5: MOVWF 31 |
|
|
398 |
00D6: CALL 01B |
|
|
399 |
.................... break; |
|
|
400 |
00D7: GOTO 0F4 |
|
|
401 |
.................... case '\n' : lcd_gotoxy(1,2); break; // presun se na 1. znak 2. radky |
|
|
402 |
00D8: MOVLW 01 |
|
|
403 |
00D9: MOVWF 31 |
|
|
404 |
00DA: MOVLW 02 |
|
|
405 |
00DB: MOVWF 32 |
|
|
406 |
00DC: CALL 09D |
|
|
407 |
00DD: GOTO 0F4 |
|
|
408 |
.................... case '\r' : lcd_gotoxy(1,1); break; // presun home |
|
|
409 |
00DE: MOVLW 01 |
|
|
410 |
00DF: MOVWF 31 |
|
|
411 |
00E0: MOVWF 32 |
|
|
412 |
00E1: CALL 09D |
|
|
413 |
00E2: GOTO 0F4 |
|
|
414 |
.................... case '\b' : lcd_send_byte(0,0x10); break; // posun kurzor o 1 zpet |
|
|
415 |
00E3: CLRF 35 |
|
|
416 |
00E4: MOVLW 10 |
|
|
417 |
00E5: MOVWF 36 |
|
|
418 |
00E6: CALL 049 |
|
|
419 |
00E7: GOTO 0F4 |
|
|
420 |
.................... default : if (c<0x20) c&=0x7; // preklopeni definovatelnych znaku na rozsah 0 az 0x1F |
|
|
421 |
00E8: MOVF 30,W |
|
|
422 |
00E9: SUBLW 1F |
|
|
423 |
00EA: BTFSS 03.0 |
|
|
424 |
00EB: GOTO 0EE |
|
|
425 |
00EC: MOVLW 07 |
|
|
426 |
00ED: ANDWF 30,F |
|
|
427 |
.................... lcd_send_byte(1,c); break; // zapis znak |
|
|
428 |
00EE: MOVLW 01 |
|
|
429 |
00EF: MOVWF 35 |
|
|
430 |
00F0: MOVF 30,W |
|
|
431 |
00F1: MOVWF 36 |
|
|
432 |
00F2: CALL 049 |
|
|
433 |
00F3: GOTO 0F4 |
|
|
434 |
.................... } |
|
|
435 |
.................... } |
|
|
436 |
00F4: 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 |
.................... void main() |
|
|
537 |
.................... { |
|
|
538 |
* |
|
|
539 |
016F: CLRF 04 |
|
|
540 |
0170: BCF 03.7 |
|
|
541 |
0171: MOVLW 1F |
|
|
542 |
0172: ANDWF 03,F |
|
|
543 |
0173: MOVLW 0C |
|
|
544 |
0174: BSF 03.5 |
|
|
545 |
0175: MOVWF 19 |
|
|
546 |
0176: MOVLW A6 |
|
|
547 |
0177: MOVWF 18 |
|
|
548 |
0178: MOVLW 90 |
|
|
549 |
0179: BCF 03.5 |
|
|
550 |
017A: MOVWF 18 |
|
|
551 |
017B: BSF 03.5 |
|
|
552 |
017C: BSF 1F.0 |
|
|
553 |
017D: BSF 1F.1 |
|
|
554 |
017E: BSF 1F.2 |
|
|
555 |
017F: BCF 1F.3 |
|
|
556 |
0180: MOVLW 07 |
|
|
557 |
0181: MOVWF 1C |
|
|
558 |
.................... int odp[8]; |
|
|
559 |
.................... int i; |
|
|
560 |
.................... setup_adc_ports(NO_ANALOGS); |
|
|
561 |
* |
|
|
562 |
0185: BSF 03.5 |
|
|
563 |
0186: BSF 1F.0 |
|
|
564 |
0187: BSF 1F.1 |
|
|
565 |
0188: BSF 1F.2 |
|
|
566 |
0189: BCF 1F.3 |
|
|
567 |
.................... setup_adc(ADC_OFF); |
|
|
568 |
018A: BCF 03.5 |
|
|
569 |
018B: BCF 1F.0 |
|
|
570 |
.................... setup_psp(PSP_DISABLED); |
|
|
571 |
018C: BSF 03.5 |
|
|
572 |
018D: BCF 09.4 |
|
|
573 |
.................... setup_spi(SPI_SS_DISABLED); |
|
|
574 |
* |
|
|
575 |
0182: MOVLW FF |
|
|
576 |
0183: BCF 03.5 |
|
|
577 |
0184: MOVWF 20 |
|
|
578 |
* |
|
|
579 |
018E: BCF 03.5 |
|
|
580 |
018F: BCF 14.5 |
|
|
581 |
0190: BCF 20.5 |
|
|
582 |
0191: MOVF 20,W |
|
|
583 |
0192: BSF 03.5 |
|
|
584 |
0193: MOVWF 07 |
|
|
585 |
0194: BCF 03.5 |
|
|
586 |
0195: BSF 20.4 |
|
|
587 |
0196: MOVF 20,W |
|
|
588 |
0197: BSF 03.5 |
|
|
589 |
0198: MOVWF 07 |
|
|
590 |
0199: BCF 03.5 |
|
|
591 |
019A: BCF 20.3 |
|
|
592 |
019B: MOVF 20,W |
|
|
593 |
019C: BSF 03.5 |
|
|
594 |
019D: MOVWF 07 |
|
|
595 |
019E: MOVLW 01 |
|
|
596 |
019F: BCF 03.5 |
|
|
597 |
01A0: MOVWF 14 |
|
|
598 |
01A1: MOVLW 00 |
|
|
599 |
01A2: BSF 03.5 |
|
|
600 |
01A3: MOVWF 14 |
|
|
601 |
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); |
|
|
602 |
01A4: MOVF 01,W |
|
|
603 |
01A5: ANDLW C7 |
|
|
604 |
01A6: IORLW 08 |
|
|
605 |
01A7: MOVWF 01 |
|
|
606 |
.................... setup_timer_1(T1_DISABLED); |
|
|
607 |
01A8: BCF 03.5 |
|
|
608 |
01A9: CLRF 10 |
|
|
609 |
.................... setup_timer_2(T2_DISABLED,0,1); |
|
|
610 |
01AA: MOVLW 00 |
|
|
611 |
01AB: MOVWF 78 |
|
|
612 |
01AC: MOVWF 12 |
|
|
613 |
01AD: MOVLW 00 |
|
|
614 |
01AE: BSF 03.5 |
|
|
615 |
01AF: MOVWF 12 |
|
|
616 |
.................... setup_comparator(NC_NC_NC_NC); |
|
|
617 |
01B0: MOVLW 07 |
|
|
618 |
01B1: MOVWF 1C |
|
|
619 |
01B2: MOVF 05,W |
|
|
620 |
01B3: CLRWDT |
|
|
621 |
01B4: MOVLW 02 |
|
|
622 |
01B5: MOVWF 77 |
|
|
623 |
01B6: DECFSZ 77,F |
|
|
624 |
01B7: GOTO 1B6 |
|
|
625 |
01B8: GOTO 1B9 |
|
|
626 |
01B9: MOVF 1C,W |
|
|
627 |
01BA: BCF 03.5 |
|
|
628 |
01BB: BCF 0D.6 |
|
|
629 |
.................... setup_vref(FALSE); |
|
|
630 |
01BC: BSF 03.5 |
|
|
631 |
01BD: CLRF 1D |
|
|
632 |
.................... lcd_init(); |
|
|
633 |
01BE: BCF 03.5 |
|
|
634 |
01BF: GOTO 060 |
|
|
635 |
.................... delay_ms(100); |
|
|
636 |
01C0: MOVLW 64 |
|
|
637 |
01C1: MOVWF 31 |
|
|
638 |
01C2: CALL 01B |
|
|
639 |
.................... |
|
|
640 |
.................... printf("AT+CMGL=1\r"); //vycti prijate SMS |
|
|
641 |
01C3: CLRF 2A |
|
|
642 |
01C4: MOVF 2A,W |
|
|
643 |
01C5: CALL 00C |
|
|
644 |
01C6: INCF 2A,F |
|
|
645 |
01C7: MOVWF 77 |
|
|
646 |
01C8: MOVF 77,W |
|
|
647 |
01C9: BTFSS 0C.4 |
|
|
648 |
01CA: GOTO 1C9 |
|
|
649 |
01CB: MOVWF 19 |
|
|
650 |
01CC: MOVLW 0A |
|
|
651 |
01CD: SUBWF 2A,W |
|
|
652 |
01CE: BTFSS 03.2 |
|
|
653 |
01CF: GOTO 1C4 |
|
|
654 |
.................... gets(odp); //uloz odpoved prikazu do odp |
|
|
655 |
01D0: MOVLW 21 |
|
|
656 |
01D1: MOVWF 04 |
|
|
657 |
01D2: BCF 03.7 |
|
|
658 |
01D3: DECF 04,F |
|
|
659 |
01D4: INCF 04,F |
|
|
660 |
01D5: BTFSS 0C.5 |
|
|
661 |
01D6: GOTO 1D5 |
|
|
662 |
01D7: MOVF 1A,W |
|
|
663 |
01D8: MOVWF 00 |
|
|
664 |
01D9: MOVLW 0D |
|
|
665 |
01DA: SUBWF 00,W |
|
|
666 |
01DB: BTFSS 03.2 |
|
|
667 |
01DC: GOTO 1D4 |
|
|
668 |
01DD: CLRF 00 |
|
|
669 |
.................... getc(); //preskoc 0A |
|
|
670 |
01DE: BTFSS 0C.5 |
|
|
671 |
01DF: GOTO 1DE |
|
|
672 |
01E0: MOVF 1A,W |
|
|
673 |
.................... getc(); //preskoc 0D |
|
|
674 |
01E1: BTFSS 0C.5 |
|
|
675 |
01E2: GOTO 1E1 |
|
|
676 |
01E3: MOVF 1A,W |
|
|
677 |
.................... gets(odp); //uloz pocatek odpovedi do odp |
|
|
678 |
01E4: MOVLW 21 |
|
|
679 |
01E5: MOVWF 04 |
|
|
680 |
01E6: BCF 03.7 |
|
|
681 |
01E7: DECF 04,F |
|
|
682 |
01E8: INCF 04,F |
|
|
683 |
01E9: BTFSS 0C.5 |
|
|
684 |
01EA: GOTO 1E9 |
|
|
685 |
01EB: MOVF 1A,W |
|
|
686 |
01EC: MOVWF 00 |
|
|
687 |
01ED: MOVLW 0D |
|
|
688 |
01EE: SUBWF 00,W |
|
|
689 |
01EF: BTFSS 03.2 |
|
|
690 |
01F0: GOTO 1E8 |
|
|
691 |
01F1: CLRF 00 |
|
|
692 |
.................... for(i=0;i<55;i++) //preskoc nedulezite informace |
|
|
693 |
01F2: CLRF 29 |
|
|
694 |
01F3: MOVF 29,W |
|
|
695 |
01F4: SUBLW 36 |
|
|
696 |
01F5: BTFSS 03.0 |
|
|
697 |
01F6: GOTO 1FC |
|
|
698 |
.................... { |
|
|
699 |
.................... getc(); |
|
|
700 |
01F7: BTFSS 0C.5 |
|
|
701 |
01F8: GOTO 1F7 |
|
|
702 |
01F9: MOVF 1A,W |
|
|
703 |
.................... } |
|
|
704 |
01FA: INCF 29,F |
|
|
705 |
01FB: GOTO 1F3 |
|
|
706 |
.................... gets(odp); //uloz zakodovany text SMS |
|
|
707 |
01FC: MOVLW 21 |
|
|
708 |
01FD: MOVWF 04 |
|
|
709 |
01FE: BCF 03.7 |
|
|
710 |
01FF: DECF 04,F |
|
|
711 |
0200: INCF 04,F |
|
|
712 |
0201: BTFSS 0C.5 |
|
|
713 |
0202: GOTO 201 |
|
|
714 |
0203: MOVF 1A,W |
|
|
715 |
0204: MOVWF 00 |
|
|
716 |
0205: MOVLW 0D |
|
|
717 |
0206: SUBWF 00,W |
|
|
718 |
0207: BTFSS 03.2 |
|
|
719 |
0208: GOTO 200 |
|
|
720 |
0209: CLRF 00 |
|
|
721 |
.................... printf(lcd_putc,"%s\n",odp); |
|
|
722 |
020A: MOVLW 21 |
|
|
723 |
020B: MOVWF 04 |
|
|
724 |
020C: BCF 03.7 |
|
|
725 |
020D: MOVLW 00 |
|
|
726 |
020E: IORWF 00,W |
|
|
727 |
020F: BTFSC 03.2 |
|
|
728 |
0210: GOTO 221 |
|
|
729 |
0211: CLRF 2B |
|
|
730 |
0212: MOVF 04,W |
|
|
731 |
0213: MOVWF 2A |
|
|
732 |
0214: BCF 2B.0 |
|
|
733 |
0215: BTFSC 03.7 |
|
|
734 |
0216: BSF 2B.0 |
|
|
735 |
0217: MOVF 00,W |
|
|
736 |
0218: MOVWF 30 |
|
|
737 |
0219: CALL 0C2 |
|
|
738 |
021A: MOVF 2A,W |
|
|
739 |
021B: MOVWF 04 |
|
|
740 |
021C: BCF 03.7 |
|
|
741 |
021D: BTFSC 2B.0 |
|
|
742 |
021E: BSF 03.7 |
|
|
743 |
021F: INCF 04,F |
|
|
744 |
0220: GOTO 20D |
|
|
745 |
0221: MOVLW 0A |
|
|
746 |
0222: MOVWF 30 |
|
|
747 |
0223: CALL 0C2 |
|
|
748 |
.................... printf(lcd_putc,"%d",odp[0]); |
|
|
749 |
0224: MOVF 21,W |
|
|
750 |
0225: MOVWF 2A |
|
|
751 |
0226: MOVLW 1F |
|
|
752 |
0227: MOVWF 2B |
|
|
753 |
0228: GOTO 10A |
|
|
754 |
.................... |
|
|
755 |
.................... } |
|
|
756 |
0229: SLEEP |
|
|
757 |
|
|
|
758 |
Configuration Fuses: |
|
|
759 |
Word 1: 3F39 XT NOWDT NOPUT NODEBUG NOPROTECT NOBROWNOUT NOLVP NOCPD NOWRT |