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