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