171 |
chroust |
1 |
CCS PCM C Compiler, Version 4.059d, 15399 13-II-07 23:16 |
|
|
2 |
|
|
|
3 |
Filename: main.lst |
|
|
4 |
|
|
|
5 |
ROM used: 1704 words (83%) |
|
|
6 |
Largest free fragment is 344 |
|
|
7 |
RAM used: 32 (9%) at main() level |
|
|
8 |
58 (16%) worst case |
|
|
9 |
Stack: 5 locations |
|
|
10 |
|
|
|
11 |
* |
|
|
12 |
0000: MOVLW 00 |
|
|
13 |
0001: MOVWF 0A |
|
|
14 |
0002: GOTO 59C |
|
|
15 |
0003: NOP |
|
|
16 |
.................... #include "C:\Rs\zdrojáky\projekt\Posledni\main.h" |
|
|
17 |
.................... #include <16F877A.h> |
|
|
18 |
.................... //////// Standard Header file for the PIC16F877A device //////////////// |
|
|
19 |
.................... #device PIC16F877A |
|
|
20 |
.................... #list |
|
|
21 |
.................... |
|
|
22 |
.................... #device adc=10 |
|
|
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 WRT_50% //Lower half of Program Memory is Write Protected |
|
|
33 |
.................... |
|
|
34 |
.................... #use delay(clock=4000000,RESTART_WDT) |
|
|
35 |
* |
|
|
36 |
008B: MOVLW 48 |
|
|
37 |
008C: MOVWF 04 |
|
|
38 |
008D: BCF 03.7 |
|
|
39 |
008E: MOVF 00,W |
|
|
40 |
008F: BTFSC 03.2 |
|
|
41 |
0090: GOTO 0A2 |
|
|
42 |
0091: MOVLW 01 |
|
|
43 |
0092: MOVWF 78 |
|
|
44 |
0093: MOVLW BF |
|
|
45 |
0094: MOVWF 77 |
|
|
46 |
0095: CLRWDT |
|
|
47 |
0096: DECFSZ 77,F |
|
|
48 |
0097: GOTO 095 |
|
|
49 |
0098: DECFSZ 78,F |
|
|
50 |
0099: GOTO 093 |
|
|
51 |
009A: MOVLW 4A |
|
|
52 |
009B: MOVWF 77 |
|
|
53 |
009C: DECFSZ 77,F |
|
|
54 |
009D: GOTO 09C |
|
|
55 |
009E: NOP |
|
|
56 |
009F: CLRWDT |
|
|
57 |
00A0: DECFSZ 00,F |
|
|
58 |
00A1: GOTO 091 |
|
|
59 |
00A2: RETLW 00 |
|
|
60 |
.................... |
|
|
61 |
.................... |
|
|
62 |
.................... |
|
|
63 |
.................... #define LCD_RS PIN_C7 // rizeni registru LCD displeje <lcd.c> |
|
|
64 |
.................... #define LCD_E PIN_B7 // enable LCD displeje <lcd.c> |
|
|
65 |
.................... #define LCD_D0 PIN_B3 // data LCD <lcd.c> |
|
|
66 |
.................... #define LCD_D1 PIN_B2 |
|
|
67 |
.................... #define LCD_D2 PIN_B1 |
|
|
68 |
.................... #define LCD_D3 PIN_B0 |
|
|
69 |
.................... |
|
|
70 |
.................... #include "LCD.C" //pro LCD |
|
|
71 |
.................... // LCD modul pro ovladani dvouradkoveho LCD modulu se standardnim Hitachi radicem |
|
|
72 |
.................... // (c)miho 2002,2005 |
|
|
73 |
.................... // |
|
|
74 |
.................... // Historie: |
|
|
75 |
.................... // |
|
|
76 |
.................... // 0.00 Uvodni verze se snadnou definici portu LCD displeje |
|
|
77 |
.................... // 0.01 Oprava portu (zapomenute stare identifikatory) |
|
|
78 |
.................... // 0.02 Doplnena moznost pripojeni datoveho portu LCD na libovolne porty |
|
|
79 |
.................... // 0.03 Doplnena procedura lcd_clr pro smazani displeje |
|
|
80 |
.................... // |
|
|
81 |
.................... // |
|
|
82 |
.................... // Funkce: |
|
|
83 |
.................... // |
|
|
84 |
.................... // lcd_init() inicializuje LCD displej a porty, nutno volat jako prvni |
|
|
85 |
.................... // |
|
|
86 |
.................... // lcd_putc(c) zapis snaku do lcd displeje, zpracovava nasledujici ridici znaky |
|
|
87 |
.................... // \f = \x0C - nova stranka - smazani displeje |
|
|
88 |
.................... // \n = \x0A - odradkovani (prechod na druhou radku) |
|
|
89 |
.................... // \b = \x08 - backspace - posunuti kurzoru o 1 pozici zpet |
|
|
90 |
.................... // \r = \x0D - goto home to position 1,1 |
|
|
91 |
.................... // \0 .. \7 - definovatelne znaky v pozicich 0 az 7 v CGRAM |
|
|
92 |
.................... // \20 .. \27 - alternativne zapsane znaky (oktalove) v pozicich 0 az 7 CGRAM |
|
|
93 |
.................... // Pozor na to, ze funkce printf konci tisk pokud narazi na \0 (konec retezce) |
|
|
94 |
.................... // |
|
|
95 |
.................... // lcd_gotoxy(x,y) presune kurzor na uvedenou adresu |
|
|
96 |
.................... // nekontroluje parametry |
|
|
97 |
.................... // |
|
|
98 |
.................... // lcd_cursor_on zapne kurzor |
|
|
99 |
.................... // lcd_cursor_off vypne kurzor |
|
|
100 |
.................... // |
|
|
101 |
.................... // lcd_clr smaze displej |
|
|
102 |
.................... // |
|
|
103 |
.................... // lcd_define_char(Index, Def) Makro, ktere definuje znaky od pozice Index obsahem definicniho |
|
|
104 |
.................... // retezce Def. Kazdych 8 znaku retezce Def definuje dalsi znak v CGRAM. |
|
|
105 |
.................... // Kapacita CGRAM je celkem 8 znaku s indexem 0 az 7. |
|
|
106 |
.................... // Na konci se provede lcd_gotoxy(1,1). |
|
|
107 |
.................... // Na konci teto knihovny je priklad pouziti definovanych znaku |
|
|
108 |
.................... // |
|
|
109 |
.................... // |
|
|
110 |
.................... // Definice portu: // Datovy port displeje pripojeny na 4 bity za sebou na jeden port |
|
|
111 |
.................... // |
|
|
112 |
.................... // #define LCD_RS PIN_B2 // rizeni registru LCD displeje |
|
|
113 |
.................... // #define LCD_E PIN_B1 // enable LCD displeje |
|
|
114 |
.................... // #define LCD_DATA_LSB PIN_C2 // pripojeni LSB bitu datoveho portu LCD displeje (celkem 4 bity vzestupne za sebou) |
|
|
115 |
.................... // |
|
|
116 |
.................... // |
|
|
117 |
.................... // Alternativni definice: // Datovy port displeje pripojeny na libovolne 4 bitove porty (vede na kod delsi asi o 25 slov) |
|
|
118 |
.................... // |
|
|
119 |
.................... // #define LCD_RS PIN_B2 // rizeni registru LCD displeje |
|
|
120 |
.................... // #define LCD_E PIN_B1 // enable LCD displeje |
|
|
121 |
.................... // #define LCD_D0 PIN_C2 // D0 - datove bity pripojene na libovolne porty |
|
|
122 |
.................... // #define LCD_D1 PIN_C3 // D1 |
|
|
123 |
.................... // #define LCD_D2 PIN_C4 // D2 |
|
|
124 |
.................... // #define LCD_D3 PIN_C5 // D3 |
|
|
125 |
.................... |
|
|
126 |
.................... |
|
|
127 |
.................... |
|
|
128 |
.................... |
|
|
129 |
.................... // Privatni sekce, cist jen v pripade, ze neco nefunguje |
|
|
130 |
.................... |
|
|
131 |
.................... |
|
|
132 |
.................... |
|
|
133 |
.................... |
|
|
134 |
.................... #ifdef LCD_DATA_LSB |
|
|
135 |
.................... // Generovane defince portu pro ucely teto knihovny aby kod generoval spravne IO operace a soucasne |
|
|
136 |
.................... // bylo mozne jednoduse deklarovat pripojene piny LCD displeje pri pouziti teto knihovny. Problem spociva |
|
|
137 |
.................... // v tom, ze se musi spravne ridit smery portu a soucasne datovy port zabira jen 4 bity ze zadaneho portu |
|
|
138 |
.................... // |
|
|
139 |
.................... #define LCD_SHIFT (LCD_DATA_LSB&7) // pocet bitu posuvu datoveho kanalu v datovem portu |
|
|
140 |
.................... #define LCD_PORT (LCD_DATA_LSB>>3) // adresa LCD datoveho portu |
|
|
141 |
.................... #define LCD_TRIS (LCD_PORT+0x80) // adresa prislusneho TRIS registru |
|
|
142 |
.................... #define LCD_MASK (0xF<<LCD_SHIFT) // maska platnych bitu |
|
|
143 |
.................... // |
|
|
144 |
.................... #if LCD_SHIFT>4 // kontrola mezi |
|
|
145 |
.................... #error LCD data port LSB bit not in range 0..4 |
|
|
146 |
.................... #endif |
|
|
147 |
.................... #endif |
|
|
148 |
.................... |
|
|
149 |
.................... |
|
|
150 |
.................... // Definice konstant pro LCD display |
|
|
151 |
.................... // |
|
|
152 |
.................... #define LCD_CURSOR_ON_ 0x0E // kurzor jako blikajici radka pod znakem |
|
|
153 |
.................... #define LCD_CURSOR_OFF_ 0x0C // zadny kurzor |
|
|
154 |
.................... #define LCD_LINE_2 0x40 // adresa 1. znaku 2. radky |
|
|
155 |
.................... |
|
|
156 |
.................... |
|
|
157 |
.................... // Definice rezimu LCD displeje |
|
|
158 |
.................... // |
|
|
159 |
.................... BYTE const LCD_INIT_STRING[4] = |
|
|
160 |
.................... { |
|
|
161 |
.................... 0x28, // intrfejs 4 bity, 2 radky, font 5x7 |
|
|
162 |
.................... LCD_CURSOR_OFF_, // display on, kurzor off, |
|
|
163 |
.................... 0x01, // clear displeje |
|
|
164 |
.................... 0x06 // inkrement pozice kurzoru (posun kurzoru doprava) |
|
|
165 |
.................... }; |
|
|
166 |
.................... |
|
|
167 |
.................... |
|
|
168 |
.................... // Odesle nibble do displeje (posle data a klikne signalem e) |
|
|
169 |
.................... // |
|
|
170 |
.................... void lcd_send_nibble( BYTE n ) |
|
|
171 |
.................... { |
|
|
172 |
.................... #ifdef LCD_DATA_LSB |
|
|
173 |
.................... // data jsou za sebou na 4 bitech jednoho portu |
|
|
174 |
.................... *LCD_PORT = (*LCD_PORT & ~LCD_MASK) | ((n << LCD_SHIFT) & LCD_MASK); // nastav datove bity portu a ostatni zachovej |
|
|
175 |
.................... #else |
|
|
176 |
.................... // data jsou na libovolnych 4 bitech libovolnych portu |
|
|
177 |
.................... output_bit(LCD_D0,bit_test(n,0)); |
|
|
178 |
* |
|
|
179 |
01FA: BTFSC 4E.0 |
|
|
180 |
01FB: GOTO 1FE |
|
|
181 |
01FC: BCF 06.3 |
|
|
182 |
01FD: GOTO 1FF |
|
|
183 |
01FE: BSF 06.3 |
|
|
184 |
01FF: BSF 03.5 |
|
|
185 |
0200: BCF 06.3 |
|
|
186 |
.................... output_bit(LCD_D1,bit_test(n,1)); |
|
|
187 |
0201: BCF 03.5 |
|
|
188 |
0202: BTFSC 4E.1 |
|
|
189 |
0203: GOTO 206 |
|
|
190 |
0204: BCF 06.2 |
|
|
191 |
0205: GOTO 207 |
|
|
192 |
0206: BSF 06.2 |
|
|
193 |
0207: BSF 03.5 |
|
|
194 |
0208: BCF 06.2 |
|
|
195 |
.................... output_bit(LCD_D2,bit_test(n,2)); |
|
|
196 |
0209: BCF 03.5 |
|
|
197 |
020A: BTFSC 4E.2 |
|
|
198 |
020B: GOTO 20E |
|
|
199 |
020C: BCF 06.1 |
|
|
200 |
020D: GOTO 20F |
|
|
201 |
020E: BSF 06.1 |
|
|
202 |
020F: BSF 03.5 |
|
|
203 |
0210: BCF 06.1 |
|
|
204 |
.................... output_bit(LCD_D3,bit_test(n,3)); |
|
|
205 |
0211: BCF 03.5 |
|
|
206 |
0212: BTFSC 4E.3 |
|
|
207 |
0213: GOTO 216 |
|
|
208 |
0214: BCF 06.0 |
|
|
209 |
0215: GOTO 217 |
|
|
210 |
0216: BSF 06.0 |
|
|
211 |
0217: BSF 03.5 |
|
|
212 |
0218: BCF 06.0 |
|
|
213 |
.................... #endif |
|
|
214 |
.................... output_bit(LCD_E,1); // vzestupna hrana |
|
|
215 |
0219: BCF 03.5 |
|
|
216 |
021A: BSF 06.7 |
|
|
217 |
021B: BSF 03.5 |
|
|
218 |
021C: BCF 06.7 |
|
|
219 |
.................... delay_us(1); // pockej alespon 450ns od e nebo alespon 195ns od dat |
|
|
220 |
021D: CLRWDT |
|
|
221 |
.................... output_bit(LCD_E,0); // sestupna hrana (minimalni perioda e je 1us) |
|
|
222 |
021E: BCF 03.5 |
|
|
223 |
021F: BCF 06.7 |
|
|
224 |
0220: BSF 03.5 |
|
|
225 |
0221: BCF 06.7 |
|
|
226 |
.................... } |
|
|
227 |
0222: BCF 03.5 |
|
|
228 |
0223: RETLW 00 |
|
|
229 |
.................... |
|
|
230 |
.................... |
|
|
231 |
.................... // Odesle bajt do registru LCD |
|
|
232 |
.................... // |
|
|
233 |
.................... // Pokud je Adr=0 .. instrukcni registr |
|
|
234 |
.................... // Pokud je Adr=1 .. datovy registr |
|
|
235 |
.................... // |
|
|
236 |
.................... void lcd_send_byte( BOOLEAN Adr, BYTE n ) |
|
|
237 |
.................... { |
|
|
238 |
.................... output_bit(LCD_RS,Adr); // vyber registr |
|
|
239 |
0224: MOVF 4C,F |
|
|
240 |
0225: BTFSS 03.2 |
|
|
241 |
0226: GOTO 229 |
|
|
242 |
0227: BCF 07.7 |
|
|
243 |
0228: GOTO 22A |
|
|
244 |
0229: BSF 07.7 |
|
|
245 |
022A: BCF 20.7 |
|
|
246 |
022B: MOVF 20,W |
|
|
247 |
022C: BSF 03.5 |
|
|
248 |
022D: MOVWF 07 |
|
|
249 |
* |
|
|
250 |
05A7: MOVLW FF |
|
|
251 |
05A8: BCF 03.5 |
|
|
252 |
05A9: MOVWF 20 |
|
|
253 |
.................... swap(n); |
|
|
254 |
* |
|
|
255 |
022E: BCF 03.5 |
|
|
256 |
022F: SWAPF 4D,F |
|
|
257 |
.................... lcd_send_nibble(n); // posli horni pulku bajtu |
|
|
258 |
0230: MOVF 4D,W |
|
|
259 |
0231: MOVWF 4E |
|
|
260 |
0232: CALL 1FA |
|
|
261 |
.................... swap(n); |
|
|
262 |
0233: SWAPF 4D,F |
|
|
263 |
.................... lcd_send_nibble(n); // posli spodni pulku bajtu |
|
|
264 |
0234: MOVF 4D,W |
|
|
265 |
0235: MOVWF 4E |
|
|
266 |
0236: CALL 1FA |
|
|
267 |
.................... delay_us(40); // minimalni doba na provedeni prikazu |
|
|
268 |
0237: CLRWDT |
|
|
269 |
0238: MOVLW 0C |
|
|
270 |
0239: MOVWF 77 |
|
|
271 |
023A: DECFSZ 77,F |
|
|
272 |
023B: GOTO 23A |
|
|
273 |
023C: GOTO 23D |
|
|
274 |
.................... } |
|
|
275 |
023D: RETLW 00 |
|
|
276 |
.................... |
|
|
277 |
.................... |
|
|
278 |
.................... // Provede inicializaci LCD displeje, smaze obsah a nastavi mod displeje |
|
|
279 |
.................... // |
|
|
280 |
.................... // Tato procedura se musi volat pred pouzitim ostatnich lcd_ procedur |
|
|
281 |
.................... // |
|
|
282 |
.................... void lcd_init() |
|
|
283 |
.................... { |
|
|
284 |
.................... |
|
|
285 |
.................... int i; // pocitadlo cyklu |
|
|
286 |
.................... |
|
|
287 |
.................... delay_ms(20); // spozdeni pro provedeni startu displeje po zapnuti napajeni |
|
|
288 |
023E: MOVLW 14 |
|
|
289 |
023F: MOVWF 48 |
|
|
290 |
0240: CALL 08B |
|
|
291 |
.................... |
|
|
292 |
.................... #ifdef LCD_DATA_LSB |
|
|
293 |
.................... // data jsou na 4 bitech za sebou, nastav smer pro vsechny dalsi prenosy |
|
|
294 |
.................... *LCD_TRIS = *LCD_TRIS & ~LCD_MASK; // nuluj odpovidajici bity tris registru datoveho portu LCD |
|
|
295 |
.................... #endif |
|
|
296 |
.................... |
|
|
297 |
.................... output_bit(LCD_RS,0); // nastav jako vystup a nastav klidovy stav |
|
|
298 |
0241: BCF 07.7 |
|
|
299 |
0242: BCF 20.7 |
|
|
300 |
0243: MOVF 20,W |
|
|
301 |
0244: BSF 03.5 |
|
|
302 |
0245: MOVWF 07 |
|
|
303 |
.................... output_bit(LCD_E, 0); // nastav jako vystup a nastav klidovy stav |
|
|
304 |
0246: BCF 03.5 |
|
|
305 |
0247: BCF 06.7 |
|
|
306 |
0248: BSF 03.5 |
|
|
307 |
0249: BCF 06.7 |
|
|
308 |
.................... |
|
|
309 |
.................... for (i=0; i<3; i++) // nastav lcd do rezimu 8 bitu sbernice |
|
|
310 |
024A: BCF 03.5 |
|
|
311 |
024B: CLRF 2D |
|
|
312 |
024C: MOVF 2D,W |
|
|
313 |
024D: SUBLW 02 |
|
|
314 |
024E: BTFSS 03.0 |
|
|
315 |
024F: GOTO 258 |
|
|
316 |
.................... { |
|
|
317 |
.................... delay_ms(2); // muze byt rozdelany prenos dat (2x 4 bity) nebo pomaly povel |
|
|
318 |
0250: MOVLW 02 |
|
|
319 |
0251: MOVWF 48 |
|
|
320 |
0252: CALL 08B |
|
|
321 |
.................... lcd_send_nibble(3); // rezim 8 bitu |
|
|
322 |
0253: MOVLW 03 |
|
|
323 |
0254: MOVWF 4E |
|
|
324 |
0255: CALL 1FA |
|
|
325 |
.................... } |
|
|
326 |
0256: INCF 2D,F |
|
|
327 |
0257: GOTO 24C |
|
|
328 |
.................... |
|
|
329 |
.................... delay_us(40); // cas na zpracovani |
|
|
330 |
0258: CLRWDT |
|
|
331 |
0259: MOVLW 0C |
|
|
332 |
025A: MOVWF 77 |
|
|
333 |
025B: DECFSZ 77,F |
|
|
334 |
025C: GOTO 25B |
|
|
335 |
025D: GOTO 25E |
|
|
336 |
.................... lcd_send_nibble(2); // nastav rezim 4 bitu (plati od nasledujiciho prenosu) |
|
|
337 |
025E: MOVLW 02 |
|
|
338 |
025F: MOVWF 4E |
|
|
339 |
0260: CALL 1FA |
|
|
340 |
.................... delay_us(40); // cas na zpracovani |
|
|
341 |
0261: CLRWDT |
|
|
342 |
0262: MOVLW 0C |
|
|
343 |
0263: MOVWF 77 |
|
|
344 |
0264: DECFSZ 77,F |
|
|
345 |
0265: GOTO 264 |
|
|
346 |
0266: GOTO 267 |
|
|
347 |
.................... |
|
|
348 |
.................... for (i=0;i<3;i++) // proved inicializaci (nastaveni modu, smazani apod) |
|
|
349 |
0267: CLRF 2D |
|
|
350 |
0268: MOVF 2D,W |
|
|
351 |
0269: SUBLW 02 |
|
|
352 |
026A: BTFSS 03.0 |
|
|
353 |
026B: GOTO 278 |
|
|
354 |
.................... { |
|
|
355 |
.................... lcd_send_byte(0,LCD_INIT_STRING[i]); |
|
|
356 |
026C: MOVF 2D,W |
|
|
357 |
026D: CALL 004 |
|
|
358 |
026E: MOVWF 2E |
|
|
359 |
026F: CLRF 4C |
|
|
360 |
0270: MOVF 2E,W |
|
|
361 |
0271: MOVWF 4D |
|
|
362 |
0272: CALL 224 |
|
|
363 |
.................... delay_ms(2); |
|
|
364 |
0273: MOVLW 02 |
|
|
365 |
0274: MOVWF 48 |
|
|
366 |
0275: CALL 08B |
|
|
367 |
.................... } |
|
|
368 |
0276: INCF 2D,F |
|
|
369 |
0277: GOTO 268 |
|
|
370 |
.................... } |
|
|
371 |
0278: GOTO 610 (RETURN) |
|
|
372 |
.................... |
|
|
373 |
.................... |
|
|
374 |
.................... // Proved presun kurzoru |
|
|
375 |
.................... // |
|
|
376 |
.................... // Pozice 1.1 je domu |
|
|
377 |
.................... // |
|
|
378 |
.................... void lcd_gotoxy( BYTE x, BYTE y) |
|
|
379 |
.................... { |
|
|
380 |
.................... |
|
|
381 |
.................... BYTE Adr; |
|
|
382 |
.................... |
|
|
383 |
.................... Adr=x-1; |
|
|
384 |
0279: MOVLW 01 |
|
|
385 |
027A: SUBWF 48,W |
|
|
386 |
027B: MOVWF 4A |
|
|
387 |
.................... if(y==2) |
|
|
388 |
027C: MOVF 49,W |
|
|
389 |
027D: SUBLW 02 |
|
|
390 |
027E: BTFSS 03.2 |
|
|
391 |
027F: GOTO 282 |
|
|
392 |
.................... Adr+=LCD_LINE_2; |
|
|
393 |
0280: MOVLW 40 |
|
|
394 |
0281: ADDWF 4A,F |
|
|
395 |
.................... |
|
|
396 |
.................... lcd_send_byte(0,0x80|Adr); |
|
|
397 |
0282: MOVF 4A,W |
|
|
398 |
0283: IORLW 80 |
|
|
399 |
0284: MOVWF 4B |
|
|
400 |
0285: CLRF 4C |
|
|
401 |
0286: MOVF 4B,W |
|
|
402 |
0287: MOVWF 4D |
|
|
403 |
0288: CALL 224 |
|
|
404 |
.................... } |
|
|
405 |
0289: RETLW 00 |
|
|
406 |
.................... |
|
|
407 |
.................... |
|
|
408 |
.................... // Zapis znaku na displej, zpracovani ridicich znaku |
|
|
409 |
.................... // |
|
|
410 |
.................... void lcd_putc( char c) |
|
|
411 |
.................... { |
|
|
412 |
.................... |
|
|
413 |
.................... switch (c) |
|
|
414 |
.................... { |
|
|
415 |
028A: MOVF 47,W |
|
|
416 |
028B: XORLW 0C |
|
|
417 |
028C: BTFSC 03.2 |
|
|
418 |
028D: GOTO 298 |
|
|
419 |
028E: XORLW 06 |
|
|
420 |
028F: BTFSC 03.2 |
|
|
421 |
0290: GOTO 2A0 |
|
|
422 |
0291: XORLW 07 |
|
|
423 |
0292: BTFSC 03.2 |
|
|
424 |
0293: GOTO 2A6 |
|
|
425 |
0294: XORLW 05 |
|
|
426 |
0295: BTFSC 03.2 |
|
|
427 |
0296: GOTO 2AB |
|
|
428 |
0297: GOTO 2B0 |
|
|
429 |
.................... case '\f' : lcd_send_byte(0,1); // smaz displej |
|
|
430 |
0298: CLRF 4C |
|
|
431 |
0299: MOVLW 01 |
|
|
432 |
029A: MOVWF 4D |
|
|
433 |
029B: CALL 224 |
|
|
434 |
.................... delay_ms(2); |
|
|
435 |
029C: MOVLW 02 |
|
|
436 |
029D: MOVWF 48 |
|
|
437 |
029E: CALL 08B |
|
|
438 |
.................... break; |
|
|
439 |
029F: GOTO 2BC |
|
|
440 |
.................... case '\n' : lcd_gotoxy(1,2); break; // presun se na 1. znak 2. radky |
|
|
441 |
02A0: MOVLW 01 |
|
|
442 |
02A1: MOVWF 48 |
|
|
443 |
02A2: MOVLW 02 |
|
|
444 |
02A3: MOVWF 49 |
|
|
445 |
02A4: CALL 279 |
|
|
446 |
02A5: GOTO 2BC |
|
|
447 |
.................... case '\r' : lcd_gotoxy(1,1); break; // presun home |
|
|
448 |
02A6: MOVLW 01 |
|
|
449 |
02A7: MOVWF 48 |
|
|
450 |
02A8: MOVWF 49 |
|
|
451 |
02A9: CALL 279 |
|
|
452 |
02AA: GOTO 2BC |
|
|
453 |
.................... case '\b' : lcd_send_byte(0,0x10); break; // posun kurzor o 1 zpet |
|
|
454 |
02AB: CLRF 4C |
|
|
455 |
02AC: MOVLW 10 |
|
|
456 |
02AD: MOVWF 4D |
|
|
457 |
02AE: CALL 224 |
|
|
458 |
02AF: GOTO 2BC |
|
|
459 |
.................... default : if (c<0x20) c&=0x7; // preklopeni definovatelnych znaku na rozsah 0 az 0x1F |
|
|
460 |
02B0: MOVF 47,W |
|
|
461 |
02B1: SUBLW 1F |
|
|
462 |
02B2: BTFSS 03.0 |
|
|
463 |
02B3: GOTO 2B6 |
|
|
464 |
02B4: MOVLW 07 |
|
|
465 |
02B5: ANDWF 47,F |
|
|
466 |
.................... lcd_send_byte(1,c); break; // zapis znak |
|
|
467 |
02B6: MOVLW 01 |
|
|
468 |
02B7: MOVWF 4C |
|
|
469 |
02B8: MOVF 47,W |
|
|
470 |
02B9: MOVWF 4D |
|
|
471 |
02BA: CALL 224 |
|
|
472 |
02BB: GOTO 2BC |
|
|
473 |
.................... } |
|
|
474 |
.................... } |
|
|
475 |
02BC: RETLW 00 |
|
|
476 |
.................... |
|
|
477 |
.................... |
|
|
478 |
.................... // Zapni kurzor |
|
|
479 |
.................... // |
|
|
480 |
.................... void lcd_cursor_on() |
|
|
481 |
.................... { |
|
|
482 |
.................... lcd_send_byte(0,LCD_CURSOR_ON_); |
|
|
483 |
.................... } |
|
|
484 |
.................... |
|
|
485 |
.................... |
|
|
486 |
.................... // Vypni kurzor |
|
|
487 |
.................... // |
|
|
488 |
.................... void lcd_cursor_off() |
|
|
489 |
.................... { |
|
|
490 |
.................... lcd_send_byte(0,LCD_CURSOR_OFF_); |
|
|
491 |
.................... } |
|
|
492 |
.................... |
|
|
493 |
.................... |
|
|
494 |
.................... // Smaz displej |
|
|
495 |
.................... // |
|
|
496 |
.................... void lcd_clr() |
|
|
497 |
.................... { |
|
|
498 |
.................... lcd_putc('\f'); |
|
|
499 |
.................... } |
|
|
500 |
.................... |
|
|
501 |
.................... |
|
|
502 |
.................... // Definice vlastnich fontu |
|
|
503 |
.................... // |
|
|
504 |
.................... // Vlastnich definic muze byt jen 8 do pozic 0 az 7 pameti CGRAM radice lcd displeje |
|
|
505 |
.................... // Pro snadne definovani jsou pripraveny nasledujici definice a na konci souboru je uveden |
|
|
506 |
.................... // priklad pouziti definovanych znaku. |
|
|
507 |
.................... |
|
|
508 |
.................... |
|
|
509 |
.................... // Pomocna procedura pro posilani ridicich dat do radice displeje |
|
|
510 |
.................... // |
|
|
511 |
.................... void lcd_putc2(int Data) |
|
|
512 |
.................... { |
|
|
513 |
.................... lcd_send_byte(1,Data); |
|
|
514 |
.................... } |
|
|
515 |
.................... |
|
|
516 |
.................... |
|
|
517 |
.................... // Pomocne definice pro programovani obsahu CGRAM |
|
|
518 |
.................... // |
|
|
519 |
.................... #define lcd_define_start(Code) lcd_send_byte(0,0x40+(Code<<3)); delay_ms(2) |
|
|
520 |
.................... #define lcd_define_def(String) printf(lcd_putc2,String); |
|
|
521 |
.................... #define lcd_define_end() lcd_send_byte(0,3); delay_ms(2) |
|
|
522 |
.................... |
|
|
523 |
.................... |
|
|
524 |
.................... // Vlastni vykonne makro pro definovani fontu do pozice Index CGRAM s definicnim retezcem Def |
|
|
525 |
.................... // |
|
|
526 |
.................... #define lcd_define_char(Index, Def) lcd_define_start(Index); lcd_define_def(Def); lcd_define_end(); |
|
|
527 |
.................... |
|
|
528 |
.................... |
|
|
529 |
.................... // Pripravene definice fontu vybranych znaku |
|
|
530 |
.................... // V tabulce nesmi byt 00 (konec retezce v printf()), misto toho davame 80 |
|
|
531 |
.................... // |
|
|
532 |
.................... #define LCD_CHAR_BAT100 "\x0E\x1F\x1F\x1F\x1F\x1F\x1F\x1F" /* symbol plne baterie */ |
|
|
533 |
.................... #define LCD_CHAR_BAT50 "\x0E\x1F\x11\x11\x13\x17\x1F\x1F" /* symbol polovicni baterie */ |
|
|
534 |
.................... #define LCD_CHAR_BAT0 "\x0E\x1F\x11\x11\x11\x11\x11\x1F" /* symbol vybite baterie */ |
|
|
535 |
.................... #define LCD_CHAR_UP "\x80\x04\x0E\x15\x04\x04\x04\x80" /* symbol sipka nahoru */ |
|
|
536 |
.................... #define LCD_CHAR_DOWN "\x80\x04\x04\x04\x15\x0E\x04\x80" /* symbol Sipka dolu */ |
|
|
537 |
.................... #define LCD_CHAR_LUA "\x04\x0E\x11\x11\x1F\x11\x11\x80" /* A s carkou */ |
|
|
538 |
.................... #define LCD_CHAR_LLA "\x01\x02\x0E\x01\x1F\x11\x0F\x80" /* a s carkou */ |
|
|
539 |
.................... #define LCD_CHAR_HUC "\x0A\x0E\x11\x10\x10\x11\x0E\x80" /* C s hackem */ |
|
|
540 |
.................... #define LCD_CHAR_HLC "\x0A\x04\x0E\x10\x10\x11\x0E\x80" /* c s hackem */ |
|
|
541 |
.................... #define LCD_CHAR_HUD "\x0A\x1C\x12\x11\x11\x12\x1C\x80" /* D s hackem */ |
|
|
542 |
.................... #define LCD_CHAR_HLD "\x05\x03\x0D\x13\x11\x11\x0F\x80" /* d s hackem */ |
|
|
543 |
.................... #define LCD_CHAR_LUE "\x04\x1F\x10\x10\x1E\x10\x1F\x80" /* E s carkou */ |
|
|
544 |
.................... #define LCD_CHAR_LLE "\x01\x02\x0E\x11\x1F\x10\x0E\x80" /* e s carkou */ |
|
|
545 |
.................... #define LCD_CHAR_HUE "\x0A\x1F\x10\x1E\x10\x10\x1F\x80" /* E s hackem */ |
|
|
546 |
.................... #define LCD_CHAR_HLE "\x0A\x04\x0E\x11\x1F\x10\x0E\x80" /* e s hackem */ |
|
|
547 |
.................... #define LCD_CHAR_LUI "\x04\x0E\x04\x04\x04\x04\x0E\x80" /* I s carkou */ |
|
|
548 |
.................... #define LCD_CHAR_LLI "\x02\x04\x80\x0C\x04\x04\x0E\x80" /* i s carkou */ |
|
|
549 |
.................... #define LCD_CHAR_HUN "\x0A\x15\x11\x19\x15\x13\x11\x80" /* N s hackem */ |
|
|
550 |
.................... #define LCD_CHAR_HLN "\x0A\x04\x16\x19\x11\x11\x11\x80" /* n s hackem */ |
|
|
551 |
.................... #define LCD_CHAR_LUO "\x04\x0E\x11\x11\x11\x11\x0E\x80" /* O s carkou */ |
|
|
552 |
.................... #define LCD_CHAR_LLO "\x02\x04\x0E\x11\x11\x11\x0E\x80" /* o s carkou */ |
|
|
553 |
.................... #define LCD_CHAR_HUR "\x0A\x1E\x11\x1E\x14\x12\x11\x80" /* R s hackem */ |
|
|
554 |
.................... #define LCD_CHAR_HLR "\x0A\x04\x16\x19\x10\x10\x10\x80" /* r s hackem */ |
|
|
555 |
.................... #define LCD_CHAR_HUS "\x0A\x0F\x10\x0E\x01\x01\x1E\x80" /* S s hackem */ |
|
|
556 |
.................... #define LCD_CHAR_HLS "\x0A\x04\x0E\x10\x0E\x01\x1E\x80" /* s s hackem */ |
|
|
557 |
.................... #define LCD_CHAR_HUT "\x0A\x1F\x04\x04\x04\x04\x04\x80" /* T s hackem */ |
|
|
558 |
.................... #define LCD_CHAR_HLT "\x0A\x0C\x1C\x08\x08\x09\x06\x80" /* t s hackem */ |
|
|
559 |
.................... #define LCD_CHAR_LUU "\x02\x15\x11\x11\x11\x11\x0E\x80" /* U s carkou */ |
|
|
560 |
.................... #define LCD_CHAR_LLU "\x02\x04\x11\x11\x11\x13\x0D\x80" /* u s carkou */ |
|
|
561 |
.................... #define LCD_CHAR_CUU "\x06\x17\x11\x11\x11\x11\x0E\x80" /* U s krouzkem */ |
|
|
562 |
.................... #define LCD_CHAR_CLU "\x06\x06\x11\x11\x11\x11\x0E\x80" /* u s krouzkem */ |
|
|
563 |
.................... #define LCD_CHAR_LUY "\x02\x15\x11\x0A\x04\x04\x04\x80" /* Y s carkou */ |
|
|
564 |
.................... #define LCD_CHAR_LLY "\x02\x04\x11\x11\x0F\x01\x0E\x80" /* y s carkou */ |
|
|
565 |
.................... #define LCD_CHAR_HUZ "\x0A\x1F\x01\x02\x04\x08\x1F\x80" /* Z s hackem */ |
|
|
566 |
.................... #define LCD_CHAR_HLZ "\x0A\x04\x1F\x02\x04\x08\x1F\x80" /* z s hackem */ |
|
|
567 |
.................... |
|
|
568 |
.................... |
|
|
569 |
.................... // Priklad pouziti definovanych znaku |
|
|
570 |
.................... // |
|
|
571 |
.................... // |
|
|
572 |
.................... //void lcd_sample() |
|
|
573 |
.................... //{ |
|
|
574 |
.................... // lcd_define_char(0,LCD_CHAR_BAT50); // Priklad definice znaku baterie do pozice 0 |
|
|
575 |
.................... // lcd_define_char(2,LCD_CHAR_HLE LCD_CHAR_LUI); // Priklad definice znaku e s hackem a I s carkou od pozice 2 |
|
|
576 |
.................... // // vsimnete si, ze neni carka mezi retezci s definici (oba retezce definuji |
|
|
577 |
.................... // // jediny definicni retezec) |
|
|
578 |
.................... // printf(lcd_putc,"\fZnaky:\20\22\23"); // priklad vypisu znaku z pozice 0, 2 a 3 |
|
|
579 |
.................... // delay_ms(1000); |
|
|
580 |
.................... // lcd_define_char(0,LCD_CHAR_BAT0); // Predefinovani tvaru znaku v pozici 0 |
|
|
581 |
.................... // delay_ms(1000); |
|
|
582 |
.................... //} |
|
|
583 |
.................... |
|
|
584 |
.................... |
|
|
585 |
.................... #include "1wire.c" //pro mìøení teploty |
|
|
586 |
.................... #define ONE_WIRE_PIN PIN_A1 |
|
|
587 |
.................... |
|
|
588 |
.................... void onewire_reset() |
|
|
589 |
.................... |
|
|
590 |
.................... |
|
|
591 |
.................... |
|
|
592 |
.................... { |
|
|
593 |
.................... output_low(ONE_WIRE_PIN); |
|
|
594 |
* |
|
|
595 |
0032: BSF 03.5 |
|
|
596 |
0033: BCF 05.1 |
|
|
597 |
0034: BCF 03.5 |
|
|
598 |
0035: BCF 05.1 |
|
|
599 |
.................... delay_us(500); |
|
|
600 |
0036: CLRWDT |
|
|
601 |
0037: MOVLW A6 |
|
|
602 |
0038: MOVWF 77 |
|
|
603 |
0039: DECFSZ 77,F |
|
|
604 |
003A: GOTO 039 |
|
|
605 |
.................... output_float(ONE_WIRE_PIN); |
|
|
606 |
003B: BSF 03.5 |
|
|
607 |
003C: BSF 05.1 |
|
|
608 |
.................... delay_us(500); |
|
|
609 |
003D: CLRWDT |
|
|
610 |
003E: MOVLW A6 |
|
|
611 |
003F: MOVWF 77 |
|
|
612 |
0040: DECFSZ 77,F |
|
|
613 |
0041: GOTO 040 |
|
|
614 |
.................... output_float(ONE_WIRE_PIN); |
|
|
615 |
0042: BSF 05.1 |
|
|
616 |
.................... } |
|
|
617 |
0043: BCF 03.5 |
|
|
618 |
0044: RETLW 00 |
|
|
619 |
.................... |
|
|
620 |
.................... |
|
|
621 |
.................... void onewire_write(int data) |
|
|
622 |
.................... { |
|
|
623 |
.................... int count; |
|
|
624 |
.................... |
|
|
625 |
.................... for (count=0; count<8; ++count) |
|
|
626 |
0045: CLRF 37 |
|
|
627 |
0046: MOVF 37,W |
|
|
628 |
0047: SUBLW 07 |
|
|
629 |
0048: BTFSS 03.0 |
|
|
630 |
0049: GOTO 065 |
|
|
631 |
.................... { |
|
|
632 |
.................... output_low(ONE_WIRE_PIN); |
|
|
633 |
004A: BSF 03.5 |
|
|
634 |
004B: BCF 05.1 |
|
|
635 |
004C: BCF 03.5 |
|
|
636 |
004D: BCF 05.1 |
|
|
637 |
.................... delay_us( 2 ); |
|
|
638 |
004E: CLRWDT |
|
|
639 |
004F: NOP |
|
|
640 |
.................... output_bit(ONE_WIRE_PIN, shift_right(&data,1,1)); |
|
|
641 |
0050: BSF 03.0 |
|
|
642 |
0051: RRF 36,F |
|
|
643 |
0052: BTFSC 03.0 |
|
|
644 |
0053: GOTO 056 |
|
|
645 |
0054: BCF 05.1 |
|
|
646 |
0055: GOTO 057 |
|
|
647 |
0056: BSF 05.1 |
|
|
648 |
0057: BSF 03.5 |
|
|
649 |
0058: BCF 05.1 |
|
|
650 |
.................... |
|
|
651 |
.................... delay_us( 60 ); |
|
|
652 |
0059: CLRWDT |
|
|
653 |
005A: MOVLW 13 |
|
|
654 |
005B: MOVWF 77 |
|
|
655 |
005C: DECFSZ 77,F |
|
|
656 |
005D: GOTO 05C |
|
|
657 |
005E: NOP |
|
|
658 |
.................... output_float(ONE_WIRE_PIN); |
|
|
659 |
005F: BSF 05.1 |
|
|
660 |
.................... delay_us( 2 ); |
|
|
661 |
0060: CLRWDT |
|
|
662 |
0061: NOP |
|
|
663 |
.................... } |
|
|
664 |
0062: BCF 03.5 |
|
|
665 |
0063: INCF 37,F |
|
|
666 |
0064: GOTO 046 |
|
|
667 |
.................... } |
|
|
668 |
0065: RETLW 00 |
|
|
669 |
.................... |
|
|
670 |
.................... |
|
|
671 |
.................... int onewire_read() |
|
|
672 |
.................... { |
|
|
673 |
.................... int count, data; |
|
|
674 |
.................... |
|
|
675 |
.................... for (count=0; count<8; ++count) |
|
|
676 |
0066: CLRF 36 |
|
|
677 |
0067: MOVF 36,W |
|
|
678 |
0068: SUBLW 07 |
|
|
679 |
0069: BTFSS 03.0 |
|
|
680 |
006A: GOTO 088 |
|
|
681 |
.................... { |
|
|
682 |
.................... output_low(ONE_WIRE_PIN); |
|
|
683 |
006B: BSF 03.5 |
|
|
684 |
006C: BCF 05.1 |
|
|
685 |
006D: BCF 03.5 |
|
|
686 |
006E: BCF 05.1 |
|
|
687 |
.................... delay_us( 2 ); |
|
|
688 |
006F: CLRWDT |
|
|
689 |
0070: NOP |
|
|
690 |
.................... output_float(ONE_WIRE_PIN); |
|
|
691 |
0071: BSF 03.5 |
|
|
692 |
0072: BSF 05.1 |
|
|
693 |
.................... delay_us( 8 ); |
|
|
694 |
0073: CLRWDT |
|
|
695 |
0074: MOVLW 02 |
|
|
696 |
0075: MOVWF 77 |
|
|
697 |
0076: DECFSZ 77,F |
|
|
698 |
0077: GOTO 076 |
|
|
699 |
.................... shift_right(&data,1,input(ONE_WIRE_PIN)); |
|
|
700 |
0078: BSF 05.1 |
|
|
701 |
0079: BCF 03.5 |
|
|
702 |
007A: BTFSC 05.1 |
|
|
703 |
007B: GOTO 07E |
|
|
704 |
007C: BCF 03.0 |
|
|
705 |
007D: GOTO 07F |
|
|
706 |
007E: BSF 03.0 |
|
|
707 |
007F: RRF 37,F |
|
|
708 |
.................... delay_us( 120 ); |
|
|
709 |
0080: CLRWDT |
|
|
710 |
0081: MOVLW 27 |
|
|
711 |
0082: MOVWF 77 |
|
|
712 |
0083: DECFSZ 77,F |
|
|
713 |
0084: GOTO 083 |
|
|
714 |
0085: NOP |
|
|
715 |
.................... } |
|
|
716 |
0086: INCF 36,F |
|
|
717 |
0087: GOTO 067 |
|
|
718 |
.................... |
|
|
719 |
.................... return( data ); |
|
|
720 |
0088: MOVF 37,W |
|
|
721 |
0089: MOVWF 78 |
|
|
722 |
.................... } |
|
|
723 |
008A: RETLW 00 |
|
|
724 |
.................... |
|
|
725 |
.................... #include "ds1820.c" //pro mìøení teploty |
|
|
726 |
.................... |
|
|
727 |
.................... float ds1820_read() |
|
|
728 |
.................... { |
|
|
729 |
.................... int8 busy=0, temp1, temp2; |
|
|
730 |
* |
|
|
731 |
00A3: CLRF 2D |
|
|
732 |
.................... signed int16 temp3; |
|
|
733 |
.................... float result; |
|
|
734 |
.................... |
|
|
735 |
.................... onewire_reset(); |
|
|
736 |
00A4: CALL 032 |
|
|
737 |
.................... onewire_write(0xCC); |
|
|
738 |
00A5: MOVLW CC |
|
|
739 |
00A6: MOVWF 36 |
|
|
740 |
00A7: CALL 045 |
|
|
741 |
.................... onewire_write(0x44); |
|
|
742 |
00A8: MOVLW 44 |
|
|
743 |
00A9: MOVWF 36 |
|
|
744 |
00AA: CALL 045 |
|
|
745 |
.................... |
|
|
746 |
.................... while (busy == 0) |
|
|
747 |
.................... busy = onewire_read(); |
|
|
748 |
00AB: MOVF 2D,F |
|
|
749 |
00AC: BTFSS 03.2 |
|
|
750 |
00AD: GOTO 0B2 |
|
|
751 |
00AE: CALL 066 |
|
|
752 |
00AF: MOVF 78,W |
|
|
753 |
00B0: MOVWF 2D |
|
|
754 |
00B1: GOTO 0AB |
|
|
755 |
.................... |
|
|
756 |
.................... onewire_reset(); |
|
|
757 |
00B2: CALL 032 |
|
|
758 |
.................... onewire_write(0xCC); |
|
|
759 |
00B3: MOVLW CC |
|
|
760 |
00B4: MOVWF 36 |
|
|
761 |
00B5: CALL 045 |
|
|
762 |
.................... onewire_write(0xBE); |
|
|
763 |
00B6: MOVLW BE |
|
|
764 |
00B7: MOVWF 36 |
|
|
765 |
00B8: CALL 045 |
|
|
766 |
.................... temp1 = onewire_read(); |
|
|
767 |
00B9: CALL 066 |
|
|
768 |
00BA: MOVF 78,W |
|
|
769 |
00BB: MOVWF 2E |
|
|
770 |
.................... temp2 = onewire_read(); |
|
|
771 |
00BC: CALL 066 |
|
|
772 |
00BD: MOVF 78,W |
|
|
773 |
00BE: MOVWF 2F |
|
|
774 |
.................... temp3 = make16(temp2, temp1); |
|
|
775 |
00BF: MOVF 2F,W |
|
|
776 |
00C0: MOVWF 31 |
|
|
777 |
00C1: MOVF 2E,W |
|
|
778 |
00C2: MOVWF 30 |
|
|
779 |
.................... |
|
|
780 |
.................... result = (float) temp3 / 16.0; //calculation pro DS18B20 with 0.1 deg C |
|
|
781 |
00C3: MOVF 31,W |
|
|
782 |
00C4: MOVWF 37 |
|
|
783 |
00C5: MOVF 30,W |
|
|
784 |
00C6: MOVWF 36 |
|
|
785 |
* |
|
|
786 |
00EB: MOVF 77,W |
|
|
787 |
00EC: MOVWF 36 |
|
|
788 |
00ED: MOVF 78,W |
|
|
789 |
00EE: MOVWF 37 |
|
|
790 |
00EF: MOVF 79,W |
|
|
791 |
00F0: MOVWF 38 |
|
|
792 |
00F1: MOVF 7A,W |
|
|
793 |
00F2: MOVWF 39 |
|
|
794 |
00F3: MOVF 39,W |
|
|
795 |
00F4: MOVWF 3D |
|
|
796 |
00F5: MOVF 38,W |
|
|
797 |
00F6: MOVWF 3C |
|
|
798 |
00F7: MOVF 37,W |
|
|
799 |
00F8: MOVWF 3B |
|
|
800 |
00F9: MOVF 36,W |
|
|
801 |
00FA: MOVWF 3A |
|
|
802 |
00FB: CLRF 41 |
|
|
803 |
00FC: CLRF 40 |
|
|
804 |
00FD: CLRF 3F |
|
|
805 |
00FE: MOVLW 83 |
|
|
806 |
00FF: MOVWF 3E |
|
|
807 |
* |
|
|
808 |
01C9: MOVF 7A,W |
|
|
809 |
01CA: MOVWF 35 |
|
|
810 |
01CB: MOVF 79,W |
|
|
811 |
01CC: MOVWF 34 |
|
|
812 |
01CD: MOVF 78,W |
|
|
813 |
01CE: MOVWF 33 |
|
|
814 |
01CF: MOVF 77,W |
|
|
815 |
01D0: MOVWF 32 |
|
|
816 |
.................... |
|
|
817 |
.................... |
|
|
818 |
.................... delay_ms(200); |
|
|
819 |
01D1: MOVLW C8 |
|
|
820 |
01D2: MOVWF 48 |
|
|
821 |
01D3: CALL 08B |
|
|
822 |
.................... return(result); |
|
|
823 |
01D4: MOVF 32,W |
|
|
824 |
01D5: MOVWF 77 |
|
|
825 |
01D6: MOVF 33,W |
|
|
826 |
01D7: MOVWF 78 |
|
|
827 |
01D8: MOVF 34,W |
|
|
828 |
01D9: MOVWF 79 |
|
|
829 |
01DA: MOVF 35,W |
|
|
830 |
01DB: MOVWF 7A |
|
|
831 |
.................... |
|
|
832 |
.................... } |
|
|
833 |
01DC: GOTO 5EB (RETURN) |
|
|
834 |
.................... |
|
|
835 |
.................... |
|
|
836 |
.................... void main() |
|
|
837 |
.................... { |
|
|
838 |
* |
|
|
839 |
059C: CLRF 04 |
|
|
840 |
059D: BCF 03.7 |
|
|
841 |
059E: MOVLW 1F |
|
|
842 |
059F: ANDWF 03,F |
|
|
843 |
05A0: BSF 03.5 |
|
|
844 |
05A1: BSF 1F.0 |
|
|
845 |
05A2: BSF 1F.1 |
|
|
846 |
05A3: BSF 1F.2 |
|
|
847 |
05A4: BCF 1F.3 |
|
|
848 |
05A5: MOVLW 07 |
|
|
849 |
05A6: MOVWF 1C |
|
|
850 |
.................... |
|
|
851 |
.................... double t; // promena pro hodnotu z A/D pro tlak |
|
|
852 |
.................... double a; // konstanta pro vypocet tlaku |
|
|
853 |
.................... |
|
|
854 |
.................... float temperature; //pro mìøení teploty |
|
|
855 |
.................... |
|
|
856 |
.................... setup_adc_ports(AN0); |
|
|
857 |
* |
|
|
858 |
05AA: BSF 03.5 |
|
|
859 |
05AB: BCF 1F.0 |
|
|
860 |
05AC: BSF 1F.1 |
|
|
861 |
05AD: BSF 1F.2 |
|
|
862 |
05AE: BSF 1F.3 |
|
|
863 |
.................... setup_adc(ADC_CLOCK_INTERNAL); |
|
|
864 |
05AF: BCF 1F.6 |
|
|
865 |
05B0: BCF 03.5 |
|
|
866 |
05B1: BSF 1F.6 |
|
|
867 |
05B2: BSF 1F.7 |
|
|
868 |
05B3: BSF 03.5 |
|
|
869 |
05B4: BSF 1F.7 |
|
|
870 |
05B5: BCF 03.5 |
|
|
871 |
05B6: BSF 1F.0 |
|
|
872 |
.................... setup_psp(PSP_DISABLED); |
|
|
873 |
05B7: BSF 03.5 |
|
|
874 |
05B8: BCF 09.4 |
|
|
875 |
.................... setup_spi(SPI_SS_DISABLED); |
|
|
876 |
05B9: BCF 03.5 |
|
|
877 |
05BA: BCF 14.5 |
|
|
878 |
05BB: BCF 20.5 |
|
|
879 |
05BC: MOVF 20,W |
|
|
880 |
05BD: BSF 03.5 |
|
|
881 |
05BE: MOVWF 07 |
|
|
882 |
05BF: BCF 03.5 |
|
|
883 |
05C0: BSF 20.4 |
|
|
884 |
05C1: MOVF 20,W |
|
|
885 |
05C2: BSF 03.5 |
|
|
886 |
05C3: MOVWF 07 |
|
|
887 |
05C4: BCF 03.5 |
|
|
888 |
05C5: BCF 20.3 |
|
|
889 |
05C6: MOVF 20,W |
|
|
890 |
05C7: BSF 03.5 |
|
|
891 |
05C8: MOVWF 07 |
|
|
892 |
05C9: MOVLW 01 |
|
|
893 |
05CA: BCF 03.5 |
|
|
894 |
05CB: MOVWF 14 |
|
|
895 |
05CC: MOVLW 00 |
|
|
896 |
05CD: BSF 03.5 |
|
|
897 |
05CE: MOVWF 14 |
|
|
898 |
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); |
|
|
899 |
05CF: MOVF 01,W |
|
|
900 |
05D0: ANDLW C7 |
|
|
901 |
05D1: IORLW 08 |
|
|
902 |
05D2: MOVWF 01 |
|
|
903 |
.................... setup_timer_1(T1_DISABLED); |
|
|
904 |
05D3: BCF 03.5 |
|
|
905 |
05D4: CLRF 10 |
|
|
906 |
.................... setup_timer_2(T2_DISABLED,0,1); |
|
|
907 |
05D5: MOVLW 00 |
|
|
908 |
05D6: MOVWF 78 |
|
|
909 |
05D7: MOVWF 12 |
|
|
910 |
05D8: MOVLW 00 |
|
|
911 |
05D9: BSF 03.5 |
|
|
912 |
05DA: MOVWF 12 |
|
|
913 |
.................... setup_comparator(NC_NC_NC_NC); |
|
|
914 |
05DB: MOVLW 07 |
|
|
915 |
05DC: MOVWF 1C |
|
|
916 |
05DD: MOVF 05,W |
|
|
917 |
05DE: CLRWDT |
|
|
918 |
05DF: MOVLW 02 |
|
|
919 |
05E0: MOVWF 77 |
|
|
920 |
05E1: DECFSZ 77,F |
|
|
921 |
05E2: GOTO 5E1 |
|
|
922 |
05E3: GOTO 5E4 |
|
|
923 |
05E4: MOVF 1C,W |
|
|
924 |
05E5: BCF 03.5 |
|
|
925 |
05E6: BCF 0D.6 |
|
|
926 |
.................... setup_vref(FALSE); |
|
|
927 |
05E7: BSF 03.5 |
|
|
928 |
05E8: CLRF 1D |
|
|
929 |
.................... |
|
|
930 |
.................... // TODO: USER CODE!! |
|
|
931 |
.................... |
|
|
932 |
.................... while(true) |
|
|
933 |
.................... { |
|
|
934 |
.................... temperature = ds1820_read(); //naètení teploty z èidla |
|
|
935 |
05E9: BCF 03.5 |
|
|
936 |
05EA: GOTO 0A3 |
|
|
937 |
05EB: MOVF 7A,W |
|
|
938 |
05EC: MOVWF 2C |
|
|
939 |
05ED: MOVF 79,W |
|
|
940 |
05EE: MOVWF 2B |
|
|
941 |
05EF: MOVF 78,W |
|
|
942 |
05F0: MOVWF 2A |
|
|
943 |
05F1: MOVF 77,W |
|
|
944 |
05F2: MOVWF 29 |
|
|
945 |
.................... |
|
|
946 |
.................... a = 0.10850694; //konstantak pro tlak |
|
|
947 |
05F3: MOVLW E3 |
|
|
948 |
05F4: MOVWF 28 |
|
|
949 |
05F5: MOVLW 38 |
|
|
950 |
05F6: MOVWF 27 |
|
|
951 |
05F7: MOVLW 5E |
|
|
952 |
05F8: MOVWF 26 |
|
|
953 |
05F9: MOVLW 7B |
|
|
954 |
05FA: MOVWF 25 |
|
|
955 |
.................... t = read_adc(); //za t dosazení hodnoty z a/d pro tlak |
|
|
956 |
05FB: BSF 1F.2 |
|
|
957 |
05FC: BTFSC 1F.2 |
|
|
958 |
05FD: GOTO 5FC |
|
|
959 |
05FE: MOVF 1E,W |
|
|
960 |
05FF: MOVWF 7A |
|
|
961 |
0600: BSF 03.5 |
|
|
962 |
0601: MOVF 1E,W |
|
|
963 |
0602: BCF 03.5 |
|
|
964 |
0603: MOVWF 2D |
|
|
965 |
0604: MOVF 1E,W |
|
|
966 |
0605: MOVWF 2E |
|
|
967 |
0606: GOTO 1DD |
|
|
968 |
0607: MOVF 7A,W |
|
|
969 |
0608: MOVWF 24 |
|
|
970 |
0609: MOVF 79,W |
|
|
971 |
060A: MOVWF 23 |
|
|
972 |
060B: MOVF 78,W |
|
|
973 |
060C: MOVWF 22 |
|
|
974 |
060D: MOVF 77,W |
|
|
975 |
060E: MOVWF 21 |
|
|
976 |
.................... |
|
|
977 |
.................... |
|
|
978 |
.................... |
|
|
979 |
.................... lcd_init(); //inicializuje LCD |
|
|
980 |
060F: GOTO 23E |
|
|
981 |
.................... LCD_gotoxy(1,1); //na LCD 1bunka 1øadek |
|
|
982 |
0610: MOVLW 01 |
|
|
983 |
0611: MOVWF 48 |
|
|
984 |
0612: MOVWF 49 |
|
|
985 |
0613: CALL 279 |
|
|
986 |
.................... printf(lcd_putc,"Temp: %5.3f°C ", temperature); //teplota v °C |
|
|
987 |
0614: CLRF 2D |
|
|
988 |
0615: MOVF 2D,W |
|
|
989 |
0616: CALL 00C |
|
|
990 |
0617: INCF 2D,F |
|
|
991 |
0618: MOVWF 77 |
|
|
992 |
0619: MOVWF 47 |
|
|
993 |
061A: CALL 28A |
|
|
994 |
061B: MOVLW 06 |
|
|
995 |
061C: SUBWF 2D,W |
|
|
996 |
061D: BTFSS 03.2 |
|
|
997 |
061E: GOTO 615 |
|
|
998 |
061F: MOVLW 04 |
|
|
999 |
0620: MOVWF 04 |
|
|
1000 |
0621: MOVF 2C,W |
|
|
1001 |
0622: MOVWF 3D |
|
|
1002 |
0623: MOVF 2B,W |
|
|
1003 |
0624: MOVWF 3C |
|
|
1004 |
0625: MOVF 2A,W |
|
|
1005 |
0626: MOVWF 3B |
|
|
1006 |
0627: MOVF 29,W |
|
|
1007 |
0628: MOVWF 3A |
|
|
1008 |
0629: MOVLW 03 |
|
|
1009 |
062A: MOVWF 3E |
|
|
1010 |
062B: CALL 374 |
|
|
1011 |
062C: MOVLW B0 |
|
|
1012 |
062D: MOVWF 47 |
|
|
1013 |
062E: CALL 28A |
|
|
1014 |
062F: MOVLW 43 |
|
|
1015 |
0630: MOVWF 47 |
|
|
1016 |
0631: CALL 28A |
|
|
1017 |
0632: MOVLW 20 |
|
|
1018 |
0633: MOVWF 47 |
|
|
1019 |
0634: CALL 28A |
|
|
1020 |
.................... |
|
|
1021 |
.................... LCD_gotoxy(1,2); //na LCD 1bunka 2øadek |
|
|
1022 |
0635: MOVLW 01 |
|
|
1023 |
0636: MOVWF 48 |
|
|
1024 |
0637: MOVLW 02 |
|
|
1025 |
0638: MOVWF 49 |
|
|
1026 |
0639: CALL 279 |
|
|
1027 |
.................... printf(lcd_putc,"Tlak: %5.3fkPa", ((t-41)*a)+15 ); //tiska tlaku v kPa |
|
|
1028 |
063A: BSF 03.1 |
|
|
1029 |
063B: MOVF 24,W |
|
|
1030 |
063C: MOVWF 38 |
|
|
1031 |
063D: MOVF 23,W |
|
|
1032 |
063E: MOVWF 37 |
|
|
1033 |
063F: MOVF 22,W |
|
|
1034 |
0640: MOVWF 36 |
|
|
1035 |
0641: MOVF 21,W |
|
|
1036 |
0642: MOVWF 35 |
|
|
1037 |
0643: CLRF 3C |
|
|
1038 |
0644: CLRF 3B |
|
|
1039 |
0645: MOVLW 24 |
|
|
1040 |
0646: MOVWF 3A |
|
|
1041 |
0647: MOVLW 84 |
|
|
1042 |
0648: MOVWF 39 |
|
|
1043 |
0649: CALL 45B |
|
|
1044 |
064A: MOVF 77,W |
|
|
1045 |
064B: MOVWF 2D |
|
|
1046 |
064C: MOVF 78,W |
|
|
1047 |
064D: MOVWF 2E |
|
|
1048 |
064E: MOVF 79,W |
|
|
1049 |
064F: MOVWF 2F |
|
|
1050 |
0650: MOVF 7A,W |
|
|
1051 |
0651: MOVWF 30 |
|
|
1052 |
0652: MOVWF 4A |
|
|
1053 |
0653: MOVF 79,W |
|
|
1054 |
0654: MOVWF 49 |
|
|
1055 |
0655: MOVF 78,W |
|
|
1056 |
0656: MOVWF 48 |
|
|
1057 |
0657: MOVF 77,W |
|
|
1058 |
0658: MOVWF 47 |
|
|
1059 |
0659: MOVF 28,W |
|
|
1060 |
065A: MOVWF 4E |
|
|
1061 |
065B: MOVF 27,W |
|
|
1062 |
065C: MOVWF 4D |
|
|
1063 |
065D: MOVF 26,W |
|
|
1064 |
065E: MOVWF 4C |
|
|
1065 |
065F: MOVF 25,W |
|
|
1066 |
0660: MOVWF 4B |
|
|
1067 |
0661: CALL 2BD |
|
|
1068 |
0662: MOVF 77,W |
|
|
1069 |
0663: MOVWF 31 |
|
|
1070 |
0664: MOVF 78,W |
|
|
1071 |
0665: MOVWF 32 |
|
|
1072 |
0666: MOVF 79,W |
|
|
1073 |
0667: MOVWF 33 |
|
|
1074 |
0668: MOVF 7A,W |
|
|
1075 |
0669: MOVWF 34 |
|
|
1076 |
066A: BCF 03.1 |
|
|
1077 |
066B: MOVF 7A,W |
|
|
1078 |
066C: MOVWF 38 |
|
|
1079 |
066D: MOVF 79,W |
|
|
1080 |
066E: MOVWF 37 |
|
|
1081 |
066F: MOVF 78,W |
|
|
1082 |
0670: MOVWF 36 |
|
|
1083 |
0671: MOVF 77,W |
|
|
1084 |
0672: MOVWF 35 |
|
|
1085 |
0673: CLRF 3C |
|
|
1086 |
0674: CLRF 3B |
|
|
1087 |
0675: MOVLW 70 |
|
|
1088 |
0676: MOVWF 3A |
|
|
1089 |
0677: MOVLW 82 |
|
|
1090 |
0678: MOVWF 39 |
|
|
1091 |
0679: CALL 45B |
|
|
1092 |
067A: MOVF 77,W |
|
|
1093 |
067B: MOVWF 35 |
|
|
1094 |
067C: MOVF 78,W |
|
|
1095 |
067D: MOVWF 36 |
|
|
1096 |
067E: MOVF 79,W |
|
|
1097 |
067F: MOVWF 37 |
|
|
1098 |
0680: MOVF 7A,W |
|
|
1099 |
0681: MOVWF 38 |
|
|
1100 |
0682: CLRF 39 |
|
|
1101 |
0683: MOVF 39,W |
|
|
1102 |
0684: CALL 01F |
|
|
1103 |
0685: INCF 39,F |
|
|
1104 |
0686: MOVWF 77 |
|
|
1105 |
0687: MOVWF 47 |
|
|
1106 |
0688: CALL 28A |
|
|
1107 |
0689: MOVLW 06 |
|
|
1108 |
068A: SUBWF 39,W |
|
|
1109 |
068B: BTFSS 03.2 |
|
|
1110 |
068C: GOTO 683 |
|
|
1111 |
068D: MOVLW 04 |
|
|
1112 |
068E: MOVWF 04 |
|
|
1113 |
068F: MOVF 38,W |
|
|
1114 |
0690: MOVWF 3D |
|
|
1115 |
0691: MOVF 37,W |
|
|
1116 |
0692: MOVWF 3C |
|
|
1117 |
0693: MOVF 36,W |
|
|
1118 |
0694: MOVWF 3B |
|
|
1119 |
0695: MOVF 35,W |
|
|
1120 |
0696: MOVWF 3A |
|
|
1121 |
0697: MOVLW 03 |
|
|
1122 |
0698: MOVWF 3E |
|
|
1123 |
0699: CALL 374 |
|
|
1124 |
069A: MOVLW 6B |
|
|
1125 |
069B: MOVWF 47 |
|
|
1126 |
069C: CALL 28A |
|
|
1127 |
069D: MOVLW 50 |
|
|
1128 |
069E: MOVWF 47 |
|
|
1129 |
069F: CALL 28A |
|
|
1130 |
06A0: MOVLW 61 |
|
|
1131 |
06A1: MOVWF 47 |
|
|
1132 |
06A2: CALL 28A |
|
|
1133 |
.................... |
|
|
1134 |
.................... Delay_ms(100); |
|
|
1135 |
06A3: MOVLW 64 |
|
|
1136 |
06A4: MOVWF 48 |
|
|
1137 |
06A5: CALL 08B |
|
|
1138 |
.................... } |
|
|
1139 |
06A6: GOTO 5EA |
|
|
1140 |
.................... |
|
|
1141 |
.................... |
|
|
1142 |
.................... } |
|
|
1143 |
06A7: SLEEP |
|
|
1144 |
|
|
|
1145 |
Configuration Fuses: |
|
|
1146 |
Word 1: 3939 XT NOWDT NOPUT NODEBUG NOPROTECT NOBROWNOUT NOLVP NOCPD WRT_50% |