1045 |
jacho |
1 |
CCS PCM C Compiler, Version 4.106, 47914 03-4-13 15:28 |
|
|
2 |
|
|
|
3 |
Filename: C:\Users\Honza\Documents\pic\tomas\main.lst |
|
|
4 |
|
|
|
5 |
ROM used: 1258 words (15%) |
|
|
6 |
Largest free fragment is 2048 |
|
|
7 |
RAM used: 23 (6%) at main() level |
|
|
8 |
48 (13%) worst case |
|
|
9 |
Stack: 6 worst case (5 in main + 1 for interrupts) |
|
|
10 |
|
|
|
11 |
* |
|
|
12 |
0000: MOVLW 03 |
|
|
13 |
0001: MOVWF 0A |
|
|
14 |
0002: GOTO 38E |
|
|
15 |
0003: NOP |
|
|
16 |
0004: MOVWF 7F |
|
|
17 |
0005: SWAPF 03,W |
|
|
18 |
0006: CLRF 03 |
|
|
19 |
0007: MOVWF 21 |
|
|
20 |
0008: MOVF 0A,W |
|
|
21 |
0009: MOVWF 20 |
|
|
22 |
000A: CLRF 0A |
|
|
23 |
000B: MOVF 04,W |
|
|
24 |
000C: MOVWF 22 |
|
|
25 |
000D: MOVF 77,W |
|
|
26 |
000E: MOVWF 23 |
|
|
27 |
000F: MOVF 78,W |
|
|
28 |
0010: MOVWF 24 |
|
|
29 |
0011: MOVF 79,W |
|
|
30 |
0012: MOVWF 25 |
|
|
31 |
0013: MOVF 7A,W |
|
|
32 |
0014: MOVWF 26 |
|
|
33 |
0015: BCF 03.7 |
|
|
34 |
0016: BCF 03.5 |
|
|
35 |
0017: BTFSS 0B.4 |
|
|
36 |
0018: GOTO 01B |
|
|
37 |
0019: BTFSC 0B.1 |
|
|
38 |
001A: GOTO 02C |
|
|
39 |
001B: MOVF 22,W |
|
|
40 |
001C: MOVWF 04 |
|
|
41 |
001D: MOVF 23,W |
|
|
42 |
001E: MOVWF 77 |
|
|
43 |
001F: MOVF 24,W |
|
|
44 |
0020: MOVWF 78 |
|
|
45 |
0021: MOVF 25,W |
|
|
46 |
0022: MOVWF 79 |
|
|
47 |
0023: MOVF 26,W |
|
|
48 |
0024: MOVWF 7A |
|
|
49 |
0025: MOVF 20,W |
|
|
50 |
0026: MOVWF 0A |
|
|
51 |
0027: SWAPF 21,W |
|
|
52 |
0028: MOVWF 03 |
|
|
53 |
0029: SWAPF 7F,F |
|
|
54 |
002A: SWAPF 7F,W |
|
|
55 |
002B: RETFIE |
|
|
56 |
002C: BCF 0A.3 |
|
|
57 |
002D: BCF 0A.4 |
|
|
58 |
002E: GOTO 037 |
|
|
59 |
.................... #include "C:\Users\Honza\Documents\pic\tomas\main.h" |
|
|
60 |
.................... #include <16F887.h> |
|
|
61 |
.................... //////// Standard Header file for the PIC16F887 device //////////////// |
|
|
62 |
.................... #device PIC16F887 |
|
|
63 |
.................... #list |
|
|
64 |
.................... |
|
|
65 |
.................... #device adc=8 |
|
|
66 |
.................... |
|
|
67 |
.................... #FUSES NOWDT //No Watch Dog Timer |
|
|
68 |
.................... #FUSES INTRC //Internal RC Osc |
|
|
69 |
.................... #FUSES NOPUT //No Power Up Timer |
|
|
70 |
.................... #FUSES MCLR //Master Clear pin enabled |
|
|
71 |
.................... #FUSES NOPROTECT //Code not protected from reading |
|
|
72 |
.................... #FUSES NOCPD //No EE protection |
|
|
73 |
.................... #FUSES NOBROWNOUT //No brownout reset |
|
|
74 |
.................... #FUSES IESO //Internal External Switch Over mode enabled |
|
|
75 |
.................... #FUSES FCMEN //Fail-safe clock monitor enabled |
|
|
76 |
.................... #FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O |
|
|
77 |
.................... #FUSES NODEBUG //No Debug mode for ICD |
|
|
78 |
.................... #FUSES NOWRT //Program memory not write protected |
|
|
79 |
.................... #FUSES BORV40 //Brownout reset at 4.0V |
|
|
80 |
.................... |
|
|
81 |
.................... #use delay(clock=8000000) |
|
|
82 |
* |
|
|
83 |
006C: MOVLW 3F |
|
|
84 |
006D: MOVWF 04 |
|
|
85 |
006E: BCF 03.7 |
|
|
86 |
006F: MOVF 00,W |
|
|
87 |
0070: BTFSC 03.2 |
|
|
88 |
0071: GOTO 07F |
|
|
89 |
0072: MOVLW 02 |
|
|
90 |
0073: MOVWF 78 |
|
|
91 |
0074: CLRF 77 |
|
|
92 |
0075: DECFSZ 77,F |
|
|
93 |
0076: GOTO 075 |
|
|
94 |
0077: DECFSZ 78,F |
|
|
95 |
0078: GOTO 074 |
|
|
96 |
0079: MOVLW 97 |
|
|
97 |
007A: MOVWF 77 |
|
|
98 |
007B: DECFSZ 77,F |
|
|
99 |
007C: GOTO 07B |
|
|
100 |
007D: DECFSZ 00,F |
|
|
101 |
007E: GOTO 072 |
|
|
102 |
007F: RETURN |
|
|
103 |
.................... |
|
|
104 |
.................... |
|
|
105 |
.................... |
|
|
106 |
.................... #define LCD_RS PIN_C7 // rizeni registru LCD displeje <lcd.c> |
|
|
107 |
.................... #define LCD_E PIN_B7 // enable LCD displeje <lcd.c> |
|
|
108 |
.................... #define LCD_D0 PIN_B6 // data LCD <lcd.c> |
|
|
109 |
.................... #define LCD_D1 PIN_B5 |
|
|
110 |
.................... #define LCD_D2 PIN_B4 |
|
|
111 |
.................... #define LCD_D3 PIN_D4 |
|
|
112 |
.................... #include "LCD.C" //pro LCD |
|
|
113 |
.................... // LCD modul pro ovladani dvouradkoveho LCD modulu se standardnim Hitachi radicem |
|
|
114 |
.................... // (c)miho 2002,2005 |
|
|
115 |
.................... // |
|
|
116 |
.................... // Historie: |
|
|
117 |
.................... // |
|
|
118 |
.................... // 0.00 Uvodni verze se snadnou definici portu LCD displeje |
|
|
119 |
.................... // 0.01 Oprava portu (zapomenute stare identifikatory) |
|
|
120 |
.................... // 0.02 Doplnena moznost pripojeni datoveho portu LCD na libovolne porty |
|
|
121 |
.................... // 0.03 Doplnena procedura lcd_clr pro smazani displeje |
|
|
122 |
.................... // |
|
|
123 |
.................... // |
|
|
124 |
.................... // Funkce: |
|
|
125 |
.................... // |
|
|
126 |
.................... // lcd_init() inicializuje LCD displej a porty, nutno volat jako prvni |
|
|
127 |
.................... // |
|
|
128 |
.................... // lcd_putc(c) zapis snaku do lcd displeje, zpracovava nasledujici ridici znaky |
|
|
129 |
.................... // \f = \x0C - nova stranka - smazani displeje |
|
|
130 |
.................... // \n = \x0A - odradkovani (prechod na druhou radku) |
|
|
131 |
.................... // \b = \x08 - backspace - posunuti kurzoru o 1 pozici zpet |
|
|
132 |
.................... // \r = \x0D - goto home to position 1,1 |
|
|
133 |
.................... // \0 .. \7 - definovatelne znaky v pozicich 0 az 7 v CGRAM |
|
|
134 |
.................... // \20 .. \27 - alternativne zapsane znaky (oktalove) v pozicich 0 az 7 CGRAM |
|
|
135 |
.................... // Pozor na to, ze funkce printf konci tisk pokud narazi na \0 (konec retezce) |
|
|
136 |
.................... // |
|
|
137 |
.................... // lcd_gotoxy(x,y) presune kurzor na uvedenou adresu |
|
|
138 |
.................... // nekontroluje parametry |
|
|
139 |
.................... // |
|
|
140 |
.................... // lcd_cursor_on zapne kurzor |
|
|
141 |
.................... // lcd_cursor_off vypne kurzor |
|
|
142 |
.................... // |
|
|
143 |
.................... // lcd_clr smaze displej |
|
|
144 |
.................... // |
|
|
145 |
.................... // lcd_define_char(Index, Def) Makro, ktere definuje znaky od pozice Index obsahem definicniho |
|
|
146 |
.................... // retezce Def. Kazdych 8 znaku retezce Def definuje dalsi znak v CGRAM. |
|
|
147 |
.................... // Kapacita CGRAM je celkem 8 znaku s indexem 0 az 7. |
|
|
148 |
.................... // Na konci se provede lcd_gotoxy(1,1). |
|
|
149 |
.................... // Na konci teto knihovny je priklad pouziti definovanych znaku |
|
|
150 |
.................... // |
|
|
151 |
.................... // |
|
|
152 |
.................... // Definice portu: // Datovy port displeje pripojeny na 4 bity za sebou na jeden port |
|
|
153 |
.................... // |
|
|
154 |
.................... // #define LCD_RS PIN_B2 // rizeni registru LCD displeje |
|
|
155 |
.................... // #define LCD_E PIN_B1 // enable LCD displeje |
|
|
156 |
.................... // #define LCD_DATA_LSB PIN_C2 // pripojeni LSB bitu datoveho portu LCD displeje (celkem 4 bity vzestupne za sebou) |
|
|
157 |
.................... // |
|
|
158 |
.................... // |
|
|
159 |
.................... // Alternativni definice: // Datovy port displeje pripojeny na libovolne 4 bitove porty (vede na kod delsi asi o 25 slov) |
|
|
160 |
.................... // |
|
|
161 |
.................... // #define LCD_RS PIN_B2 // rizeni registru LCD displeje |
|
|
162 |
.................... // #define LCD_E PIN_B1 // enable LCD displeje |
|
|
163 |
.................... // #define LCD_D0 PIN_C2 // D0 - datove bity pripojene na libovolne porty |
|
|
164 |
.................... // #define LCD_D1 PIN_C3 // D1 |
|
|
165 |
.................... // #define LCD_D2 PIN_C4 // D2 |
|
|
166 |
.................... // #define LCD_D3 PIN_C5 // D3 |
|
|
167 |
.................... |
|
|
168 |
.................... |
|
|
169 |
.................... |
|
|
170 |
.................... |
|
|
171 |
.................... // Privatni sekce, cist jen v pripade, ze neco nefunguje |
|
|
172 |
.................... |
|
|
173 |
.................... |
|
|
174 |
.................... |
|
|
175 |
.................... |
|
|
176 |
.................... #ifdef LCD_DATA_LSB |
|
|
177 |
.................... // Generovane defince portu pro ucely teto knihovny aby kod generoval spravne IO operace a soucasne |
|
|
178 |
.................... // bylo mozne jednoduse deklarovat pripojene piny LCD displeje pri pouziti teto knihovny. Problem spociva |
|
|
179 |
.................... // v tom, ze se musi spravne ridit smery portu a soucasne datovy port zabira jen 4 bity ze zadaneho portu |
|
|
180 |
.................... // |
|
|
181 |
.................... #define LCD_SHIFT (LCD_DATA_LSB&7) // pocet bitu posuvu datoveho kanalu v datovem portu |
|
|
182 |
.................... #define LCD_PORT (LCD_DATA_LSB>>3) // adresa LCD datoveho portu |
|
|
183 |
.................... #define LCD_TRIS (LCD_PORT+0x80) // adresa prislusneho TRIS registru |
|
|
184 |
.................... #define LCD_MASK (0xF<<LCD_SHIFT) // maska platnych bitu |
|
|
185 |
.................... // |
|
|
186 |
.................... #if LCD_SHIFT>4 // kontrola mezi |
|
|
187 |
.................... #error LCD data port LSB bit not in range 0..4 |
|
|
188 |
.................... #endif |
|
|
189 |
.................... #endif |
|
|
190 |
.................... |
|
|
191 |
.................... |
|
|
192 |
.................... // Definice konstant pro LCD display |
|
|
193 |
.................... // |
|
|
194 |
.................... #define LCD_CURSOR_ON_ 0x0E // kurzor jako blikajici radka pod znakem |
|
|
195 |
.................... #define LCD_CURSOR_OFF_ 0x0C // zadny kurzor |
|
|
196 |
.................... #define LCD_LINE_2 0x40 // adresa 1. znaku 2. radky |
|
|
197 |
.................... |
|
|
198 |
.................... |
|
|
199 |
.................... // Definice rezimu LCD displeje |
|
|
200 |
.................... // |
|
|
201 |
.................... BYTE const LCD_INIT_STRING[4] = |
|
|
202 |
.................... { |
|
|
203 |
.................... 0x28, // intrfejs 4 bity, 2 radky, font 5x7 |
|
|
204 |
.................... LCD_CURSOR_OFF_, // display on, kurzor off, |
|
|
205 |
.................... 0x01, // clear displeje |
|
|
206 |
.................... 0x06 // inkrement pozice kurzoru (posun kurzoru doprava) |
|
|
207 |
.................... }; |
|
|
208 |
.................... |
|
|
209 |
.................... |
|
|
210 |
.................... // Odesle nibble do displeje (posle data a klikne signalem e) |
|
|
211 |
.................... // |
|
|
212 |
.................... void lcd_send_nibble( BYTE n ) |
|
|
213 |
.................... { |
|
|
214 |
.................... #ifdef LCD_DATA_LSB |
|
|
215 |
.................... // data jsou za sebou na 4 bitech jednoho portu |
|
|
216 |
.................... *LCD_PORT = (*LCD_PORT & ~LCD_MASK) | ((n << LCD_SHIFT) & LCD_MASK); // nastav datove bity portu a ostatni zachovej |
|
|
217 |
.................... #else |
|
|
218 |
.................... // data jsou na libovolnych 4 bitech libovolnych portu |
|
|
219 |
.................... output_bit(LCD_D0,bit_test(n,0)); |
|
|
220 |
0080: BTFSC 45.0 |
|
|
221 |
0081: GOTO 084 |
|
|
222 |
0082: BCF 06.6 |
|
|
223 |
0083: GOTO 085 |
|
|
224 |
0084: BSF 06.6 |
|
|
225 |
0085: BSF 03.5 |
|
|
226 |
0086: BCF 06.6 |
|
|
227 |
.................... output_bit(LCD_D1,bit_test(n,1)); |
|
|
228 |
0087: BCF 03.5 |
|
|
229 |
0088: BTFSC 45.1 |
|
|
230 |
0089: GOTO 08C |
|
|
231 |
008A: BCF 06.5 |
|
|
232 |
008B: GOTO 08D |
|
|
233 |
008C: BSF 06.5 |
|
|
234 |
008D: BSF 03.5 |
|
|
235 |
008E: BCF 06.5 |
|
|
236 |
.................... output_bit(LCD_D2,bit_test(n,2)); |
|
|
237 |
008F: BCF 03.5 |
|
|
238 |
0090: BTFSC 45.2 |
|
|
239 |
0091: GOTO 094 |
|
|
240 |
0092: BCF 06.4 |
|
|
241 |
0093: GOTO 095 |
|
|
242 |
0094: BSF 06.4 |
|
|
243 |
0095: BSF 03.5 |
|
|
244 |
0096: BCF 06.4 |
|
|
245 |
.................... output_bit(LCD_D3,bit_test(n,3)); |
|
|
246 |
0097: BCF 03.5 |
|
|
247 |
0098: BTFSC 45.3 |
|
|
248 |
0099: GOTO 09C |
|
|
249 |
009A: BCF 08.4 |
|
|
250 |
009B: GOTO 09D |
|
|
251 |
009C: BSF 08.4 |
|
|
252 |
009D: BSF 03.5 |
|
|
253 |
009E: BCF 08.4 |
|
|
254 |
.................... #endif |
|
|
255 |
.................... output_bit(LCD_E,1); // vzestupna hrana |
|
|
256 |
009F: BCF 03.5 |
|
|
257 |
00A0: BSF 06.7 |
|
|
258 |
00A1: BSF 03.5 |
|
|
259 |
00A2: BCF 06.7 |
|
|
260 |
.................... delay_us(1); // pockej alespon 450ns od e nebo alespon 195ns od dat |
|
|
261 |
00A3: GOTO 0A4 |
|
|
262 |
.................... output_bit(LCD_E,0); // sestupna hrana (minimalni perioda e je 1us) |
|
|
263 |
00A4: BCF 03.5 |
|
|
264 |
00A5: BCF 06.7 |
|
|
265 |
00A6: BSF 03.5 |
|
|
266 |
00A7: BCF 06.7 |
|
|
267 |
.................... } |
|
|
268 |
00A8: BCF 03.5 |
|
|
269 |
00A9: RETURN |
|
|
270 |
.................... |
|
|
271 |
.................... |
|
|
272 |
.................... // Odesle bajt do registru LCD |
|
|
273 |
.................... // |
|
|
274 |
.................... // Pokud je Adr=0 .. instrukcni registr |
|
|
275 |
.................... // Pokud je Adr=1 .. datovy registr |
|
|
276 |
.................... // |
|
|
277 |
.................... void lcd_send_byte( BOOLEAN Adr, BYTE n ) |
|
|
278 |
.................... { |
|
|
279 |
.................... output_bit(LCD_RS,Adr); // vyber registr |
|
|
280 |
00AA: MOVF 43,F |
|
|
281 |
00AB: BTFSS 03.2 |
|
|
282 |
00AC: GOTO 0AF |
|
|
283 |
00AD: BCF 07.7 |
|
|
284 |
00AE: GOTO 0B0 |
|
|
285 |
00AF: BSF 07.7 |
|
|
286 |
00B0: BCF 27.7 |
|
|
287 |
00B1: MOVF 27,W |
|
|
288 |
00B2: BSF 03.5 |
|
|
289 |
00B3: MOVWF 07 |
|
|
290 |
.................... swap(n); |
|
|
291 |
00B4: BCF 03.5 |
|
|
292 |
00B5: SWAPF 44,F |
|
|
293 |
.................... lcd_send_nibble(n); // posli horni pulku bajtu |
|
|
294 |
00B6: MOVF 44,W |
|
|
295 |
00B7: MOVWF 45 |
|
|
296 |
00B8: CALL 080 |
|
|
297 |
.................... swap(n); |
|
|
298 |
00B9: SWAPF 44,F |
|
|
299 |
.................... lcd_send_nibble(n); // posli spodni pulku bajtu |
|
|
300 |
00BA: MOVF 44,W |
|
|
301 |
00BB: MOVWF 45 |
|
|
302 |
00BC: CALL 080 |
|
|
303 |
.................... delay_us(40); // minimalni doba na provedeni prikazu |
|
|
304 |
00BD: MOVLW 1A |
|
|
305 |
00BE: MOVWF 77 |
|
|
306 |
00BF: DECFSZ 77,F |
|
|
307 |
00C0: GOTO 0BF |
|
|
308 |
00C1: NOP |
|
|
309 |
.................... } |
|
|
310 |
00C2: RETURN |
|
|
311 |
.................... |
|
|
312 |
.................... |
|
|
313 |
.................... // Provede inicializaci LCD displeje, smaze obsah a nastavi mod displeje |
|
|
314 |
.................... // |
|
|
315 |
.................... // Tato procedura se musi volat pred pouzitim ostatnich lcd_ procedur |
|
|
316 |
.................... // |
|
|
317 |
.................... void lcd_init() |
|
|
318 |
.................... { |
|
|
319 |
.................... |
|
|
320 |
.................... int i; // pocitadlo cyklu |
|
|
321 |
.................... |
|
|
322 |
.................... delay_ms(20); // spozdeni pro provedeni startu displeje po zapnuti napajeni |
|
|
323 |
00C3: MOVLW 14 |
|
|
324 |
00C4: MOVWF 3F |
|
|
325 |
00C5: CALL 06C |
|
|
326 |
.................... |
|
|
327 |
.................... #ifdef LCD_DATA_LSB |
|
|
328 |
.................... // data jsou na 4 bitech za sebou, nastav smer pro vsechny dalsi prenosy |
|
|
329 |
.................... *LCD_TRIS = *LCD_TRIS & ~LCD_MASK; // nuluj odpovidajici bity tris registru datoveho portu LCD |
|
|
330 |
.................... #endif |
|
|
331 |
.................... |
|
|
332 |
.................... output_bit(LCD_RS,0); // nastav jako vystup a nastav klidovy stav |
|
|
333 |
00C6: BCF 07.7 |
|
|
334 |
00C7: BCF 27.7 |
|
|
335 |
00C8: MOVF 27,W |
|
|
336 |
00C9: BSF 03.5 |
|
|
337 |
00CA: MOVWF 07 |
|
|
338 |
.................... output_bit(LCD_E, 0); // nastav jako vystup a nastav klidovy stav |
|
|
339 |
00CB: BCF 03.5 |
|
|
340 |
00CC: BCF 06.7 |
|
|
341 |
00CD: BSF 03.5 |
|
|
342 |
00CE: BCF 06.7 |
|
|
343 |
.................... |
|
|
344 |
.................... for (i=0; i<3; i++) // nastav lcd do rezimu 8 bitu sbernice |
|
|
345 |
00CF: BCF 03.5 |
|
|
346 |
00D0: CLRF 31 |
|
|
347 |
00D1: MOVF 31,W |
|
|
348 |
00D2: SUBLW 02 |
|
|
349 |
00D3: BTFSS 03.0 |
|
|
350 |
00D4: GOTO 0DD |
|
|
351 |
.................... { |
|
|
352 |
.................... delay_ms(2); // muze byt rozdelany prenos dat (2x 4 bity) nebo pomaly povel |
|
|
353 |
00D5: MOVLW 02 |
|
|
354 |
00D6: MOVWF 3F |
|
|
355 |
00D7: CALL 06C |
|
|
356 |
.................... lcd_send_nibble(3); // rezim 8 bitu |
|
|
357 |
00D8: MOVLW 03 |
|
|
358 |
00D9: MOVWF 45 |
|
|
359 |
00DA: CALL 080 |
|
|
360 |
.................... } |
|
|
361 |
00DB: INCF 31,F |
|
|
362 |
00DC: GOTO 0D1 |
|
|
363 |
.................... |
|
|
364 |
.................... delay_us(40); // cas na zpracovani |
|
|
365 |
00DD: MOVLW 1A |
|
|
366 |
00DE: MOVWF 77 |
|
|
367 |
00DF: DECFSZ 77,F |
|
|
368 |
00E0: GOTO 0DF |
|
|
369 |
00E1: NOP |
|
|
370 |
.................... lcd_send_nibble(2); // nastav rezim 4 bitu (plati od nasledujiciho prenosu) |
|
|
371 |
00E2: MOVLW 02 |
|
|
372 |
00E3: MOVWF 45 |
|
|
373 |
00E4: CALL 080 |
|
|
374 |
.................... delay_us(40); // cas na zpracovani |
|
|
375 |
00E5: MOVLW 1A |
|
|
376 |
00E6: MOVWF 77 |
|
|
377 |
00E7: DECFSZ 77,F |
|
|
378 |
00E8: GOTO 0E7 |
|
|
379 |
00E9: NOP |
|
|
380 |
.................... |
|
|
381 |
.................... for (i=0;i<3;i++) // proved inicializaci (nastaveni modu, smazani apod) |
|
|
382 |
00EA: CLRF 31 |
|
|
383 |
00EB: MOVF 31,W |
|
|
384 |
00EC: SUBLW 02 |
|
|
385 |
00ED: BTFSS 03.0 |
|
|
386 |
00EE: GOTO 0FB |
|
|
387 |
.................... { |
|
|
388 |
.................... lcd_send_byte(0,LCD_INIT_STRING[i]); |
|
|
389 |
00EF: MOVF 31,W |
|
|
390 |
00F0: CALL 02F |
|
|
391 |
00F1: MOVWF 32 |
|
|
392 |
00F2: CLRF 43 |
|
|
393 |
00F3: MOVF 32,W |
|
|
394 |
00F4: MOVWF 44 |
|
|
395 |
00F5: CALL 0AA |
|
|
396 |
.................... delay_ms(2); |
|
|
397 |
00F6: MOVLW 02 |
|
|
398 |
00F7: MOVWF 3F |
|
|
399 |
00F8: CALL 06C |
|
|
400 |
.................... } |
|
|
401 |
00F9: INCF 31,F |
|
|
402 |
00FA: GOTO 0EB |
|
|
403 |
.................... } |
|
|
404 |
00FB: RETURN |
|
|
405 |
.................... |
|
|
406 |
.................... |
|
|
407 |
.................... // Proved presun kurzoru |
|
|
408 |
.................... // |
|
|
409 |
.................... // Pozice 1.1 je domu |
|
|
410 |
.................... // |
|
|
411 |
.................... void lcd_gotoxy( BYTE x, BYTE y) |
|
|
412 |
.................... { |
|
|
413 |
.................... |
|
|
414 |
.................... BYTE Adr; |
|
|
415 |
.................... |
|
|
416 |
.................... Adr=x-1; |
|
|
417 |
00FC: MOVLW 01 |
|
|
418 |
00FD: SUBWF 3F,W |
|
|
419 |
00FE: MOVWF 41 |
|
|
420 |
.................... if(y==2) |
|
|
421 |
00FF: MOVF 40,W |
|
|
422 |
0100: SUBLW 02 |
|
|
423 |
0101: BTFSS 03.2 |
|
|
424 |
0102: GOTO 105 |
|
|
425 |
.................... Adr+=LCD_LINE_2; |
|
|
426 |
0103: MOVLW 40 |
|
|
427 |
0104: ADDWF 41,F |
|
|
428 |
.................... |
|
|
429 |
.................... lcd_send_byte(0,0x80|Adr); |
|
|
430 |
0105: MOVF 41,W |
|
|
431 |
0106: IORLW 80 |
|
|
432 |
0107: MOVWF 42 |
|
|
433 |
0108: CLRF 43 |
|
|
434 |
0109: MOVF 42,W |
|
|
435 |
010A: MOVWF 44 |
|
|
436 |
010B: CALL 0AA |
|
|
437 |
.................... } |
|
|
438 |
010C: RETURN |
|
|
439 |
.................... |
|
|
440 |
.................... |
|
|
441 |
.................... // Zapis znaku na displej, zpracovani ridicich znaku |
|
|
442 |
.................... // |
|
|
443 |
.................... void lcd_putc( char c) |
|
|
444 |
.................... { |
|
|
445 |
.................... |
|
|
446 |
.................... switch (c) |
|
|
447 |
.................... { |
|
|
448 |
010D: MOVF 3E,W |
|
|
449 |
010E: XORLW 0C |
|
|
450 |
010F: BTFSC 03.2 |
|
|
451 |
0110: GOTO 11B |
|
|
452 |
0111: XORLW 06 |
|
|
453 |
0112: BTFSC 03.2 |
|
|
454 |
0113: GOTO 123 |
|
|
455 |
0114: XORLW 07 |
|
|
456 |
0115: BTFSC 03.2 |
|
|
457 |
0116: GOTO 129 |
|
|
458 |
0117: XORLW 05 |
|
|
459 |
0118: BTFSC 03.2 |
|
|
460 |
0119: GOTO 12E |
|
|
461 |
011A: GOTO 133 |
|
|
462 |
.................... case '\f' : lcd_send_byte(0,1); // smaz displej |
|
|
463 |
011B: CLRF 43 |
|
|
464 |
011C: MOVLW 01 |
|
|
465 |
011D: MOVWF 44 |
|
|
466 |
011E: CALL 0AA |
|
|
467 |
.................... delay_ms(2); |
|
|
468 |
011F: MOVLW 02 |
|
|
469 |
0120: MOVWF 3F |
|
|
470 |
0121: CALL 06C |
|
|
471 |
.................... break; |
|
|
472 |
0122: GOTO 13F |
|
|
473 |
.................... case '\n' : lcd_gotoxy(1,2); break; // presun se na 1. znak 2. radky |
|
|
474 |
0123: MOVLW 01 |
|
|
475 |
0124: MOVWF 3F |
|
|
476 |
0125: MOVLW 02 |
|
|
477 |
0126: MOVWF 40 |
|
|
478 |
0127: CALL 0FC |
|
|
479 |
0128: GOTO 13F |
|
|
480 |
.................... case '\r' : lcd_gotoxy(1,1); break; // presun home |
|
|
481 |
0129: MOVLW 01 |
|
|
482 |
012A: MOVWF 3F |
|
|
483 |
012B: MOVWF 40 |
|
|
484 |
012C: CALL 0FC |
|
|
485 |
012D: GOTO 13F |
|
|
486 |
.................... case '\b' : lcd_send_byte(0,0x10); break; // posun kurzor o 1 zpet |
|
|
487 |
012E: CLRF 43 |
|
|
488 |
012F: MOVLW 10 |
|
|
489 |
0130: MOVWF 44 |
|
|
490 |
0131: CALL 0AA |
|
|
491 |
0132: GOTO 13F |
|
|
492 |
.................... default : if (c<0x20) c&=0x7; // preklopeni definovatelnych znaku na rozsah 0 az 0x1F |
|
|
493 |
0133: MOVF 3E,W |
|
|
494 |
0134: SUBLW 1F |
|
|
495 |
0135: BTFSS 03.0 |
|
|
496 |
0136: GOTO 139 |
|
|
497 |
0137: MOVLW 07 |
|
|
498 |
0138: ANDWF 3E,F |
|
|
499 |
.................... lcd_send_byte(1,c); break; // zapis znak |
|
|
500 |
0139: MOVLW 01 |
|
|
501 |
013A: MOVWF 43 |
|
|
502 |
013B: MOVF 3E,W |
|
|
503 |
013C: MOVWF 44 |
|
|
504 |
013D: CALL 0AA |
|
|
505 |
013E: GOTO 13F |
|
|
506 |
.................... } |
|
|
507 |
.................... } |
|
|
508 |
013F: RETURN |
|
|
509 |
.................... |
|
|
510 |
.................... |
|
|
511 |
.................... // Zapni kurzor |
|
|
512 |
.................... // |
|
|
513 |
.................... void lcd_cursor_on() |
|
|
514 |
.................... { |
|
|
515 |
.................... lcd_send_byte(0,LCD_CURSOR_ON_); |
|
|
516 |
.................... } |
|
|
517 |
.................... |
|
|
518 |
.................... |
|
|
519 |
.................... // Vypni kurzor |
|
|
520 |
.................... // |
|
|
521 |
.................... void lcd_cursor_off() |
|
|
522 |
.................... { |
|
|
523 |
.................... lcd_send_byte(0,LCD_CURSOR_OFF_); |
|
|
524 |
.................... } |
|
|
525 |
.................... |
|
|
526 |
.................... |
|
|
527 |
.................... // Smaz displej |
|
|
528 |
.................... // |
|
|
529 |
.................... void lcd_clr() |
|
|
530 |
.................... { |
|
|
531 |
.................... lcd_putc('\f'); |
|
|
532 |
.................... } |
|
|
533 |
.................... |
|
|
534 |
.................... |
|
|
535 |
.................... // Definice vlastnich fontu |
|
|
536 |
.................... // |
|
|
537 |
.................... // Vlastnich definic muze byt jen 8 do pozic 0 az 7 pameti CGRAM radice lcd displeje |
|
|
538 |
.................... // Pro snadne definovani jsou pripraveny nasledujici definice a na konci souboru je uveden |
|
|
539 |
.................... // priklad pouziti definovanych znaku. |
|
|
540 |
.................... |
|
|
541 |
.................... |
|
|
542 |
.................... // Pomocna procedura pro posilani ridicich dat do radice displeje |
|
|
543 |
.................... // |
|
|
544 |
.................... void lcd_putc2(int Data) |
|
|
545 |
.................... { |
|
|
546 |
.................... lcd_send_byte(1,Data); |
|
|
547 |
.................... } |
|
|
548 |
.................... |
|
|
549 |
.................... |
|
|
550 |
.................... // Pomocne definice pro programovani obsahu CGRAM |
|
|
551 |
.................... // |
|
|
552 |
.................... #define lcd_define_start(Code) lcd_send_byte(0,0x40+(Code<<3)); delay_ms(2) |
|
|
553 |
.................... #define lcd_define_def(String) printf(lcd_putc2,String); |
|
|
554 |
.................... #define lcd_define_end() lcd_send_byte(0,3); delay_ms(2) |
|
|
555 |
.................... |
|
|
556 |
.................... |
|
|
557 |
.................... // Vlastni vykonne makro pro definovani fontu do pozice Index CGRAM s definicnim retezcem Def |
|
|
558 |
.................... // |
|
|
559 |
.................... #define lcd_define_char(Index, Def) lcd_define_start(Index); lcd_define_def(Def); lcd_define_end(); |
|
|
560 |
.................... |
|
|
561 |
.................... |
|
|
562 |
.................... // Pripravene definice fontu vybranych znaku |
|
|
563 |
.................... // V tabulce nesmi byt 00 (konec retezce v printf()), misto toho davame 80 |
|
|
564 |
.................... // |
|
|
565 |
.................... #define LCD_CHAR_BAT100 "\x0E\x1F\x1F\x1F\x1F\x1F\x1F\x1F" /* symbol plne baterie */ |
|
|
566 |
.................... #define LCD_CHAR_BAT50 "\x0E\x1F\x11\x11\x13\x17\x1F\x1F" /* symbol polovicni baterie */ |
|
|
567 |
.................... #define LCD_CHAR_BAT0 "\x0E\x1F\x11\x11\x11\x11\x11\x1F" /* symbol vybite baterie */ |
|
|
568 |
.................... #define LCD_CHAR_UP "\x80\x04\x0E\x15\x04\x04\x04\x80" /* symbol sipka nahoru */ |
|
|
569 |
.................... #define LCD_CHAR_DOWN "\x80\x04\x04\x04\x15\x0E\x04\x80" /* symbol Sipka dolu */ |
|
|
570 |
.................... #define LCD_CHAR_LUA "\x04\x0E\x11\x11\x1F\x11\x11\x80" /* A s carkou */ |
|
|
571 |
.................... #define LCD_CHAR_LLA "\x01\x02\x0E\x01\x1F\x11\x0F\x80" /* a s carkou */ |
|
|
572 |
.................... #define LCD_CHAR_HUC "\x0A\x0E\x11\x10\x10\x11\x0E\x80" /* C s hackem */ |
|
|
573 |
.................... #define LCD_CHAR_HLC "\x0A\x04\x0E\x10\x10\x11\x0E\x80" /* c s hackem */ |
|
|
574 |
.................... #define LCD_CHAR_HUD "\x0A\x1C\x12\x11\x11\x12\x1C\x80" /* D s hackem */ |
|
|
575 |
.................... #define LCD_CHAR_HLD "\x05\x03\x0D\x13\x11\x11\x0F\x80" /* d s hackem */ |
|
|
576 |
.................... #define LCD_CHAR_LUE "\x04\x1F\x10\x10\x1E\x10\x1F\x80" /* E s carkou */ |
|
|
577 |
.................... #define LCD_CHAR_LLE "\x01\x02\x0E\x11\x1F\x10\x0E\x80" /* e s carkou */ |
|
|
578 |
.................... #define LCD_CHAR_HUE "\x0A\x1F\x10\x1E\x10\x10\x1F\x80" /* E s hackem */ |
|
|
579 |
.................... #define LCD_CHAR_HLE "\x0A\x04\x0E\x11\x1F\x10\x0E\x80" /* e s hackem */ |
|
|
580 |
.................... #define LCD_CHAR_LUI "\x04\x0E\x04\x04\x04\x04\x0E\x80" /* I s carkou */ |
|
|
581 |
.................... #define LCD_CHAR_LLI "\x02\x04\x80\x0C\x04\x04\x0E\x80" /* i s carkou */ |
|
|
582 |
.................... #define LCD_CHAR_HUN "\x0A\x15\x11\x19\x15\x13\x11\x80" /* N s hackem */ |
|
|
583 |
.................... #define LCD_CHAR_HLN "\x0A\x04\x16\x19\x11\x11\x11\x80" /* n s hackem */ |
|
|
584 |
.................... #define LCD_CHAR_LUO "\x04\x0E\x11\x11\x11\x11\x0E\x80" /* O s carkou */ |
|
|
585 |
.................... #define LCD_CHAR_LLO "\x02\x04\x0E\x11\x11\x11\x0E\x80" /* o s carkou */ |
|
|
586 |
.................... #define LCD_CHAR_HUR "\x0A\x1E\x11\x1E\x14\x12\x11\x80" /* R s hackem */ |
|
|
587 |
.................... #define LCD_CHAR_HLR "\x0A\x04\x16\x19\x10\x10\x10\x80" /* r s hackem */ |
|
|
588 |
.................... #define LCD_CHAR_HUS "\x0A\x0F\x10\x0E\x01\x01\x1E\x80" /* S s hackem */ |
|
|
589 |
.................... #define LCD_CHAR_HLS "\x0A\x04\x0E\x10\x0E\x01\x1E\x80" /* s s hackem */ |
|
|
590 |
.................... #define LCD_CHAR_HUT "\x0A\x1F\x04\x04\x04\x04\x04\x80" /* T s hackem */ |
|
|
591 |
.................... #define LCD_CHAR_HLT "\x0A\x0C\x1C\x08\x08\x09\x06\x80" /* t s hackem */ |
|
|
592 |
.................... #define LCD_CHAR_LUU "\x02\x15\x11\x11\x11\x11\x0E\x80" /* U s carkou */ |
|
|
593 |
.................... #define LCD_CHAR_LLU "\x02\x04\x11\x11\x11\x13\x0D\x80" /* u s carkou */ |
|
|
594 |
.................... #define LCD_CHAR_CUU "\x06\x17\x11\x11\x11\x11\x0E\x80" /* U s krouzkem */ |
|
|
595 |
.................... #define LCD_CHAR_CLU "\x06\x06\x11\x11\x11\x11\x0E\x80" /* u s krouzkem */ |
|
|
596 |
.................... #define LCD_CHAR_LUY "\x02\x15\x11\x0A\x04\x04\x04\x80" /* Y s carkou */ |
|
|
597 |
.................... #define LCD_CHAR_LLY "\x02\x04\x11\x11\x0F\x01\x0E\x80" /* y s carkou */ |
|
|
598 |
.................... #define LCD_CHAR_HUZ "\x0A\x1F\x01\x02\x04\x08\x1F\x80" /* Z s hackem */ |
|
|
599 |
.................... #define LCD_CHAR_HLZ "\x0A\x04\x1F\x02\x04\x08\x1F\x80" /* z s hackem */ |
|
|
600 |
.................... |
|
|
601 |
.................... |
|
|
602 |
.................... // Priklad pouziti definovanych znaku |
|
|
603 |
.................... // |
|
|
604 |
.................... // |
|
|
605 |
.................... //void lcd_sample() |
|
|
606 |
.................... //{ |
|
|
607 |
.................... // lcd_define_char(0,LCD_CHAR_BAT50); // Priklad definice znaku baterie do pozice 0 |
|
|
608 |
.................... // lcd_define_char(2,LCD_CHAR_HLE LCD_CHAR_LUI); // Priklad definice znaku e s hackem a I s carkou od pozice 2 |
|
|
609 |
.................... // // vsimnete si, ze neni carka mezi retezci s definici (oba retezce definuji |
|
|
610 |
.................... // // jediny definicni retezec) |
|
|
611 |
.................... // printf(lcd_putc,"\fZnaky:\20\22\23"); // priklad vypisu znaku z pozice 0, 2 a 3 |
|
|
612 |
.................... // delay_ms(1000); |
|
|
613 |
.................... // lcd_define_char(0,LCD_CHAR_BAT0); // Predefinovani tvaru znaku v pozici 0 |
|
|
614 |
.................... // delay_ms(1000); |
|
|
615 |
.................... //} |
|
|
616 |
.................... |
|
|
617 |
.................... |
|
|
618 |
.................... int1 value=0; |
|
|
619 |
.................... |
|
|
620 |
.................... #INT_EXT //preruseni od RB0 |
|
|
621 |
.................... void EXT_isr(void) |
|
|
622 |
.................... { |
|
|
623 |
.................... |
|
|
624 |
.................... value=~value; |
|
|
625 |
* |
|
|
626 |
0037: MOVLW 01 |
|
|
627 |
0038: XORWF 28,F |
|
|
628 |
.................... |
|
|
629 |
.................... } |
|
|
630 |
.................... |
|
|
631 |
0039: BCF 0B.1 |
|
|
632 |
003A: BCF 0A.3 |
|
|
633 |
003B: BCF 0A.4 |
|
|
634 |
003C: GOTO 01B |
|
|
635 |
.................... void main() |
|
|
636 |
.................... { |
|
|
637 |
* |
|
|
638 |
038E: CLRF 04 |
|
|
639 |
038F: BCF 03.7 |
|
|
640 |
0390: MOVLW 1F |
|
|
641 |
0391: ANDWF 03,F |
|
|
642 |
0392: MOVLW 71 |
|
|
643 |
0393: BSF 03.5 |
|
|
644 |
0394: MOVWF 0F |
|
|
645 |
0395: MOVF 0F,W |
|
|
646 |
0396: BCF 03.5 |
|
|
647 |
0397: BCF 28.0 |
|
|
648 |
0398: BSF 03.5 |
|
|
649 |
0399: BSF 03.6 |
|
|
650 |
039A: MOVF 09,W |
|
|
651 |
039B: ANDLW C0 |
|
|
652 |
039C: MOVWF 09 |
|
|
653 |
039D: BCF 03.6 |
|
|
654 |
039E: BCF 1F.4 |
|
|
655 |
039F: BCF 1F.5 |
|
|
656 |
03A0: MOVLW 00 |
|
|
657 |
03A1: BSF 03.6 |
|
|
658 |
03A2: MOVWF 08 |
|
|
659 |
03A3: BCF 03.5 |
|
|
660 |
03A4: CLRF 07 |
|
|
661 |
03A5: CLRF 08 |
|
|
662 |
03A6: CLRF 09 |
|
|
663 |
.................... double value1, value2; |
|
|
664 |
.................... enable_interrupts(INT_EXT); //povolení pøeruseni |
|
|
665 |
* |
|
|
666 |
03AA: BSF 0B.4 |
|
|
667 |
.................... enable_interrupts(GLOBAL); |
|
|
668 |
03AB: MOVLW C0 |
|
|
669 |
03AC: IORWF 0B,F |
|
|
670 |
.................... ext_int_edge(H_TO_L); |
|
|
671 |
03AD: BSF 03.5 |
|
|
672 |
03AE: BCF 01.6 |
|
|
673 |
.................... setup_adc_ports(PIN_A0); //piny pro A/D RA0 |
|
|
674 |
03AF: BSF 03.6 |
|
|
675 |
03B0: MOVF 09,W |
|
|
676 |
03B1: ANDLW C0 |
|
|
677 |
03B2: MOVWF 09 |
|
|
678 |
03B3: BCF 03.6 |
|
|
679 |
03B4: BCF 1F.4 |
|
|
680 |
03B5: BCF 1F.5 |
|
|
681 |
03B6: MOVLW 28 |
|
|
682 |
03B7: BSF 03.6 |
|
|
683 |
03B8: MOVWF 08 |
|
|
684 |
.................... setup_adc_ports(PIN_A1); //piny pro A/D RA1 |
|
|
685 |
03B9: MOVF 09,W |
|
|
686 |
03BA: ANDLW C0 |
|
|
687 |
03BB: MOVWF 09 |
|
|
688 |
03BC: BCF 03.6 |
|
|
689 |
03BD: BCF 1F.4 |
|
|
690 |
03BE: BCF 1F.5 |
|
|
691 |
03BF: MOVLW 29 |
|
|
692 |
03C0: BSF 03.6 |
|
|
693 |
03C1: MOVWF 08 |
|
|
694 |
.................... setup_adc(ADC_CLOCK_DIV_8); |
|
|
695 |
03C2: BCF 03.5 |
|
|
696 |
03C3: BCF 03.6 |
|
|
697 |
03C4: BSF 1F.6 |
|
|
698 |
03C5: BCF 1F.7 |
|
|
699 |
03C6: BSF 03.5 |
|
|
700 |
03C7: BCF 1F.7 |
|
|
701 |
03C8: BCF 03.5 |
|
|
702 |
03C9: BSF 1F.0 |
|
|
703 |
.................... |
|
|
704 |
.................... |
|
|
705 |
.................... |
|
|
706 |
.................... |
|
|
707 |
.................... setup_spi(SPI_SS_DISABLED); |
|
|
708 |
03CA: BCF 14.5 |
|
|
709 |
03CB: BCF 27.5 |
|
|
710 |
03CC: MOVF 27,W |
|
|
711 |
03CD: BSF 03.5 |
|
|
712 |
03CE: MOVWF 07 |
|
|
713 |
03CF: BCF 03.5 |
|
|
714 |
03D0: BSF 27.4 |
|
|
715 |
03D1: MOVF 27,W |
|
|
716 |
03D2: BSF 03.5 |
|
|
717 |
03D3: MOVWF 07 |
|
|
718 |
03D4: BCF 03.5 |
|
|
719 |
03D5: BCF 27.3 |
|
|
720 |
03D6: MOVF 27,W |
|
|
721 |
03D7: BSF 03.5 |
|
|
722 |
03D8: MOVWF 07 |
|
|
723 |
03D9: MOVLW 01 |
|
|
724 |
03DA: BCF 03.5 |
|
|
725 |
03DB: MOVWF 14 |
|
|
726 |
03DC: MOVLW 00 |
|
|
727 |
03DD: BSF 03.5 |
|
|
728 |
03DE: MOVWF 14 |
|
|
729 |
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); |
|
|
730 |
03DF: MOVF 01,W |
|
|
731 |
03E0: ANDLW C7 |
|
|
732 |
03E1: IORLW 08 |
|
|
733 |
03E2: MOVWF 01 |
|
|
734 |
.................... setup_timer_1(T1_DISABLED); |
|
|
735 |
03E3: BCF 03.5 |
|
|
736 |
03E4: CLRF 10 |
|
|
737 |
.................... setup_timer_2(T2_DISABLED,0,1); |
|
|
738 |
03E5: MOVLW 00 |
|
|
739 |
03E6: MOVWF 78 |
|
|
740 |
03E7: MOVWF 12 |
|
|
741 |
03E8: MOVLW 00 |
|
|
742 |
03E9: BSF 03.5 |
|
|
743 |
03EA: MOVWF 12 |
|
|
744 |
.................... setup_ccp1(CCP_OFF); |
|
|
745 |
03EB: BCF 03.5 |
|
|
746 |
03EC: BSF 27.2 |
|
|
747 |
03ED: MOVF 27,W |
|
|
748 |
03EE: BSF 03.5 |
|
|
749 |
03EF: MOVWF 07 |
|
|
750 |
03F0: BCF 03.5 |
|
|
751 |
03F1: CLRF 17 |
|
|
752 |
03F2: BSF 03.5 |
|
|
753 |
03F3: CLRF 1B |
|
|
754 |
03F4: CLRF 1C |
|
|
755 |
03F5: MOVLW 01 |
|
|
756 |
03F6: MOVWF 1D |
|
|
757 |
.................... setup_comparator(NC_NC_NC_NC); |
|
|
758 |
03F7: BCF 03.5 |
|
|
759 |
03F8: BSF 03.6 |
|
|
760 |
03F9: CLRF 07 |
|
|
761 |
03FA: CLRF 08 |
|
|
762 |
03FB: CLRF 09 |
|
|
763 |
.................... setup_oscillator(OSC_8MHZ); |
|
|
764 |
03FC: MOVLW 71 |
|
|
765 |
03FD: BSF 03.5 |
|
|
766 |
03FE: BCF 03.6 |
|
|
767 |
03FF: MOVWF 0F |
|
|
768 |
0400: MOVF 0F,W |
|
|
769 |
.................... |
|
|
770 |
.................... lcd_init(); //inicializuje LCD |
|
|
771 |
0401: BCF 03.5 |
|
|
772 |
0402: CALL 0C3 |
|
|
773 |
.................... |
|
|
774 |
.................... LCD_gotoxy(1,1); //na LCD 1bunka 1øadek |
|
|
775 |
0403: MOVLW 01 |
|
|
776 |
0404: MOVWF 3F |
|
|
777 |
0405: MOVWF 40 |
|
|
778 |
0406: CALL 0FC |
|
|
779 |
.................... printf(lcd_putc,"Tomas Pavlicek"); |
|
|
780 |
0407: MOVLW 3D |
|
|
781 |
0408: BSF 03.6 |
|
|
782 |
0409: MOVWF 0D |
|
|
783 |
040A: MOVLW 00 |
|
|
784 |
040B: MOVWF 0F |
|
|
785 |
040C: BCF 03.6 |
|
|
786 |
040D: CALL 140 |
|
|
787 |
.................... LCD_gotoxy(1,2); |
|
|
788 |
040E: MOVLW 01 |
|
|
789 |
040F: MOVWF 3F |
|
|
790 |
0410: MOVLW 02 |
|
|
791 |
0411: MOVWF 40 |
|
|
792 |
0412: CALL 0FC |
|
|
793 |
.................... printf(lcd_putc,"CVUT 2012/2013"); |
|
|
794 |
0413: MOVLW 45 |
|
|
795 |
0414: BSF 03.6 |
|
|
796 |
0415: MOVWF 0D |
|
|
797 |
0416: MOVLW 00 |
|
|
798 |
0417: MOVWF 0F |
|
|
799 |
0418: BCF 03.6 |
|
|
800 |
0419: CALL 140 |
|
|
801 |
.................... Delay_ms(1000); |
|
|
802 |
041A: MOVLW 04 |
|
|
803 |
041B: MOVWF 31 |
|
|
804 |
041C: MOVLW FA |
|
|
805 |
041D: MOVWF 3F |
|
|
806 |
041E: CALL 06C |
|
|
807 |
041F: DECFSZ 31,F |
|
|
808 |
0420: GOTO 41C |
|
|
809 |
.................... |
|
|
810 |
.................... while(true) |
|
|
811 |
.................... { |
|
|
812 |
.................... lcd_init(); //inicializuje LCD |
|
|
813 |
0421: CALL 0C3 |
|
|
814 |
.................... set_adc_channel(0); //nastavi AD na kanál 0 (RA0) |
|
|
815 |
0422: MOVLW 00 |
|
|
816 |
0423: MOVWF 78 |
|
|
817 |
0424: MOVF 1F,W |
|
|
818 |
0425: ANDLW C3 |
|
|
819 |
0426: IORWF 78,W |
|
|
820 |
0427: MOVWF 1F |
|
|
821 |
.................... read_adc(ADC_START_ONLY); // Spustime A/D prevod |
|
|
822 |
0428: BSF 1F.1 |
|
|
823 |
.................... Delay_ms(1); |
|
|
824 |
0429: MOVLW 01 |
|
|
825 |
042A: MOVWF 3F |
|
|
826 |
042B: CALL 06C |
|
|
827 |
.................... while(!adc_done()); // Cekame na dokonceni prevodu |
|
|
828 |
042C: BTFSC 1F.1 |
|
|
829 |
042D: GOTO 42C |
|
|
830 |
.................... value1=read_adc(); // Precteme hodnotu z prevodniku |
|
|
831 |
042E: BSF 1F.1 |
|
|
832 |
042F: BTFSC 1F.1 |
|
|
833 |
0430: GOTO 42F |
|
|
834 |
0431: MOVF 1E,W |
|
|
835 |
0432: CLRF 32 |
|
|
836 |
0433: MOVWF 31 |
|
|
837 |
0434: CALL 186 |
|
|
838 |
0435: MOVF 7A,W |
|
|
839 |
0436: MOVWF 2C |
|
|
840 |
0437: MOVF 79,W |
|
|
841 |
0438: MOVWF 2B |
|
|
842 |
0439: MOVF 78,W |
|
|
843 |
043A: MOVWF 2A |
|
|
844 |
043B: MOVF 77,W |
|
|
845 |
043C: MOVWF 29 |
|
|
846 |
.................... //Delay_ms(100); |
|
|
847 |
.................... set_adc_channel(1); //nastavi AD na kanál 1 (RA1) |
|
|
848 |
043D: MOVLW 04 |
|
|
849 |
043E: MOVWF 78 |
|
|
850 |
043F: MOVF 1F,W |
|
|
851 |
0440: ANDLW C3 |
|
|
852 |
0441: IORWF 78,W |
|
|
853 |
0442: MOVWF 1F |
|
|
854 |
.................... read_adc(ADC_START_ONLY); // Spustime A/D prevod |
|
|
855 |
0443: BSF 1F.1 |
|
|
856 |
.................... Delay_ms(1); |
|
|
857 |
0444: MOVLW 01 |
|
|
858 |
0445: MOVWF 3F |
|
|
859 |
0446: CALL 06C |
|
|
860 |
.................... while(!adc_done()); // Cekame na dokonceni prevodu |
|
|
861 |
0447: BTFSC 1F.1 |
|
|
862 |
0448: GOTO 447 |
|
|
863 |
.................... value2=read_adc(); // Precteme hodnotu z prevodniku |
|
|
864 |
0449: BSF 1F.1 |
|
|
865 |
044A: BTFSC 1F.1 |
|
|
866 |
044B: GOTO 44A |
|
|
867 |
044C: MOVF 1E,W |
|
|
868 |
044D: CLRF 32 |
|
|
869 |
044E: MOVWF 31 |
|
|
870 |
044F: CALL 186 |
|
|
871 |
0450: MOVF 7A,W |
|
|
872 |
0451: MOVWF 30 |
|
|
873 |
0452: MOVF 79,W |
|
|
874 |
0453: MOVWF 2F |
|
|
875 |
0454: MOVF 78,W |
|
|
876 |
0455: MOVWF 2E |
|
|
877 |
0456: MOVF 77,W |
|
|
878 |
0457: MOVWF 2D |
|
|
879 |
.................... |
|
|
880 |
.................... |
|
|
881 |
.................... if(value==1) |
|
|
882 |
0458: BTFSS 28.0 |
|
|
883 |
0459: GOTO 49E |
|
|
884 |
.................... { |
|
|
885 |
.................... LCD_gotoxy(1,1); //na LCD 1bunka 1øadek |
|
|
886 |
045A: MOVLW 01 |
|
|
887 |
045B: MOVWF 3F |
|
|
888 |
045C: MOVWF 40 |
|
|
889 |
045D: CALL 0FC |
|
|
890 |
.................... printf(lcd_putc,"Napeti:%5.3f V", value1);; |
|
|
891 |
045E: MOVLW 4E |
|
|
892 |
045F: BSF 03.6 |
|
|
893 |
0460: MOVWF 0D |
|
|
894 |
0461: MOVLW 00 |
|
|
895 |
0462: MOVWF 0F |
|
|
896 |
0463: BCF 03.0 |
|
|
897 |
0464: MOVLW 07 |
|
|
898 |
0465: BCF 03.6 |
|
|
899 |
0466: MOVWF 31 |
|
|
900 |
0467: CALL 1A3 |
|
|
901 |
0468: MOVLW 04 |
|
|
902 |
0469: MOVWF 04 |
|
|
903 |
046A: MOVF 2C,W |
|
|
904 |
046B: MOVWF 34 |
|
|
905 |
046C: MOVF 2B,W |
|
|
906 |
046D: MOVWF 33 |
|
|
907 |
046E: MOVF 2A,W |
|
|
908 |
046F: MOVWF 32 |
|
|
909 |
0470: MOVF 29,W |
|
|
910 |
0471: MOVWF 31 |
|
|
911 |
0472: MOVLW 03 |
|
|
912 |
0473: MOVWF 35 |
|
|
913 |
0474: CALL 234 |
|
|
914 |
0475: MOVLW 20 |
|
|
915 |
0476: MOVWF 3E |
|
|
916 |
0477: CALL 10D |
|
|
917 |
0478: MOVLW 56 |
|
|
918 |
0479: MOVWF 3E |
|
|
919 |
047A: CALL 10D |
|
|
920 |
.................... LCD_gotoxy(1,2); |
|
|
921 |
047B: MOVLW 01 |
|
|
922 |
047C: MOVWF 3F |
|
|
923 |
047D: MOVLW 02 |
|
|
924 |
047E: MOVWF 40 |
|
|
925 |
047F: CALL 0FC |
|
|
926 |
.................... printf(lcd_putc,"Proud:%5.3f I", value2); |
|
|
927 |
0480: MOVLW 56 |
|
|
928 |
0481: BSF 03.6 |
|
|
929 |
0482: MOVWF 0D |
|
|
930 |
0483: MOVLW 00 |
|
|
931 |
0484: MOVWF 0F |
|
|
932 |
0485: BCF 03.0 |
|
|
933 |
0486: MOVLW 06 |
|
|
934 |
0487: BCF 03.6 |
|
|
935 |
0488: MOVWF 31 |
|
|
936 |
0489: CALL 1A3 |
|
|
937 |
048A: MOVLW 04 |
|
|
938 |
048B: MOVWF 04 |
|
|
939 |
048C: MOVF 30,W |
|
|
940 |
048D: MOVWF 34 |
|
|
941 |
048E: MOVF 2F,W |
|
|
942 |
048F: MOVWF 33 |
|
|
943 |
0490: MOVF 2E,W |
|
|
944 |
0491: MOVWF 32 |
|
|
945 |
0492: MOVF 2D,W |
|
|
946 |
0493: MOVWF 31 |
|
|
947 |
0494: MOVLW 03 |
|
|
948 |
0495: MOVWF 35 |
|
|
949 |
0496: CALL 234 |
|
|
950 |
0497: MOVLW 20 |
|
|
951 |
0498: MOVWF 3E |
|
|
952 |
0499: CALL 10D |
|
|
953 |
049A: MOVLW 49 |
|
|
954 |
049B: MOVWF 3E |
|
|
955 |
049C: CALL 10D |
|
|
956 |
.................... |
|
|
957 |
.................... } |
|
|
958 |
.................... else |
|
|
959 |
049D: GOTO 4E1 |
|
|
960 |
.................... { |
|
|
961 |
.................... LCD_gotoxy(1,1); //na LCD 1bunka 1øadek |
|
|
962 |
049E: MOVLW 01 |
|
|
963 |
049F: MOVWF 3F |
|
|
964 |
04A0: MOVWF 40 |
|
|
965 |
04A1: CALL 0FC |
|
|
966 |
.................... printf(lcd_putc,"Napeti:%5.3f V", value1);; |
|
|
967 |
04A2: MOVLW 5D |
|
|
968 |
04A3: BSF 03.6 |
|
|
969 |
04A4: MOVWF 0D |
|
|
970 |
04A5: MOVLW 00 |
|
|
971 |
04A6: MOVWF 0F |
|
|
972 |
04A7: BCF 03.0 |
|
|
973 |
04A8: MOVLW 07 |
|
|
974 |
04A9: BCF 03.6 |
|
|
975 |
04AA: MOVWF 31 |
|
|
976 |
04AB: CALL 1A3 |
|
|
977 |
04AC: MOVLW 04 |
|
|
978 |
04AD: MOVWF 04 |
|
|
979 |
04AE: MOVF 2C,W |
|
|
980 |
04AF: MOVWF 34 |
|
|
981 |
04B0: MOVF 2B,W |
|
|
982 |
04B1: MOVWF 33 |
|
|
983 |
04B2: MOVF 2A,W |
|
|
984 |
04B3: MOVWF 32 |
|
|
985 |
04B4: MOVF 29,W |
|
|
986 |
04B5: MOVWF 31 |
|
|
987 |
04B6: MOVLW 03 |
|
|
988 |
04B7: MOVWF 35 |
|
|
989 |
04B8: CALL 234 |
|
|
990 |
04B9: MOVLW 20 |
|
|
991 |
04BA: MOVWF 3E |
|
|
992 |
04BB: CALL 10D |
|
|
993 |
04BC: MOVLW 56 |
|
|
994 |
04BD: MOVWF 3E |
|
|
995 |
04BE: CALL 10D |
|
|
996 |
.................... LCD_gotoxy(1,2); |
|
|
997 |
04BF: MOVLW 01 |
|
|
998 |
04C0: MOVWF 3F |
|
|
999 |
04C1: MOVLW 02 |
|
|
1000 |
04C2: MOVWF 40 |
|
|
1001 |
04C3: CALL 0FC |
|
|
1002 |
.................... printf(lcd_putc,"Naboj:%5.3f I", value2); |
|
|
1003 |
04C4: MOVLW 65 |
|
|
1004 |
04C5: BSF 03.6 |
|
|
1005 |
04C6: MOVWF 0D |
|
|
1006 |
04C7: MOVLW 00 |
|
|
1007 |
04C8: MOVWF 0F |
|
|
1008 |
04C9: BCF 03.0 |
|
|
1009 |
04CA: MOVLW 06 |
|
|
1010 |
04CB: BCF 03.6 |
|
|
1011 |
04CC: MOVWF 31 |
|
|
1012 |
04CD: CALL 1A3 |
|
|
1013 |
04CE: MOVLW 04 |
|
|
1014 |
04CF: MOVWF 04 |
|
|
1015 |
04D0: MOVF 30,W |
|
|
1016 |
04D1: MOVWF 34 |
|
|
1017 |
04D2: MOVF 2F,W |
|
|
1018 |
04D3: MOVWF 33 |
|
|
1019 |
04D4: MOVF 2E,W |
|
|
1020 |
04D5: MOVWF 32 |
|
|
1021 |
04D6: MOVF 2D,W |
|
|
1022 |
04D7: MOVWF 31 |
|
|
1023 |
04D8: MOVLW 03 |
|
|
1024 |
04D9: MOVWF 35 |
|
|
1025 |
04DA: CALL 234 |
|
|
1026 |
04DB: MOVLW 20 |
|
|
1027 |
04DC: MOVWF 3E |
|
|
1028 |
04DD: CALL 10D |
|
|
1029 |
04DE: MOVLW 49 |
|
|
1030 |
04DF: MOVWF 3E |
|
|
1031 |
04E0: CALL 10D |
|
|
1032 |
.................... |
|
|
1033 |
.................... } |
|
|
1034 |
.................... Delay_ms(500); |
|
|
1035 |
04E1: MOVLW 02 |
|
|
1036 |
04E2: MOVWF 31 |
|
|
1037 |
04E3: MOVLW FA |
|
|
1038 |
04E4: MOVWF 3F |
|
|
1039 |
04E5: CALL 06C |
|
|
1040 |
04E6: DECFSZ 31,F |
|
|
1041 |
04E7: GOTO 4E3 |
|
|
1042 |
.................... } |
|
|
1043 |
04E8: GOTO 421 |
|
|
1044 |
.................... } |
|
|
1045 |
.................... |
|
|
1046 |
04E9: SLEEP |
|
|
1047 |
|
|
|
1048 |
Configuration Fuses: |
|
|
1049 |
Word 1: 2CF5 INTRC NOWDT NOPUT MCLR NOPROTECT NOCPD NOBROWNOUT IESO FCMEN NOLVP NODEBUG |
|
|
1050 |
Word 2: 3FFF NOWRT BORV40 |