328 |
kaklik |
1 |
CCS PCM C Compiler, Version 3.245, 27853 27-VI-07 00:22
|
6 |
kaklik |
2 |
|
328 |
kaklik |
3 |
Filename: D:\KAKLIK\projekty\programy\PIC_C\mereni\gmetr\gmetr.lst
|
6 |
kaklik |
4 |
|
328 |
kaklik |
5 |
ROM used: 669 words (16%)
|
6 |
kaklik |
6 |
Largest free fragment is 2048
|
328 |
kaklik |
7 |
RAM used: 13 (7%) at main() level
|
|
|
8 |
31 (16%) worst case
|
6 |
kaklik |
9 |
Stack: 5 locations
|
|
|
10 |
|
|
|
11 |
*
|
|
|
12 |
0000: MOVLW 00
|
|
|
13 |
0001: MOVWF 0A
|
328 |
kaklik |
14 |
0002: GOTO 184
|
6 |
kaklik |
15 |
0003: NOP
|
328 |
kaklik |
16 |
.................... #include ".\gmetr.h"
|
|
|
17 |
.................... #include <16F873.h>
|
|
|
18 |
.................... //////// Standard Header file for the PIC16F873 device ////////////////
|
|
|
19 |
.................... #device PIC16F873
|
|
|
20 |
.................... #list
|
6 |
kaklik |
21 |
....................
|
328 |
kaklik |
22 |
.................... #device adc=10
|
|
|
23 |
.................... #fuses NOWDT,XT, NOPUT, NOPROTECT, NOBROWNOUT, NOLVP, NOCPD, NOWRT, NODEBUG
|
|
|
24 |
.................... #use delay(clock=4000000)
|
6 |
kaklik |
25 |
*
|
328 |
kaklik |
26 |
004C: MOVLW 36
|
|
|
27 |
004D: MOVWF 04
|
|
|
28 |
004E: MOVF 00,W
|
|
|
29 |
004F: BTFSC 03.2
|
|
|
30 |
0050: GOTO 060
|
|
|
31 |
0051: MOVLW 01
|
|
|
32 |
0052: MOVWF 21
|
|
|
33 |
0053: CLRF 20
|
|
|
34 |
0054: DECFSZ 20,F
|
|
|
35 |
0055: GOTO 054
|
|
|
36 |
0056: DECFSZ 21,F
|
|
|
37 |
0057: GOTO 053
|
|
|
38 |
0058: MOVLW 4A
|
|
|
39 |
0059: MOVWF 20
|
|
|
40 |
005A: DECFSZ 20,F
|
|
|
41 |
005B: GOTO 05A
|
|
|
42 |
005C: NOP
|
|
|
43 |
005D: NOP
|
|
|
44 |
005E: DECFSZ 00,F
|
|
|
45 |
005F: GOTO 051
|
|
|
46 |
0060: RETLW 00
|
6 |
kaklik |
47 |
....................
|
328 |
kaklik |
48 |
....................
|
|
|
49 |
....................
|
|
|
50 |
.................... #define LCD_RS PIN_B1 // rizeni registru LCD displeje
|
|
|
51 |
.................... #define LCD_E PIN_B0 // enable LCD displeje
|
|
|
52 |
.................... #define LCD_DATA_LSB PIN_C4 // pripojeni LSB bitu datoveho portu LCD displeje (celkem 4 bity vzestupne za sebou)
|
|
|
53 |
....................
|
6 |
kaklik |
54 |
.................... #include "C:\library\CCS\lcd.c"
|
328 |
kaklik |
55 |
.................... // LCD modul pro ovladani dvouradkoveho LCD modulu se standardnim Hitachi radicem
|
|
|
56 |
.................... // (c)miho 2002,2005
|
|
|
57 |
.................... //
|
|
|
58 |
.................... // Historie:
|
|
|
59 |
.................... //
|
|
|
60 |
.................... // 0.00 Uvodni verze se snadnou definici portu LCD displeje
|
|
|
61 |
.................... // 0.01 Oprava portu (zapomenute stare identifikatory)
|
|
|
62 |
.................... // 0.02 Doplnena moznost pripojeni datoveho portu LCD na libovolne porty
|
|
|
63 |
.................... // 0.03 Doplnena procedura lcd_clr pro smazani displeje
|
|
|
64 |
.................... //
|
|
|
65 |
.................... //
|
|
|
66 |
.................... // Funkce:
|
|
|
67 |
.................... //
|
|
|
68 |
.................... // lcd_init() inicializuje LCD displej a porty, nutno volat jako prvni
|
|
|
69 |
.................... //
|
|
|
70 |
.................... // lcd_putc(c) zapis snaku do lcd displeje, zpracovava nasledujici ridici znaky
|
|
|
71 |
.................... // \f = \x0C - nova stranka - smazani displeje
|
|
|
72 |
.................... // \n = \x0A - odradkovani (prechod na druhou radku)
|
|
|
73 |
.................... // \b = \x08 - backspace - posunuti kurzoru o 1 pozici zpet
|
|
|
74 |
.................... // \r = \x0D - goto home to position 1,1
|
|
|
75 |
.................... // \0 .. \7 - definovatelne znaky v pozicich 0 az 7 v CGRAM
|
|
|
76 |
.................... // \20 .. \27 - alternativne zapsane znaky (oktalove) v pozicich 0 az 7 CGRAM
|
|
|
77 |
.................... // Pozor na to, ze funkce printf konci tisk pokud narazi na \0 (konec retezce)
|
|
|
78 |
.................... //
|
|
|
79 |
.................... // lcd_gotoxy(x,y) presune kurzor na uvedenou adresu
|
|
|
80 |
.................... // nekontroluje parametry
|
|
|
81 |
.................... //
|
|
|
82 |
.................... // lcd_cursor_on zapne kurzor
|
|
|
83 |
.................... // lcd_cursor_off vypne kurzor
|
|
|
84 |
.................... //
|
|
|
85 |
.................... // lcd_clr smaze displej
|
|
|
86 |
.................... //
|
|
|
87 |
.................... // lcd_define_char(Index, Def) Makro, ktere definuje znaky od pozice Index obsahem definicniho
|
|
|
88 |
.................... // retezce Def. Kazdych 8 znaku retezce Def definuje dalsi znak v CGRAM.
|
|
|
89 |
.................... // Kapacita CGRAM je celkem 8 znaku s indexem 0 az 7.
|
|
|
90 |
.................... // Na konci se provede lcd_gotoxy(1,1).
|
|
|
91 |
.................... // Na konci teto knihovny je priklad pouziti definovanych znaku
|
|
|
92 |
.................... //
|
|
|
93 |
.................... //
|
|
|
94 |
.................... // Definice portu: // Datovy port displeje pripojeny na 4 bity za sebou na jeden port
|
|
|
95 |
.................... //
|
|
|
96 |
.................... // #define LCD_RS PIN_B2 // rizeni registru LCD displeje
|
|
|
97 |
.................... // #define LCD_E PIN_B1 // enable LCD displeje
|
|
|
98 |
.................... // #define LCD_DATA_LSB PIN_C2 // pripojeni LSB bitu datoveho portu LCD displeje (celkem 4 bity vzestupne za sebou)
|
|
|
99 |
.................... //
|
|
|
100 |
.................... //
|
|
|
101 |
.................... // Alternativni definice: // Datovy port displeje pripojeny na libovolne 4 bitove porty (vede na kod delsi asi o 25 slov)
|
|
|
102 |
.................... //
|
|
|
103 |
.................... // #define LCD_RS PIN_B2 // rizeni registru LCD displeje
|
|
|
104 |
.................... // #define LCD_E PIN_B1 // enable LCD displeje
|
|
|
105 |
.................... // #define LCD_D0 PIN_C2 // D0 - datove bity pripojene na libovolne porty
|
|
|
106 |
.................... // #define LCD_D1 PIN_C3 // D1
|
|
|
107 |
.................... // #define LCD_D2 PIN_C4 // D2
|
|
|
108 |
.................... // #define LCD_D3 PIN_C5 // D3
|
6 |
kaklik |
109 |
....................
|
328 |
kaklik |
110 |
....................
|
|
|
111 |
....................
|
|
|
112 |
....................
|
|
|
113 |
.................... // Privatni sekce, cist jen v pripade, ze neco nefunguje
|
|
|
114 |
....................
|
|
|
115 |
....................
|
|
|
116 |
....................
|
|
|
117 |
....................
|
|
|
118 |
.................... #ifdef LCD_DATA_LSB
|
|
|
119 |
.................... // Generovane defince portu pro ucely teto knihovny aby kod generoval spravne IO operace a soucasne
|
|
|
120 |
.................... // bylo mozne jednoduse deklarovat pripojene piny LCD displeje pri pouziti teto knihovny. Problem spociva
|
|
|
121 |
.................... // v tom, ze se musi spravne ridit smery portu a soucasne datovy port zabira jen 4 bity ze zadaneho portu
|
|
|
122 |
.................... //
|
|
|
123 |
.................... #define LCD_SHIFT (LCD_DATA_LSB&7) // pocet bitu posuvu datoveho kanalu v datovem portu
|
|
|
124 |
.................... #define LCD_PORT (LCD_DATA_LSB>>3) // adresa LCD datoveho portu
|
|
|
125 |
.................... #define LCD_TRIS (LCD_PORT+0x80) // adresa prislusneho TRIS registru
|
|
|
126 |
.................... #define LCD_MASK (0xF<<LCD_SHIFT) // maska platnych bitu
|
|
|
127 |
.................... //
|
|
|
128 |
.................... #if LCD_SHIFT>4 // kontrola mezi
|
|
|
129 |
.................... #error LCD data port LSB bit not in range 0..4
|
|
|
130 |
.................... #endif
|
|
|
131 |
.................... #endif
|
|
|
132 |
....................
|
|
|
133 |
....................
|
|
|
134 |
.................... // Definice konstant pro LCD display
|
|
|
135 |
.................... //
|
|
|
136 |
.................... #define LCD_CURSOR_ON_ 0x0E // kurzor jako blikajici radka pod znakem
|
|
|
137 |
.................... #define LCD_CURSOR_OFF_ 0x0C // zadny kurzor
|
|
|
138 |
.................... #define LCD_LINE_2 0x40 // adresa 1. znaku 2. radky
|
|
|
139 |
....................
|
|
|
140 |
....................
|
|
|
141 |
.................... // Definice rezimu LCD displeje
|
|
|
142 |
.................... //
|
|
|
143 |
.................... BYTE const LCD_INIT_STRING[4] =
|
|
|
144 |
.................... {
|
|
|
145 |
.................... 0x28, // intrfejs 4 bity, 2 radky, font 5x7
|
|
|
146 |
.................... LCD_CURSOR_OFF_, // display on, kurzor off,
|
|
|
147 |
.................... 0x01, // clear displeje
|
|
|
148 |
.................... 0x06 // inkrement pozice kurzoru (posun kurzoru doprava)
|
|
|
149 |
.................... };
|
|
|
150 |
....................
|
|
|
151 |
....................
|
|
|
152 |
.................... // Odesle nibble do displeje (posle data a klikne signalem e)
|
|
|
153 |
.................... //
|
|
|
154 |
.................... void lcd_send_nibble( BYTE n )
|
|
|
155 |
.................... {
|
|
|
156 |
.................... #ifdef LCD_DATA_LSB
|
|
|
157 |
.................... // data jsou za sebou na 4 bitech jednoho portu
|
|
|
158 |
.................... *LCD_PORT = (*LCD_PORT & ~LCD_MASK) | ((n << LCD_SHIFT) & LCD_MASK); // nastav datove bity portu a ostatni zachovej
|
|
|
159 |
0061: MOVF 07,W
|
|
|
160 |
0062: ANDLW 0F
|
|
|
161 |
0063: MOVWF 3D
|
|
|
162 |
0064: SWAPF 3C,W
|
|
|
163 |
0065: MOVWF 20
|
|
|
164 |
0066: MOVLW F0
|
|
|
165 |
0067: ANDWF 20,F
|
|
|
166 |
0068: MOVF 20,W
|
|
|
167 |
0069: ANDLW F0
|
|
|
168 |
006A: IORWF 3D,W
|
|
|
169 |
006B: MOVWF 07
|
|
|
170 |
.................... #else
|
|
|
171 |
.................... // data jsou na libovolnych 4 bitech libovolnych portu
|
|
|
172 |
.................... output_bit(LCD_D0,bit_test(n,0));
|
|
|
173 |
.................... output_bit(LCD_D1,bit_test(n,1));
|
|
|
174 |
.................... output_bit(LCD_D2,bit_test(n,2));
|
|
|
175 |
.................... output_bit(LCD_D3,bit_test(n,3));
|
|
|
176 |
.................... #endif
|
|
|
177 |
.................... output_bit(LCD_E,1); // vzestupna hrana
|
|
|
178 |
006C: BSF 06.0
|
|
|
179 |
006D: BSF 03.5
|
|
|
180 |
006E: BCF 06.0
|
|
|
181 |
.................... delay_us(1); // pockej alespon 450ns od e nebo alespon 195ns od dat
|
|
|
182 |
006F: NOP
|
|
|
183 |
.................... output_bit(LCD_E,0); // sestupna hrana (minimalni perioda e je 1us)
|
|
|
184 |
0070: BCF 03.5
|
|
|
185 |
0071: BCF 06.0
|
|
|
186 |
0072: BSF 03.5
|
|
|
187 |
0073: BCF 06.0
|
|
|
188 |
.................... }
|
|
|
189 |
0074: BCF 03.5
|
|
|
190 |
0075: RETLW 00
|
|
|
191 |
....................
|
|
|
192 |
....................
|
|
|
193 |
.................... // Odesle bajt do registru LCD
|
|
|
194 |
.................... //
|
|
|
195 |
.................... // Pokud je Adr=0 .. instrukcni registr
|
|
|
196 |
.................... // Pokud je Adr=1 .. datovy registr
|
|
|
197 |
.................... //
|
|
|
198 |
.................... void lcd_send_byte( BOOLEAN Adr, BYTE n )
|
|
|
199 |
.................... {
|
|
|
200 |
.................... output_bit(LCD_RS,Adr); // vyber registr
|
|
|
201 |
0076: MOVF 3A,F
|
|
|
202 |
0077: BTFSS 03.2
|
|
|
203 |
0078: GOTO 07B
|
|
|
204 |
0079: BCF 06.1
|
|
|
205 |
007A: GOTO 07C
|
|
|
206 |
007B: BSF 06.1
|
|
|
207 |
007C: BSF 03.5
|
|
|
208 |
007D: BCF 06.1
|
|
|
209 |
.................... swap(n);
|
|
|
210 |
007E: BCF 03.5
|
|
|
211 |
007F: SWAPF 3B,F
|
|
|
212 |
.................... lcd_send_nibble(n); // posli horni pulku bajtu
|
|
|
213 |
0080: MOVF 3B,W
|
|
|
214 |
0081: MOVWF 3C
|
|
|
215 |
0082: CALL 061
|
|
|
216 |
.................... swap(n);
|
|
|
217 |
0083: SWAPF 3B,F
|
|
|
218 |
.................... lcd_send_nibble(n); // posli spodni pulku bajtu
|
|
|
219 |
0084: MOVF 3B,W
|
|
|
220 |
0085: MOVWF 3C
|
|
|
221 |
0086: CALL 061
|
|
|
222 |
.................... delay_us(40); // minimalni doba na provedeni prikazu
|
|
|
223 |
0087: MOVLW 0D
|
|
|
224 |
0088: MOVWF 20
|
|
|
225 |
0089: DECFSZ 20,F
|
|
|
226 |
008A: GOTO 089
|
|
|
227 |
.................... }
|
|
|
228 |
008B: RETLW 00
|
|
|
229 |
....................
|
|
|
230 |
....................
|
|
|
231 |
.................... // Provede inicializaci LCD displeje, smaze obsah a nastavi mod displeje
|
|
|
232 |
.................... //
|
|
|
233 |
.................... // Tato procedura se musi volat pred pouzitim ostatnich lcd_ procedur
|
|
|
234 |
.................... //
|
|
|
235 |
.................... void lcd_init()
|
|
|
236 |
.................... {
|
|
|
237 |
....................
|
|
|
238 |
.................... int i; // pocitadlo cyklu
|
|
|
239 |
....................
|
|
|
240 |
.................... delay_ms(20); // spozdeni pro provedeni startu displeje po zapnuti napajeni
|
|
|
241 |
008C: MOVLW 14
|
|
|
242 |
008D: MOVWF 36
|
|
|
243 |
008E: CALL 04C
|
|
|
244 |
....................
|
|
|
245 |
.................... #ifdef LCD_DATA_LSB
|
|
|
246 |
.................... // data jsou na 4 bitech za sebou, nastav smer pro vsechny dalsi prenosy
|
|
|
247 |
.................... *LCD_TRIS = *LCD_TRIS & ~LCD_MASK; // nuluj odpovidajici bity tris registru datoveho portu LCD
|
|
|
248 |
008F: MOVLW 0F
|
|
|
249 |
0090: BSF 03.5
|
|
|
250 |
0091: ANDWF 07,F
|
|
|
251 |
.................... #endif
|
|
|
252 |
....................
|
|
|
253 |
.................... output_bit(LCD_RS,0); // nastav jako vystup a nastav klidovy stav
|
|
|
254 |
0092: BCF 03.5
|
|
|
255 |
0093: BCF 06.1
|
|
|
256 |
0094: BSF 03.5
|
|
|
257 |
0095: BCF 06.1
|
|
|
258 |
.................... output_bit(LCD_E, 0); // nastav jako vystup a nastav klidovy stav
|
|
|
259 |
0096: BCF 03.5
|
|
|
260 |
0097: BCF 06.0
|
|
|
261 |
0098: BSF 03.5
|
|
|
262 |
0099: BCF 06.0
|
|
|
263 |
....................
|
|
|
264 |
.................... for (i=0; i<3; i++) // nastav lcd do rezimu 8 bitu sbernice
|
|
|
265 |
009A: BCF 03.5
|
|
|
266 |
009B: CLRF 2B
|
|
|
267 |
009C: MOVF 2B,W
|
|
|
268 |
009D: SUBLW 02
|
|
|
269 |
009E: BTFSS 03.0
|
|
|
270 |
009F: GOTO 0A8
|
|
|
271 |
.................... {
|
|
|
272 |
.................... delay_ms(2); // muze byt rozdelany prenos dat (2x 4 bity) nebo pomaly povel
|
|
|
273 |
00A0: MOVLW 02
|
|
|
274 |
00A1: MOVWF 36
|
|
|
275 |
00A2: CALL 04C
|
|
|
276 |
.................... lcd_send_nibble(3); // rezim 8 bitu
|
|
|
277 |
00A3: MOVLW 03
|
|
|
278 |
00A4: MOVWF 3C
|
|
|
279 |
00A5: CALL 061
|
|
|
280 |
.................... }
|
|
|
281 |
00A6: INCF 2B,F
|
|
|
282 |
00A7: GOTO 09C
|
|
|
283 |
....................
|
|
|
284 |
.................... delay_us(40); // cas na zpracovani
|
|
|
285 |
00A8: MOVLW 0D
|
|
|
286 |
00A9: MOVWF 20
|
|
|
287 |
00AA: DECFSZ 20,F
|
|
|
288 |
00AB: GOTO 0AA
|
|
|
289 |
.................... lcd_send_nibble(2); // nastav rezim 4 bitu (plati od nasledujiciho prenosu)
|
|
|
290 |
00AC: MOVLW 02
|
|
|
291 |
00AD: MOVWF 3C
|
|
|
292 |
00AE: CALL 061
|
|
|
293 |
.................... delay_us(40); // cas na zpracovani
|
|
|
294 |
00AF: MOVLW 0D
|
|
|
295 |
00B0: MOVWF 20
|
|
|
296 |
00B1: DECFSZ 20,F
|
|
|
297 |
00B2: GOTO 0B1
|
|
|
298 |
....................
|
|
|
299 |
.................... for (i=0;i<3;i++) // proved inicializaci (nastaveni modu, smazani apod)
|
|
|
300 |
00B3: CLRF 2B
|
|
|
301 |
00B4: MOVF 2B,W
|
|
|
302 |
00B5: SUBLW 02
|
|
|
303 |
00B6: BTFSS 03.0
|
|
|
304 |
00B7: GOTO 0C4
|
|
|
305 |
.................... {
|
|
|
306 |
.................... lcd_send_byte(0,LCD_INIT_STRING[i]);
|
|
|
307 |
00B8: MOVF 2B,W
|
|
|
308 |
00B9: CALL 004
|
|
|
309 |
00BA: MOVWF 2C
|
|
|
310 |
00BB: CLRF 3A
|
|
|
311 |
00BC: MOVF 2C,W
|
|
|
312 |
00BD: MOVWF 3B
|
|
|
313 |
00BE: CALL 076
|
|
|
314 |
.................... delay_ms(2);
|
|
|
315 |
00BF: MOVLW 02
|
|
|
316 |
00C0: MOVWF 36
|
|
|
317 |
00C1: CALL 04C
|
|
|
318 |
.................... }
|
|
|
319 |
00C2: INCF 2B,F
|
|
|
320 |
00C3: GOTO 0B4
|
|
|
321 |
.................... }
|
|
|
322 |
00C4: BCF 0A.3
|
|
|
323 |
00C5: GOTO 1BD (RETURN)
|
|
|
324 |
....................
|
|
|
325 |
....................
|
|
|
326 |
.................... // Proved presun kurzoru
|
|
|
327 |
.................... //
|
|
|
328 |
.................... // Pozice 1.1 je domu
|
|
|
329 |
.................... //
|
|
|
330 |
.................... void lcd_gotoxy( BYTE x, BYTE y)
|
|
|
331 |
.................... {
|
|
|
332 |
....................
|
|
|
333 |
.................... BYTE Adr;
|
|
|
334 |
....................
|
|
|
335 |
.................... Adr=x-1;
|
|
|
336 |
00C6: MOVLW 01
|
|
|
337 |
00C7: SUBWF 36,W
|
|
|
338 |
00C8: MOVWF 38
|
|
|
339 |
.................... if(y==2)
|
|
|
340 |
00C9: MOVF 37,W
|
|
|
341 |
00CA: SUBLW 02
|
|
|
342 |
00CB: BTFSS 03.2
|
|
|
343 |
00CC: GOTO 0CF
|
|
|
344 |
.................... Adr+=LCD_LINE_2;
|
|
|
345 |
00CD: MOVLW 40
|
|
|
346 |
00CE: ADDWF 38,F
|
|
|
347 |
....................
|
|
|
348 |
.................... lcd_send_byte(0,0x80|Adr);
|
|
|
349 |
00CF: MOVF 38,W
|
|
|
350 |
00D0: IORLW 80
|
|
|
351 |
00D1: MOVWF 39
|
|
|
352 |
00D2: CLRF 3A
|
|
|
353 |
00D3: MOVF 39,W
|
|
|
354 |
00D4: MOVWF 3B
|
|
|
355 |
00D5: CALL 076
|
|
|
356 |
.................... }
|
|
|
357 |
00D6: RETLW 00
|
|
|
358 |
....................
|
|
|
359 |
....................
|
|
|
360 |
.................... // Zapis znaku na displej, zpracovani ridicich znaku
|
|
|
361 |
.................... //
|
|
|
362 |
.................... void lcd_putc( char c)
|
|
|
363 |
.................... {
|
|
|
364 |
....................
|
|
|
365 |
.................... switch (c)
|
|
|
366 |
.................... {
|
|
|
367 |
00D7: MOVF 35,W
|
|
|
368 |
00D8: XORLW 0C
|
|
|
369 |
00D9: BTFSC 03.2
|
|
|
370 |
00DA: GOTO 0E5
|
|
|
371 |
00DB: XORLW 06
|
|
|
372 |
00DC: BTFSC 03.2
|
|
|
373 |
00DD: GOTO 0ED
|
|
|
374 |
00DE: XORLW 07
|
|
|
375 |
00DF: BTFSC 03.2
|
|
|
376 |
00E0: GOTO 0F3
|
|
|
377 |
00E1: XORLW 05
|
|
|
378 |
00E2: BTFSC 03.2
|
|
|
379 |
00E3: GOTO 0F8
|
|
|
380 |
00E4: GOTO 0FD
|
|
|
381 |
.................... case '\f' : lcd_send_byte(0,1); // smaz displej
|
|
|
382 |
00E5: CLRF 3A
|
|
|
383 |
00E6: MOVLW 01
|
|
|
384 |
00E7: MOVWF 3B
|
|
|
385 |
00E8: CALL 076
|
|
|
386 |
.................... delay_ms(2);
|
|
|
387 |
00E9: MOVLW 02
|
|
|
388 |
00EA: MOVWF 36
|
|
|
389 |
00EB: CALL 04C
|
|
|
390 |
.................... break;
|
|
|
391 |
00EC: GOTO 109
|
|
|
392 |
.................... case '\n' : lcd_gotoxy(1,2); break; // presun se na 1. znak 2. radky
|
|
|
393 |
00ED: MOVLW 01
|
|
|
394 |
00EE: MOVWF 36
|
|
|
395 |
00EF: MOVLW 02
|
|
|
396 |
00F0: MOVWF 37
|
|
|
397 |
00F1: CALL 0C6
|
|
|
398 |
00F2: GOTO 109
|
|
|
399 |
.................... case '\r' : lcd_gotoxy(1,1); break; // presun home
|
|
|
400 |
00F3: MOVLW 01
|
|
|
401 |
00F4: MOVWF 36
|
|
|
402 |
00F5: MOVWF 37
|
|
|
403 |
00F6: CALL 0C6
|
|
|
404 |
00F7: GOTO 109
|
|
|
405 |
.................... case '\b' : lcd_send_byte(0,0x10); break; // posun kurzor o 1 zpet
|
|
|
406 |
00F8: CLRF 3A
|
|
|
407 |
00F9: MOVLW 10
|
|
|
408 |
00FA: MOVWF 3B
|
|
|
409 |
00FB: CALL 076
|
|
|
410 |
00FC: GOTO 109
|
|
|
411 |
.................... default : if (c<0x20) c&=0x7; // preklopeni definovatelnych znaku na rozsah 0 az 0x1F
|
|
|
412 |
00FD: MOVF 35,W
|
|
|
413 |
00FE: SUBLW 1F
|
|
|
414 |
00FF: BTFSS 03.0
|
|
|
415 |
0100: GOTO 103
|
|
|
416 |
0101: MOVLW 07
|
|
|
417 |
0102: ANDWF 35,F
|
|
|
418 |
.................... lcd_send_byte(1,c); break; // zapis znak
|
|
|
419 |
0103: MOVLW 01
|
|
|
420 |
0104: MOVWF 3A
|
|
|
421 |
0105: MOVF 35,W
|
|
|
422 |
0106: MOVWF 3B
|
|
|
423 |
0107: CALL 076
|
|
|
424 |
0108: GOTO 109
|
|
|
425 |
.................... }
|
|
|
426 |
.................... }
|
|
|
427 |
0109: RETLW 00
|
|
|
428 |
....................
|
|
|
429 |
....................
|
|
|
430 |
.................... // Zapni kurzor
|
|
|
431 |
.................... //
|
|
|
432 |
.................... void lcd_cursor_on()
|
|
|
433 |
.................... {
|
|
|
434 |
.................... lcd_send_byte(0,LCD_CURSOR_ON_);
|
|
|
435 |
.................... }
|
|
|
436 |
....................
|
|
|
437 |
....................
|
|
|
438 |
.................... // Vypni kurzor
|
|
|
439 |
.................... //
|
|
|
440 |
.................... void lcd_cursor_off()
|
|
|
441 |
.................... {
|
|
|
442 |
.................... lcd_send_byte(0,LCD_CURSOR_OFF_);
|
|
|
443 |
.................... }
|
|
|
444 |
....................
|
|
|
445 |
....................
|
|
|
446 |
.................... // Smaz displej
|
|
|
447 |
.................... //
|
|
|
448 |
.................... void lcd_clr()
|
|
|
449 |
.................... {
|
|
|
450 |
.................... lcd_putc('\f');
|
|
|
451 |
010A: MOVLW 0C
|
|
|
452 |
010B: MOVWF 35
|
|
|
453 |
010C: CALL 0D7
|
|
|
454 |
.................... }
|
|
|
455 |
010D: RETLW 00
|
|
|
456 |
....................
|
|
|
457 |
....................
|
|
|
458 |
.................... // Definice vlastnich fontu
|
|
|
459 |
.................... //
|
|
|
460 |
.................... // Vlastnich definic muze byt jen 8 do pozic 0 az 7 pameti CGRAM radice lcd displeje
|
|
|
461 |
.................... // Pro snadne definovani jsou pripraveny nasledujici definice a na konci souboru je uveden
|
|
|
462 |
.................... // priklad pouziti definovanych znaku.
|
|
|
463 |
....................
|
|
|
464 |
....................
|
|
|
465 |
.................... // Pomocna procedura pro posilani ridicich dat do radice displeje
|
|
|
466 |
.................... //
|
|
|
467 |
.................... void lcd_putc2(int Data)
|
|
|
468 |
.................... {
|
|
|
469 |
.................... lcd_send_byte(1,Data);
|
|
|
470 |
.................... }
|
|
|
471 |
....................
|
|
|
472 |
....................
|
|
|
473 |
.................... // Pomocne definice pro programovani obsahu CGRAM
|
|
|
474 |
.................... //
|
|
|
475 |
.................... #define lcd_define_start(Code) lcd_send_byte(0,0x40+(Code<<3)); delay_ms(2)
|
|
|
476 |
.................... #define lcd_define_def(String) printf(lcd_putc2,String);
|
|
|
477 |
.................... #define lcd_define_end() lcd_send_byte(0,3); delay_ms(2)
|
|
|
478 |
....................
|
|
|
479 |
....................
|
|
|
480 |
.................... // Vlastni vykonne makro pro definovani fontu do pozice Index CGRAM s definicnim retezcem Def
|
|
|
481 |
.................... //
|
|
|
482 |
.................... #define lcd_define_char(Index, Def) lcd_define_start(Index); lcd_define_def(Def); lcd_define_end();
|
|
|
483 |
....................
|
|
|
484 |
....................
|
|
|
485 |
.................... // Pripravene definice fontu vybranych znaku
|
|
|
486 |
.................... // V tabulce nesmi byt 00 (konec retezce v printf()), misto toho davame 80
|
|
|
487 |
.................... //
|
|
|
488 |
.................... #define LCD_CHAR_BAT100 "\x0E\x1F\x1F\x1F\x1F\x1F\x1F\x1F" /* symbol plne baterie */
|
|
|
489 |
.................... #define LCD_CHAR_BAT50 "\x0E\x1F\x11\x11\x13\x17\x1F\x1F" /* symbol polovicni baterie */
|
|
|
490 |
.................... #define LCD_CHAR_BAT0 "\x0E\x1F\x11\x11\x11\x11\x11\x1F" /* symbol vybite baterie */
|
|
|
491 |
.................... #define LCD_CHAR_UP "\x80\x04\x0E\x15\x04\x04\x04\x80" /* symbol sipka nahoru */
|
|
|
492 |
.................... #define LCD_CHAR_DOWN "\x80\x04\x04\x04\x15\x0E\x04\x80" /* symbol Sipka dolu */
|
|
|
493 |
.................... #define LCD_CHAR_LUA "\x04\x0E\x11\x11\x1F\x11\x11\x80" /* A s carkou */
|
|
|
494 |
.................... #define LCD_CHAR_LLA "\x01\x02\x0E\x01\x1F\x11\x0F\x80" /* a s carkou */
|
|
|
495 |
.................... #define LCD_CHAR_HUC "\x0A\x0E\x11\x10\x10\x11\x0E\x80" /* C s hackem */
|
|
|
496 |
.................... #define LCD_CHAR_HLC "\x0A\x04\x0E\x10\x10\x11\x0E\x80" /* c s hackem */
|
|
|
497 |
.................... #define LCD_CHAR_HUD "\x0A\x1C\x12\x11\x11\x12\x1C\x80" /* D s hackem */
|
|
|
498 |
.................... #define LCD_CHAR_HLD "\x05\x03\x0D\x13\x11\x11\x0F\x80" /* d s hackem */
|
|
|
499 |
.................... #define LCD_CHAR_LUE "\x04\x1F\x10\x10\x1E\x10\x1F\x80" /* E s carkou */
|
|
|
500 |
.................... #define LCD_CHAR_LLE "\x01\x02\x0E\x11\x1F\x10\x0E\x80" /* e s carkou */
|
|
|
501 |
.................... #define LCD_CHAR_HUE "\x0A\x1F\x10\x1E\x10\x10\x1F\x80" /* E s hackem */
|
|
|
502 |
.................... #define LCD_CHAR_HLE "\x0A\x04\x0E\x11\x1F\x10\x0E\x80" /* e s hackem */
|
|
|
503 |
.................... #define LCD_CHAR_LUI "\x04\x0E\x04\x04\x04\x04\x0E\x80" /* I s carkou */
|
|
|
504 |
.................... #define LCD_CHAR_LLI "\x02\x04\x80\x0C\x04\x04\x0E\x80" /* i s carkou */
|
|
|
505 |
.................... #define LCD_CHAR_HUN "\x0A\x15\x11\x19\x15\x13\x11\x80" /* N s hackem */
|
|
|
506 |
.................... #define LCD_CHAR_HLN "\x0A\x04\x16\x19\x11\x11\x11\x80" /* n s hackem */
|
|
|
507 |
.................... #define LCD_CHAR_LUO "\x04\x0E\x11\x11\x11\x11\x0E\x80" /* O s carkou */
|
|
|
508 |
.................... #define LCD_CHAR_LLO "\x02\x04\x0E\x11\x11\x11\x0E\x80" /* o s carkou */
|
|
|
509 |
.................... #define LCD_CHAR_HUR "\x0A\x1E\x11\x1E\x14\x12\x11\x80" /* R s hackem */
|
|
|
510 |
.................... #define LCD_CHAR_HLR "\x0A\x04\x16\x19\x10\x10\x10\x80" /* r s hackem */
|
|
|
511 |
.................... #define LCD_CHAR_HUS "\x0A\x0F\x10\x0E\x01\x01\x1E\x80" /* S s hackem */
|
|
|
512 |
.................... #define LCD_CHAR_HLS "\x0A\x04\x0E\x10\x0E\x01\x1E\x80" /* s s hackem */
|
|
|
513 |
.................... #define LCD_CHAR_HUT "\x0A\x1F\x04\x04\x04\x04\x04\x80" /* T s hackem */
|
|
|
514 |
.................... #define LCD_CHAR_HLT "\x0A\x0C\x1C\x08\x08\x09\x06\x80" /* t s hackem */
|
|
|
515 |
.................... #define LCD_CHAR_LUU "\x02\x15\x11\x11\x11\x11\x0E\x80" /* U s carkou */
|
|
|
516 |
.................... #define LCD_CHAR_LLU "\x02\x04\x11\x11\x11\x13\x0D\x80" /* u s carkou */
|
|
|
517 |
.................... #define LCD_CHAR_CUU "\x06\x17\x11\x11\x11\x11\x0E\x80" /* U s krouzkem */
|
|
|
518 |
.................... #define LCD_CHAR_CLU "\x06\x06\x11\x11\x11\x11\x0E\x80" /* u s krouzkem */
|
|
|
519 |
.................... #define LCD_CHAR_LUY "\x02\x15\x11\x0A\x04\x04\x04\x80" /* Y s carkou */
|
|
|
520 |
.................... #define LCD_CHAR_LLY "\x02\x04\x11\x11\x0F\x01\x0E\x80" /* y s carkou */
|
|
|
521 |
.................... #define LCD_CHAR_HUZ "\x0A\x1F\x01\x02\x04\x08\x1F\x80" /* Z s hackem */
|
|
|
522 |
.................... #define LCD_CHAR_HLZ "\x0A\x04\x1F\x02\x04\x08\x1F\x80" /* z s hackem */
|
|
|
523 |
....................
|
|
|
524 |
....................
|
|
|
525 |
.................... // Priklad pouziti definovanych znaku
|
|
|
526 |
.................... //
|
|
|
527 |
.................... //
|
|
|
528 |
.................... //void lcd_sample()
|
|
|
529 |
.................... //{
|
|
|
530 |
.................... // lcd_define_char(0,LCD_CHAR_BAT50); // Priklad definice znaku baterie do pozice 0
|
|
|
531 |
.................... // lcd_define_char(2,LCD_CHAR_HLE LCD_CHAR_LUI); // Priklad definice znaku e s hackem a I s carkou od pozice 2
|
|
|
532 |
.................... // // vsimnete si, ze neni carka mezi retezci s definici (oba retezce definuji
|
|
|
533 |
.................... // // jediny definicni retezec)
|
|
|
534 |
.................... // printf(lcd_putc,"\fZnaky:\20\22\23"); // priklad vypisu znaku z pozice 0, 2 a 3
|
|
|
535 |
.................... // delay_ms(1000);
|
|
|
536 |
.................... // lcd_define_char(0,LCD_CHAR_BAT0); // Predefinovani tvaru znaku v pozici 0
|
|
|
537 |
.................... // delay_ms(1000);
|
|
|
538 |
.................... //}
|
|
|
539 |
....................
|
|
|
540 |
....................
|
|
|
541 |
....................
|
|
|
542 |
.................... void main()
|
|
|
543 |
.................... {
|
6 |
kaklik |
544 |
*
|
328 |
kaklik |
545 |
0184: CLRF 04
|
|
|
546 |
0185: MOVLW 1F
|
|
|
547 |
0186: ANDWF 03,F
|
|
|
548 |
0187: BSF 03.5
|
|
|
549 |
0188: BSF 1F.0
|
|
|
550 |
0189: BSF 1F.1
|
|
|
551 |
018A: BSF 1F.2
|
|
|
552 |
018B: BCF 1F.3
|
|
|
553 |
.................... signed int16 stred;
|
|
|
554 |
.................... signed int8 hodnota;
|
|
|
555 |
.................... unsigned int8 i, offset;
|
|
|
556 |
....................
|
|
|
557 |
.................... setup_adc_ports(ALL_ANALOG);
|
6 |
kaklik |
558 |
*
|
328 |
kaklik |
559 |
018F: BSF 03.5
|
|
|
560 |
0190: BCF 1F.0
|
|
|
561 |
0191: BCF 1F.1
|
|
|
562 |
0192: BCF 1F.2
|
|
|
563 |
0193: BCF 1F.3
|
|
|
564 |
.................... setup_adc(ADC_CLOCK_DIV_2);
|
|
|
565 |
0194: BCF 03.5
|
|
|
566 |
0195: BCF 1F.6
|
|
|
567 |
0196: BCF 1F.7
|
|
|
568 |
0197: BSF 03.5
|
|
|
569 |
0198: BSF 1F.7
|
|
|
570 |
0199: BCF 03.5
|
|
|
571 |
019A: BSF 1F.0
|
|
|
572 |
.................... setup_spi(FALSE);
|
6 |
kaklik |
573 |
*
|
328 |
kaklik |
574 |
018C: MOVLW FF
|
|
|
575 |
018D: BCF 03.5
|
|
|
576 |
018E: MOVWF 25
|
6 |
kaklik |
577 |
*
|
328 |
kaklik |
578 |
019B: BCF 14.5
|
|
|
579 |
019C: BCF 25.5
|
|
|
580 |
019D: MOVF 25,W
|
|
|
581 |
019E: BSF 03.5
|
|
|
582 |
019F: MOVWF 07
|
|
|
583 |
01A0: BCF 03.5
|
|
|
584 |
01A1: BSF 25.4
|
|
|
585 |
01A2: MOVF 25,W
|
|
|
586 |
01A3: BSF 03.5
|
|
|
587 |
01A4: MOVWF 07
|
|
|
588 |
01A5: BCF 03.5
|
|
|
589 |
01A6: BCF 25.3
|
|
|
590 |
01A7: MOVF 25,W
|
|
|
591 |
01A8: BSF 03.5
|
|
|
592 |
01A9: MOVWF 07
|
|
|
593 |
01AA: MOVLW 00
|
|
|
594 |
01AB: BCF 03.5
|
|
|
595 |
01AC: MOVWF 14
|
|
|
596 |
01AD: BSF 03.5
|
|
|
597 |
01AE: MOVWF 14
|
|
|
598 |
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
|
|
|
599 |
01AF: MOVF 01,W
|
|
|
600 |
01B0: ANDLW C7
|
|
|
601 |
01B1: IORLW 08
|
|
|
602 |
01B2: MOVWF 01
|
|
|
603 |
.................... setup_timer_1(T1_DISABLED);
|
|
|
604 |
01B3: BCF 03.5
|
|
|
605 |
01B4: CLRF 10
|
|
|
606 |
.................... setup_timer_2(T2_DISABLED,0,1);
|
|
|
607 |
01B5: MOVLW 00
|
|
|
608 |
01B6: MOVWF 21
|
|
|
609 |
01B7: MOVWF 12
|
|
|
610 |
01B8: MOVLW 00
|
|
|
611 |
01B9: BSF 03.5
|
|
|
612 |
01BA: MOVWF 12
|
6 |
kaklik |
613 |
....................
|
328 |
kaklik |
614 |
.................... lcd_init();
|
|
|
615 |
01BB: BCF 03.5
|
|
|
616 |
01BC: GOTO 08C
|
|
|
617 |
.................... Delay_ms(100);
|
|
|
618 |
01BD: MOVLW 64
|
|
|
619 |
01BE: MOVWF 36
|
|
|
620 |
01BF: CALL 04C
|
|
|
621 |
.................... set_adc_channel(1);
|
|
|
622 |
01C0: MOVLW 08
|
|
|
623 |
01C1: MOVWF 21
|
|
|
624 |
01C2: MOVF 1F,W
|
|
|
625 |
01C3: ANDLW C7
|
|
|
626 |
01C4: IORWF 21,W
|
|
|
627 |
01C5: MOVWF 1F
|
|
|
628 |
....................
|
|
|
629 |
.................... LCD_gotoxy(1,1);
|
|
|
630 |
01C6: MOVLW 01
|
|
|
631 |
01C7: MOVWF 36
|
|
|
632 |
01C8: MOVWF 37
|
|
|
633 |
01C9: CALL 0C6
|
|
|
634 |
.................... printf(lcd_putc,"Gmetr 0.1.2 Beta");
|
|
|
635 |
01CA: CLRF 2B
|
|
|
636 |
01CB: MOVF 2B,W
|
|
|
637 |
01CC: CALL 00C
|
|
|
638 |
01CD: IORLW 00
|
|
|
639 |
01CE: BTFSC 03.2
|
|
|
640 |
01CF: GOTO 1D4
|
|
|
641 |
01D0: INCF 2B,F
|
|
|
642 |
01D1: MOVWF 35
|
|
|
643 |
01D2: CALL 0D7
|
|
|
644 |
01D3: GOTO 1CB
|
|
|
645 |
.................... LCD_gotoxy(1,2);
|
|
|
646 |
01D4: MOVLW 01
|
|
|
647 |
01D5: MOVWF 36
|
|
|
648 |
01D6: MOVLW 02
|
|
|
649 |
01D7: MOVWF 37
|
|
|
650 |
01D8: CALL 0C6
|
|
|
651 |
.................... printf(lcd_putc,"Kaklik@mlab.cz");
|
|
|
652 |
01D9: CLRF 2B
|
|
|
653 |
01DA: MOVF 2B,W
|
|
|
654 |
01DB: CALL 021
|
|
|
655 |
01DC: IORLW 00
|
|
|
656 |
01DD: BTFSC 03.2
|
|
|
657 |
01DE: GOTO 1E3
|
|
|
658 |
01DF: INCF 2B,F
|
|
|
659 |
01E0: MOVWF 35
|
|
|
660 |
01E1: CALL 0D7
|
|
|
661 |
01E2: GOTO 1DA
|
|
|
662 |
.................... Delay_ms(500);
|
|
|
663 |
01E3: MOVLW 02
|
|
|
664 |
01E4: MOVWF 2B
|
|
|
665 |
01E5: MOVLW FA
|
|
|
666 |
01E6: MOVWF 36
|
|
|
667 |
01E7: CALL 04C
|
|
|
668 |
01E8: DECFSZ 2B,F
|
|
|
669 |
01E9: GOTO 1E5
|
|
|
670 |
....................
|
|
|
671 |
.................... LCD_clr();
|
|
|
672 |
01EA: CALL 10A
|
|
|
673 |
.................... LCD_gotoxy(1,1);
|
|
|
674 |
01EB: MOVLW 01
|
|
|
675 |
01EC: MOVWF 36
|
|
|
676 |
01ED: MOVWF 37
|
|
|
677 |
01EE: CALL 0C6
|
|
|
678 |
.................... printf(lcd_putc,"Clibration...");
|
|
|
679 |
01EF: CLRF 2B
|
|
|
680 |
01F0: MOVF 2B,W
|
|
|
681 |
01F1: CALL 034
|
|
|
682 |
01F2: IORLW 00
|
|
|
683 |
01F3: BTFSC 03.2
|
|
|
684 |
01F4: GOTO 1F9
|
|
|
685 |
01F5: INCF 2B,F
|
|
|
686 |
01F6: MOVWF 35
|
|
|
687 |
01F7: CALL 0D7
|
|
|
688 |
01F8: GOTO 1F0
|
|
|
689 |
....................
|
|
|
690 |
.................... stred = 0;
|
|
|
691 |
01F9: CLRF 27
|
|
|
692 |
01FA: CLRF 26
|
|
|
693 |
.................... for(i=0;i<=127;i++)
|
|
|
694 |
01FB: CLRF 29
|
|
|
695 |
01FC: MOVF 29,W
|
|
|
696 |
01FD: SUBLW 7F
|
|
|
697 |
01FE: BTFSS 03.0
|
|
|
698 |
01FF: GOTO 210
|
|
|
699 |
.................... {
|
|
|
700 |
.................... Delay_ms(10);
|
|
|
701 |
0200: MOVLW 0A
|
|
|
702 |
0201: MOVWF 36
|
|
|
703 |
0202: CALL 04C
|
|
|
704 |
.................... stred = stred + read_adc();
|
|
|
705 |
0203: BSF 1F.2
|
|
|
706 |
0204: BTFSC 1F.2
|
|
|
707 |
0205: GOTO 204
|
|
|
708 |
0206: BSF 03.5
|
|
|
709 |
0207: MOVF 1E,W
|
|
|
710 |
0208: BCF 03.5
|
|
|
711 |
0209: ADDWF 26,F
|
|
|
712 |
020A: BTFSC 03.0
|
|
|
713 |
020B: INCF 27,F
|
|
|
714 |
020C: MOVF 1E,W
|
|
|
715 |
020D: ADDWF 27,F
|
|
|
716 |
.................... }
|
|
|
717 |
020E: INCF 29,F
|
|
|
718 |
020F: GOTO 1FC
|
|
|
719 |
.................... stred = stred >> 7;
|
|
|
720 |
0210: RRF 27,F
|
|
|
721 |
0211: RRF 26,F
|
|
|
722 |
0212: RRF 27,F
|
|
|
723 |
0213: RRF 26,F
|
|
|
724 |
0214: RRF 27,F
|
|
|
725 |
0215: RRF 26,F
|
|
|
726 |
0216: RRF 27,F
|
|
|
727 |
0217: RRF 26,F
|
|
|
728 |
0218: RRF 27,F
|
|
|
729 |
0219: RRF 26,F
|
|
|
730 |
021A: RRF 27,F
|
|
|
731 |
021B: RRF 26,F
|
|
|
732 |
021C: RRF 27,F
|
|
|
733 |
021D: RRF 26,F
|
|
|
734 |
021E: MOVLW 01
|
|
|
735 |
021F: ANDWF 27,F
|
|
|
736 |
....................
|
|
|
737 |
.................... while(true)
|
|
|
738 |
.................... {
|
|
|
739 |
.................... hodnota = read_adc();
|
|
|
740 |
0220: BSF 1F.2
|
|
|
741 |
0221: BTFSC 1F.2
|
|
|
742 |
0222: GOTO 221
|
|
|
743 |
0223: BSF 03.5
|
|
|
744 |
0224: MOVF 1E,W
|
|
|
745 |
0225: BCF 03.5
|
|
|
746 |
0226: MOVWF 28
|
|
|
747 |
.................... Delay_ms(50);
|
|
|
748 |
0227: MOVLW 32
|
|
|
749 |
0228: MOVWF 36
|
|
|
750 |
0229: CALL 04C
|
|
|
751 |
.................... LCD_clr();
|
|
|
752 |
022A: CALL 10A
|
|
|
753 |
.................... LCD_gotoxy(6,1);
|
|
|
754 |
022B: MOVLW 06
|
|
|
755 |
022C: MOVWF 36
|
|
|
756 |
022D: MOVLW 01
|
|
|
757 |
022E: MOVWF 37
|
|
|
758 |
022F: CALL 0C6
|
|
|
759 |
.................... printf(lcd_putc," %03ld ",(stred - hodnota));
|
|
|
760 |
0230: CLRF 23
|
|
|
761 |
0231: MOVF 28,W
|
|
|
762 |
0232: MOVWF 20
|
|
|
763 |
0233: BTFSC 28.7
|
|
|
764 |
0234: DECF 23,F
|
|
|
765 |
0235: SUBWF 26,W
|
|
|
766 |
0236: MOVWF 2B
|
|
|
767 |
0237: MOVF 27,W
|
|
|
768 |
0238: MOVWF 2C
|
|
|
769 |
0239: MOVF 23,W
|
|
|
770 |
023A: BTFSS 03.0
|
|
|
771 |
023B: INCFSZ 23,W
|
|
|
772 |
023C: SUBWF 2C,F
|
|
|
773 |
023D: MOVLW 20
|
|
|
774 |
023E: MOVWF 35
|
|
|
775 |
023F: CALL 0D7
|
|
|
776 |
0240: MOVLW 0B
|
|
|
777 |
0241: MOVWF 04
|
|
|
778 |
0242: MOVF 2C,W
|
|
|
779 |
0243: MOVWF 2E
|
|
|
780 |
0244: MOVF 2B,W
|
|
|
781 |
0245: MOVWF 2D
|
|
|
782 |
0246: GOTO 10E
|
|
|
783 |
0247: MOVLW 20
|
|
|
784 |
0248: MOVWF 35
|
|
|
785 |
0249: CALL 0D7
|
|
|
786 |
.................... if (hodnota >= stred)
|
|
|
787 |
024A: CLRF 23
|
|
|
788 |
024B: MOVF 28,W
|
|
|
789 |
024C: MOVWF 20
|
|
|
790 |
024D: BTFSC 20.7
|
|
|
791 |
024E: DECF 23,F
|
|
|
792 |
024F: MOVWF 21
|
|
|
793 |
0250: BTFSS 27.7
|
|
|
794 |
0251: GOTO 255
|
|
|
795 |
0252: BTFSS 23.7
|
|
|
796 |
0253: GOTO 261
|
|
|
797 |
0254: GOTO 257
|
|
|
798 |
0255: BTFSC 23.7
|
|
|
799 |
0256: GOTO 278
|
|
|
800 |
0257: MOVF 27,W
|
|
|
801 |
0258: SUBWF 23,W
|
|
|
802 |
0259: BTFSS 03.0
|
|
|
803 |
025A: GOTO 278
|
|
|
804 |
025B: BTFSS 03.2
|
|
|
805 |
025C: GOTO 261
|
|
|
806 |
025D: MOVF 26,W
|
|
|
807 |
025E: SUBWF 21,W
|
|
|
808 |
025F: BTFSS 03.0
|
|
|
809 |
0260: GOTO 278
|
|
|
810 |
.................... {
|
|
|
811 |
.................... offset = hodnota - stred;
|
|
|
812 |
0261: CLRF 23
|
|
|
813 |
0262: MOVF 28,W
|
|
|
814 |
0263: BTFSC 28.7
|
|
|
815 |
0264: DECF 23,F
|
|
|
816 |
0265: MOVWF 21
|
|
|
817 |
0266: MOVF 26,W
|
|
|
818 |
0267: SUBWF 21,W
|
|
|
819 |
0268: MOVWF 20
|
|
|
820 |
0269: MOVF 27,W
|
|
|
821 |
026A: BTFSS 03.0
|
|
|
822 |
026B: INCFSZ 27,W
|
|
|
823 |
026C: SUBWF 23,F
|
|
|
824 |
026D: MOVF 20,W
|
|
|
825 |
026E: MOVWF 2A
|
|
|
826 |
.................... offset = (offset >> 5) + 8;
|
|
|
827 |
026F: SWAPF 2A,W
|
|
|
828 |
0270: MOVWF 20
|
|
|
829 |
0271: RRF 20,F
|
|
|
830 |
0272: MOVLW 07
|
|
|
831 |
0273: ANDWF 20,F
|
|
|
832 |
0274: MOVF 20,W
|
|
|
833 |
0275: ADDLW 08
|
|
|
834 |
0276: MOVWF 2A
|
|
|
835 |
.................... }
|
|
|
836 |
.................... else
|
|
|
837 |
0277: GOTO 28C
|
|
|
838 |
.................... {
|
|
|
839 |
.................... offset = stred - hodnota;
|
|
|
840 |
0278: CLRF 23
|
|
|
841 |
0279: MOVF 28,W
|
|
|
842 |
027A: BTFSC 28.7
|
|
|
843 |
027B: DECF 23,F
|
|
|
844 |
027C: SUBWF 26,W
|
|
|
845 |
027D: MOVWF 20
|
|
|
846 |
027E: MOVF 23,W
|
|
|
847 |
027F: BTFSS 03.0
|
|
|
848 |
0280: INCFSZ 23,W
|
|
|
849 |
0281: GOTO 284
|
|
|
850 |
0282: MOVF 27,W
|
|
|
851 |
0283: GOTO 285
|
|
|
852 |
0284: SUBWF 27,W
|
|
|
853 |
0285: MOVWF 23
|
|
|
854 |
0286: MOVF 20,W
|
|
|
855 |
0287: MOVWF 2A
|
|
|
856 |
.................... offset = offset >> 5;
|
|
|
857 |
0288: SWAPF 2A,F
|
|
|
858 |
0289: RRF 2A,F
|
|
|
859 |
028A: MOVLW 07
|
|
|
860 |
028B: ANDWF 2A,F
|
|
|
861 |
.................... }
|
|
|
862 |
.................... LCD_gotoxy(offset,2);
|
|
|
863 |
028C: MOVF 2A,W
|
|
|
864 |
028D: MOVWF 36
|
|
|
865 |
028E: MOVLW 02
|
|
|
866 |
028F: MOVWF 37
|
|
|
867 |
0290: CALL 0C6
|
|
|
868 |
.................... printf(lcd_putc,"*");
|
|
|
869 |
0291: CLRF 2B
|
|
|
870 |
0292: MOVF 2B,W
|
|
|
871 |
0293: CALL 046
|
|
|
872 |
0294: IORLW 00
|
|
|
873 |
0295: BTFSC 03.2
|
|
|
874 |
0296: GOTO 29B
|
|
|
875 |
0297: INCF 2B,F
|
|
|
876 |
0298: MOVWF 35
|
|
|
877 |
0299: CALL 0D7
|
|
|
878 |
029A: GOTO 292
|
|
|
879 |
.................... }
|
|
|
880 |
029B: GOTO 220
|
|
|
881 |
.................... }
|
|
|
882 |
029C: SLEEP
|
6 |
kaklik |
883 |
|
|
|
884 |
Configuration Fuses:
|
|
|
885 |
Word 1: 3F39 XT NOWDT NOPUT NOPROTECT NOBROWNOUT NOLVP NOCPD NOWRT NODEBUG
|