0,0 → 1,885 |
CCS PCM C Compiler, Version 3.245, 27853 27-VI-07 00:22 |
|
Filename: D:\KAKLIK\projekty\programy\PIC_C\mereni\gmetr\gmetr.lst |
|
ROM used: 669 words (16%) |
Largest free fragment is 2048 |
RAM used: 13 (7%) at main() level |
31 (16%) worst case |
Stack: 5 locations |
|
* |
0000: MOVLW 00 |
0001: MOVWF 0A |
0002: GOTO 184 |
0003: NOP |
.................... #include ".\gmetr.h" |
.................... #include <16F873.h> |
.................... //////// Standard Header file for the PIC16F873 device //////////////// |
.................... #device PIC16F873 |
.................... #list |
.................... |
.................... #device adc=10 |
.................... #fuses NOWDT,XT, NOPUT, NOPROTECT, NOBROWNOUT, NOLVP, NOCPD, NOWRT, NODEBUG |
.................... #use delay(clock=4000000) |
* |
004C: MOVLW 36 |
004D: MOVWF 04 |
004E: MOVF 00,W |
004F: BTFSC 03.2 |
0050: GOTO 060 |
0051: MOVLW 01 |
0052: MOVWF 21 |
0053: CLRF 20 |
0054: DECFSZ 20,F |
0055: GOTO 054 |
0056: DECFSZ 21,F |
0057: GOTO 053 |
0058: MOVLW 4A |
0059: MOVWF 20 |
005A: DECFSZ 20,F |
005B: GOTO 05A |
005C: NOP |
005D: NOP |
005E: DECFSZ 00,F |
005F: GOTO 051 |
0060: RETLW 00 |
.................... |
.................... |
.................... |
.................... #define LCD_RS PIN_B1 // rizeni registru LCD displeje |
.................... #define LCD_E PIN_B0 // enable LCD displeje |
.................... #define LCD_DATA_LSB PIN_C4 // pripojeni LSB bitu datoveho portu LCD displeje (celkem 4 bity vzestupne za sebou) |
.................... |
.................... #include "C:\library\CCS\lcd.c" |
.................... // LCD modul pro ovladani dvouradkoveho LCD modulu se standardnim Hitachi radicem |
.................... // (c)miho 2002,2005 |
.................... // |
.................... // Historie: |
.................... // |
.................... // 0.00 Uvodni verze se snadnou definici portu LCD displeje |
.................... // 0.01 Oprava portu (zapomenute stare identifikatory) |
.................... // 0.02 Doplnena moznost pripojeni datoveho portu LCD na libovolne porty |
.................... // 0.03 Doplnena procedura lcd_clr pro smazani displeje |
.................... // |
.................... // |
.................... // Funkce: |
.................... // |
.................... // lcd_init() inicializuje LCD displej a porty, nutno volat jako prvni |
.................... // |
.................... // lcd_putc(c) zapis snaku do lcd displeje, zpracovava nasledujici ridici znaky |
.................... // \f = \x0C - nova stranka - smazani displeje |
.................... // \n = \x0A - odradkovani (prechod na druhou radku) |
.................... // \b = \x08 - backspace - posunuti kurzoru o 1 pozici zpet |
.................... // \r = \x0D - goto home to position 1,1 |
.................... // \0 .. \7 - definovatelne znaky v pozicich 0 az 7 v CGRAM |
.................... // \20 .. \27 - alternativne zapsane znaky (oktalove) v pozicich 0 az 7 CGRAM |
.................... // Pozor na to, ze funkce printf konci tisk pokud narazi na \0 (konec retezce) |
.................... // |
.................... // lcd_gotoxy(x,y) presune kurzor na uvedenou adresu |
.................... // nekontroluje parametry |
.................... // |
.................... // lcd_cursor_on zapne kurzor |
.................... // lcd_cursor_off vypne kurzor |
.................... // |
.................... // lcd_clr smaze displej |
.................... // |
.................... // lcd_define_char(Index, Def) Makro, ktere definuje znaky od pozice Index obsahem definicniho |
.................... // retezce Def. Kazdych 8 znaku retezce Def definuje dalsi znak v CGRAM. |
.................... // Kapacita CGRAM je celkem 8 znaku s indexem 0 az 7. |
.................... // Na konci se provede lcd_gotoxy(1,1). |
.................... // Na konci teto knihovny je priklad pouziti definovanych znaku |
.................... // |
.................... // |
.................... // Definice portu: // Datovy port displeje pripojeny na 4 bity za sebou na jeden port |
.................... // |
.................... // #define LCD_RS PIN_B2 // rizeni registru LCD displeje |
.................... // #define LCD_E PIN_B1 // enable LCD displeje |
.................... // #define LCD_DATA_LSB PIN_C2 // pripojeni LSB bitu datoveho portu LCD displeje (celkem 4 bity vzestupne za sebou) |
.................... // |
.................... // |
.................... // Alternativni definice: // Datovy port displeje pripojeny na libovolne 4 bitove porty (vede na kod delsi asi o 25 slov) |
.................... // |
.................... // #define LCD_RS PIN_B2 // rizeni registru LCD displeje |
.................... // #define LCD_E PIN_B1 // enable LCD displeje |
.................... // #define LCD_D0 PIN_C2 // D0 - datove bity pripojene na libovolne porty |
.................... // #define LCD_D1 PIN_C3 // D1 |
.................... // #define LCD_D2 PIN_C4 // D2 |
.................... // #define LCD_D3 PIN_C5 // D3 |
.................... |
.................... |
.................... |
.................... |
.................... // Privatni sekce, cist jen v pripade, ze neco nefunguje |
.................... |
.................... |
.................... |
.................... |
.................... #ifdef LCD_DATA_LSB |
.................... // Generovane defince portu pro ucely teto knihovny aby kod generoval spravne IO operace a soucasne |
.................... // bylo mozne jednoduse deklarovat pripojene piny LCD displeje pri pouziti teto knihovny. Problem spociva |
.................... // v tom, ze se musi spravne ridit smery portu a soucasne datovy port zabira jen 4 bity ze zadaneho portu |
.................... // |
.................... #define LCD_SHIFT (LCD_DATA_LSB&7) // pocet bitu posuvu datoveho kanalu v datovem portu |
.................... #define LCD_PORT (LCD_DATA_LSB>>3) // adresa LCD datoveho portu |
.................... #define LCD_TRIS (LCD_PORT+0x80) // adresa prislusneho TRIS registru |
.................... #define LCD_MASK (0xF<<LCD_SHIFT) // maska platnych bitu |
.................... // |
.................... #if LCD_SHIFT>4 // kontrola mezi |
.................... #error LCD data port LSB bit not in range 0..4 |
.................... #endif |
.................... #endif |
.................... |
.................... |
.................... // Definice konstant pro LCD display |
.................... // |
.................... #define LCD_CURSOR_ON_ 0x0E // kurzor jako blikajici radka pod znakem |
.................... #define LCD_CURSOR_OFF_ 0x0C // zadny kurzor |
.................... #define LCD_LINE_2 0x40 // adresa 1. znaku 2. radky |
.................... |
.................... |
.................... // Definice rezimu LCD displeje |
.................... // |
.................... BYTE const LCD_INIT_STRING[4] = |
.................... { |
.................... 0x28, // intrfejs 4 bity, 2 radky, font 5x7 |
.................... LCD_CURSOR_OFF_, // display on, kurzor off, |
.................... 0x01, // clear displeje |
.................... 0x06 // inkrement pozice kurzoru (posun kurzoru doprava) |
.................... }; |
.................... |
.................... |
.................... // Odesle nibble do displeje (posle data a klikne signalem e) |
.................... // |
.................... void lcd_send_nibble( BYTE n ) |
.................... { |
.................... #ifdef LCD_DATA_LSB |
.................... // data jsou za sebou na 4 bitech jednoho portu |
.................... *LCD_PORT = (*LCD_PORT & ~LCD_MASK) | ((n << LCD_SHIFT) & LCD_MASK); // nastav datove bity portu a ostatni zachovej |
0061: MOVF 07,W |
0062: ANDLW 0F |
0063: MOVWF 3D |
0064: SWAPF 3C,W |
0065: MOVWF 20 |
0066: MOVLW F0 |
0067: ANDWF 20,F |
0068: MOVF 20,W |
0069: ANDLW F0 |
006A: IORWF 3D,W |
006B: MOVWF 07 |
.................... #else |
.................... // data jsou na libovolnych 4 bitech libovolnych portu |
.................... output_bit(LCD_D0,bit_test(n,0)); |
.................... output_bit(LCD_D1,bit_test(n,1)); |
.................... output_bit(LCD_D2,bit_test(n,2)); |
.................... output_bit(LCD_D3,bit_test(n,3)); |
.................... #endif |
.................... output_bit(LCD_E,1); // vzestupna hrana |
006C: BSF 06.0 |
006D: BSF 03.5 |
006E: BCF 06.0 |
.................... delay_us(1); // pockej alespon 450ns od e nebo alespon 195ns od dat |
006F: NOP |
.................... output_bit(LCD_E,0); // sestupna hrana (minimalni perioda e je 1us) |
0070: BCF 03.5 |
0071: BCF 06.0 |
0072: BSF 03.5 |
0073: BCF 06.0 |
.................... } |
0074: BCF 03.5 |
0075: RETLW 00 |
.................... |
.................... |
.................... // Odesle bajt do registru LCD |
.................... // |
.................... // Pokud je Adr=0 .. instrukcni registr |
.................... // Pokud je Adr=1 .. datovy registr |
.................... // |
.................... void lcd_send_byte( BOOLEAN Adr, BYTE n ) |
.................... { |
.................... output_bit(LCD_RS,Adr); // vyber registr |
0076: MOVF 3A,F |
0077: BTFSS 03.2 |
0078: GOTO 07B |
0079: BCF 06.1 |
007A: GOTO 07C |
007B: BSF 06.1 |
007C: BSF 03.5 |
007D: BCF 06.1 |
.................... swap(n); |
007E: BCF 03.5 |
007F: SWAPF 3B,F |
.................... lcd_send_nibble(n); // posli horni pulku bajtu |
0080: MOVF 3B,W |
0081: MOVWF 3C |
0082: CALL 061 |
.................... swap(n); |
0083: SWAPF 3B,F |
.................... lcd_send_nibble(n); // posli spodni pulku bajtu |
0084: MOVF 3B,W |
0085: MOVWF 3C |
0086: CALL 061 |
.................... delay_us(40); // minimalni doba na provedeni prikazu |
0087: MOVLW 0D |
0088: MOVWF 20 |
0089: DECFSZ 20,F |
008A: GOTO 089 |
.................... } |
008B: RETLW 00 |
.................... |
.................... |
.................... // Provede inicializaci LCD displeje, smaze obsah a nastavi mod displeje |
.................... // |
.................... // Tato procedura se musi volat pred pouzitim ostatnich lcd_ procedur |
.................... // |
.................... void lcd_init() |
.................... { |
.................... |
.................... int i; // pocitadlo cyklu |
.................... |
.................... delay_ms(20); // spozdeni pro provedeni startu displeje po zapnuti napajeni |
008C: MOVLW 14 |
008D: MOVWF 36 |
008E: CALL 04C |
.................... |
.................... #ifdef LCD_DATA_LSB |
.................... // data jsou na 4 bitech za sebou, nastav smer pro vsechny dalsi prenosy |
.................... *LCD_TRIS = *LCD_TRIS & ~LCD_MASK; // nuluj odpovidajici bity tris registru datoveho portu LCD |
008F: MOVLW 0F |
0090: BSF 03.5 |
0091: ANDWF 07,F |
.................... #endif |
.................... |
.................... output_bit(LCD_RS,0); // nastav jako vystup a nastav klidovy stav |
0092: BCF 03.5 |
0093: BCF 06.1 |
0094: BSF 03.5 |
0095: BCF 06.1 |
.................... output_bit(LCD_E, 0); // nastav jako vystup a nastav klidovy stav |
0096: BCF 03.5 |
0097: BCF 06.0 |
0098: BSF 03.5 |
0099: BCF 06.0 |
.................... |
.................... for (i=0; i<3; i++) // nastav lcd do rezimu 8 bitu sbernice |
009A: BCF 03.5 |
009B: CLRF 2B |
009C: MOVF 2B,W |
009D: SUBLW 02 |
009E: BTFSS 03.0 |
009F: GOTO 0A8 |
.................... { |
.................... delay_ms(2); // muze byt rozdelany prenos dat (2x 4 bity) nebo pomaly povel |
00A0: MOVLW 02 |
00A1: MOVWF 36 |
00A2: CALL 04C |
.................... lcd_send_nibble(3); // rezim 8 bitu |
00A3: MOVLW 03 |
00A4: MOVWF 3C |
00A5: CALL 061 |
.................... } |
00A6: INCF 2B,F |
00A7: GOTO 09C |
.................... |
.................... delay_us(40); // cas na zpracovani |
00A8: MOVLW 0D |
00A9: MOVWF 20 |
00AA: DECFSZ 20,F |
00AB: GOTO 0AA |
.................... lcd_send_nibble(2); // nastav rezim 4 bitu (plati od nasledujiciho prenosu) |
00AC: MOVLW 02 |
00AD: MOVWF 3C |
00AE: CALL 061 |
.................... delay_us(40); // cas na zpracovani |
00AF: MOVLW 0D |
00B0: MOVWF 20 |
00B1: DECFSZ 20,F |
00B2: GOTO 0B1 |
.................... |
.................... for (i=0;i<3;i++) // proved inicializaci (nastaveni modu, smazani apod) |
00B3: CLRF 2B |
00B4: MOVF 2B,W |
00B5: SUBLW 02 |
00B6: BTFSS 03.0 |
00B7: GOTO 0C4 |
.................... { |
.................... lcd_send_byte(0,LCD_INIT_STRING[i]); |
00B8: MOVF 2B,W |
00B9: CALL 004 |
00BA: MOVWF 2C |
00BB: CLRF 3A |
00BC: MOVF 2C,W |
00BD: MOVWF 3B |
00BE: CALL 076 |
.................... delay_ms(2); |
00BF: MOVLW 02 |
00C0: MOVWF 36 |
00C1: CALL 04C |
.................... } |
00C2: INCF 2B,F |
00C3: GOTO 0B4 |
.................... } |
00C4: BCF 0A.3 |
00C5: GOTO 1BD (RETURN) |
.................... |
.................... |
.................... // Proved presun kurzoru |
.................... // |
.................... // Pozice 1.1 je domu |
.................... // |
.................... void lcd_gotoxy( BYTE x, BYTE y) |
.................... { |
.................... |
.................... BYTE Adr; |
.................... |
.................... Adr=x-1; |
00C6: MOVLW 01 |
00C7: SUBWF 36,W |
00C8: MOVWF 38 |
.................... if(y==2) |
00C9: MOVF 37,W |
00CA: SUBLW 02 |
00CB: BTFSS 03.2 |
00CC: GOTO 0CF |
.................... Adr+=LCD_LINE_2; |
00CD: MOVLW 40 |
00CE: ADDWF 38,F |
.................... |
.................... lcd_send_byte(0,0x80|Adr); |
00CF: MOVF 38,W |
00D0: IORLW 80 |
00D1: MOVWF 39 |
00D2: CLRF 3A |
00D3: MOVF 39,W |
00D4: MOVWF 3B |
00D5: CALL 076 |
.................... } |
00D6: RETLW 00 |
.................... |
.................... |
.................... // Zapis znaku na displej, zpracovani ridicich znaku |
.................... // |
.................... void lcd_putc( char c) |
.................... { |
.................... |
.................... switch (c) |
.................... { |
00D7: MOVF 35,W |
00D8: XORLW 0C |
00D9: BTFSC 03.2 |
00DA: GOTO 0E5 |
00DB: XORLW 06 |
00DC: BTFSC 03.2 |
00DD: GOTO 0ED |
00DE: XORLW 07 |
00DF: BTFSC 03.2 |
00E0: GOTO 0F3 |
00E1: XORLW 05 |
00E2: BTFSC 03.2 |
00E3: GOTO 0F8 |
00E4: GOTO 0FD |
.................... case '\f' : lcd_send_byte(0,1); // smaz displej |
00E5: CLRF 3A |
00E6: MOVLW 01 |
00E7: MOVWF 3B |
00E8: CALL 076 |
.................... delay_ms(2); |
00E9: MOVLW 02 |
00EA: MOVWF 36 |
00EB: CALL 04C |
.................... break; |
00EC: GOTO 109 |
.................... case '\n' : lcd_gotoxy(1,2); break; // presun se na 1. znak 2. radky |
00ED: MOVLW 01 |
00EE: MOVWF 36 |
00EF: MOVLW 02 |
00F0: MOVWF 37 |
00F1: CALL 0C6 |
00F2: GOTO 109 |
.................... case '\r' : lcd_gotoxy(1,1); break; // presun home |
00F3: MOVLW 01 |
00F4: MOVWF 36 |
00F5: MOVWF 37 |
00F6: CALL 0C6 |
00F7: GOTO 109 |
.................... case '\b' : lcd_send_byte(0,0x10); break; // posun kurzor o 1 zpet |
00F8: CLRF 3A |
00F9: MOVLW 10 |
00FA: MOVWF 3B |
00FB: CALL 076 |
00FC: GOTO 109 |
.................... default : if (c<0x20) c&=0x7; // preklopeni definovatelnych znaku na rozsah 0 az 0x1F |
00FD: MOVF 35,W |
00FE: SUBLW 1F |
00FF: BTFSS 03.0 |
0100: GOTO 103 |
0101: MOVLW 07 |
0102: ANDWF 35,F |
.................... lcd_send_byte(1,c); break; // zapis znak |
0103: MOVLW 01 |
0104: MOVWF 3A |
0105: MOVF 35,W |
0106: MOVWF 3B |
0107: CALL 076 |
0108: GOTO 109 |
.................... } |
.................... } |
0109: RETLW 00 |
.................... |
.................... |
.................... // Zapni kurzor |
.................... // |
.................... void lcd_cursor_on() |
.................... { |
.................... lcd_send_byte(0,LCD_CURSOR_ON_); |
.................... } |
.................... |
.................... |
.................... // Vypni kurzor |
.................... // |
.................... void lcd_cursor_off() |
.................... { |
.................... lcd_send_byte(0,LCD_CURSOR_OFF_); |
.................... } |
.................... |
.................... |
.................... // Smaz displej |
.................... // |
.................... void lcd_clr() |
.................... { |
.................... lcd_putc('\f'); |
010A: MOVLW 0C |
010B: MOVWF 35 |
010C: CALL 0D7 |
.................... } |
010D: RETLW 00 |
.................... |
.................... |
.................... // Definice vlastnich fontu |
.................... // |
.................... // Vlastnich definic muze byt jen 8 do pozic 0 az 7 pameti CGRAM radice lcd displeje |
.................... // Pro snadne definovani jsou pripraveny nasledujici definice a na konci souboru je uveden |
.................... // priklad pouziti definovanych znaku. |
.................... |
.................... |
.................... // Pomocna procedura pro posilani ridicich dat do radice displeje |
.................... // |
.................... void lcd_putc2(int Data) |
.................... { |
.................... lcd_send_byte(1,Data); |
.................... } |
.................... |
.................... |
.................... // Pomocne definice pro programovani obsahu CGRAM |
.................... // |
.................... #define lcd_define_start(Code) lcd_send_byte(0,0x40+(Code<<3)); delay_ms(2) |
.................... #define lcd_define_def(String) printf(lcd_putc2,String); |
.................... #define lcd_define_end() lcd_send_byte(0,3); delay_ms(2) |
.................... |
.................... |
.................... // Vlastni vykonne makro pro definovani fontu do pozice Index CGRAM s definicnim retezcem Def |
.................... // |
.................... #define lcd_define_char(Index, Def) lcd_define_start(Index); lcd_define_def(Def); lcd_define_end(); |
.................... |
.................... |
.................... // Pripravene definice fontu vybranych znaku |
.................... // V tabulce nesmi byt 00 (konec retezce v printf()), misto toho davame 80 |
.................... // |
.................... #define LCD_CHAR_BAT100 "\x0E\x1F\x1F\x1F\x1F\x1F\x1F\x1F" /* symbol plne baterie */ |
.................... #define LCD_CHAR_BAT50 "\x0E\x1F\x11\x11\x13\x17\x1F\x1F" /* symbol polovicni baterie */ |
.................... #define LCD_CHAR_BAT0 "\x0E\x1F\x11\x11\x11\x11\x11\x1F" /* symbol vybite baterie */ |
.................... #define LCD_CHAR_UP "\x80\x04\x0E\x15\x04\x04\x04\x80" /* symbol sipka nahoru */ |
.................... #define LCD_CHAR_DOWN "\x80\x04\x04\x04\x15\x0E\x04\x80" /* symbol Sipka dolu */ |
.................... #define LCD_CHAR_LUA "\x04\x0E\x11\x11\x1F\x11\x11\x80" /* A s carkou */ |
.................... #define LCD_CHAR_LLA "\x01\x02\x0E\x01\x1F\x11\x0F\x80" /* a s carkou */ |
.................... #define LCD_CHAR_HUC "\x0A\x0E\x11\x10\x10\x11\x0E\x80" /* C s hackem */ |
.................... #define LCD_CHAR_HLC "\x0A\x04\x0E\x10\x10\x11\x0E\x80" /* c s hackem */ |
.................... #define LCD_CHAR_HUD "\x0A\x1C\x12\x11\x11\x12\x1C\x80" /* D s hackem */ |
.................... #define LCD_CHAR_HLD "\x05\x03\x0D\x13\x11\x11\x0F\x80" /* d s hackem */ |
.................... #define LCD_CHAR_LUE "\x04\x1F\x10\x10\x1E\x10\x1F\x80" /* E s carkou */ |
.................... #define LCD_CHAR_LLE "\x01\x02\x0E\x11\x1F\x10\x0E\x80" /* e s carkou */ |
.................... #define LCD_CHAR_HUE "\x0A\x1F\x10\x1E\x10\x10\x1F\x80" /* E s hackem */ |
.................... #define LCD_CHAR_HLE "\x0A\x04\x0E\x11\x1F\x10\x0E\x80" /* e s hackem */ |
.................... #define LCD_CHAR_LUI "\x04\x0E\x04\x04\x04\x04\x0E\x80" /* I s carkou */ |
.................... #define LCD_CHAR_LLI "\x02\x04\x80\x0C\x04\x04\x0E\x80" /* i s carkou */ |
.................... #define LCD_CHAR_HUN "\x0A\x15\x11\x19\x15\x13\x11\x80" /* N s hackem */ |
.................... #define LCD_CHAR_HLN "\x0A\x04\x16\x19\x11\x11\x11\x80" /* n s hackem */ |
.................... #define LCD_CHAR_LUO "\x04\x0E\x11\x11\x11\x11\x0E\x80" /* O s carkou */ |
.................... #define LCD_CHAR_LLO "\x02\x04\x0E\x11\x11\x11\x0E\x80" /* o s carkou */ |
.................... #define LCD_CHAR_HUR "\x0A\x1E\x11\x1E\x14\x12\x11\x80" /* R s hackem */ |
.................... #define LCD_CHAR_HLR "\x0A\x04\x16\x19\x10\x10\x10\x80" /* r s hackem */ |
.................... #define LCD_CHAR_HUS "\x0A\x0F\x10\x0E\x01\x01\x1E\x80" /* S s hackem */ |
.................... #define LCD_CHAR_HLS "\x0A\x04\x0E\x10\x0E\x01\x1E\x80" /* s s hackem */ |
.................... #define LCD_CHAR_HUT "\x0A\x1F\x04\x04\x04\x04\x04\x80" /* T s hackem */ |
.................... #define LCD_CHAR_HLT "\x0A\x0C\x1C\x08\x08\x09\x06\x80" /* t s hackem */ |
.................... #define LCD_CHAR_LUU "\x02\x15\x11\x11\x11\x11\x0E\x80" /* U s carkou */ |
.................... #define LCD_CHAR_LLU "\x02\x04\x11\x11\x11\x13\x0D\x80" /* u s carkou */ |
.................... #define LCD_CHAR_CUU "\x06\x17\x11\x11\x11\x11\x0E\x80" /* U s krouzkem */ |
.................... #define LCD_CHAR_CLU "\x06\x06\x11\x11\x11\x11\x0E\x80" /* u s krouzkem */ |
.................... #define LCD_CHAR_LUY "\x02\x15\x11\x0A\x04\x04\x04\x80" /* Y s carkou */ |
.................... #define LCD_CHAR_LLY "\x02\x04\x11\x11\x0F\x01\x0E\x80" /* y s carkou */ |
.................... #define LCD_CHAR_HUZ "\x0A\x1F\x01\x02\x04\x08\x1F\x80" /* Z s hackem */ |
.................... #define LCD_CHAR_HLZ "\x0A\x04\x1F\x02\x04\x08\x1F\x80" /* z s hackem */ |
.................... |
.................... |
.................... // Priklad pouziti definovanych znaku |
.................... // |
.................... // |
.................... //void lcd_sample() |
.................... //{ |
.................... // lcd_define_char(0,LCD_CHAR_BAT50); // Priklad definice znaku baterie do pozice 0 |
.................... // lcd_define_char(2,LCD_CHAR_HLE LCD_CHAR_LUI); // Priklad definice znaku e s hackem a I s carkou od pozice 2 |
.................... // // vsimnete si, ze neni carka mezi retezci s definici (oba retezce definuji |
.................... // // jediny definicni retezec) |
.................... // printf(lcd_putc,"\fZnaky:\20\22\23"); // priklad vypisu znaku z pozice 0, 2 a 3 |
.................... // delay_ms(1000); |
.................... // lcd_define_char(0,LCD_CHAR_BAT0); // Predefinovani tvaru znaku v pozici 0 |
.................... // delay_ms(1000); |
.................... //} |
.................... |
.................... |
.................... |
.................... void main() |
.................... { |
* |
0184: CLRF 04 |
0185: MOVLW 1F |
0186: ANDWF 03,F |
0187: BSF 03.5 |
0188: BSF 1F.0 |
0189: BSF 1F.1 |
018A: BSF 1F.2 |
018B: BCF 1F.3 |
.................... signed int16 stred; |
.................... signed int8 hodnota; |
.................... unsigned int8 i, offset; |
.................... |
.................... setup_adc_ports(ALL_ANALOG); |
* |
018F: BSF 03.5 |
0190: BCF 1F.0 |
0191: BCF 1F.1 |
0192: BCF 1F.2 |
0193: BCF 1F.3 |
.................... setup_adc(ADC_CLOCK_DIV_2); |
0194: BCF 03.5 |
0195: BCF 1F.6 |
0196: BCF 1F.7 |
0197: BSF 03.5 |
0198: BSF 1F.7 |
0199: BCF 03.5 |
019A: BSF 1F.0 |
.................... setup_spi(FALSE); |
* |
018C: MOVLW FF |
018D: BCF 03.5 |
018E: MOVWF 25 |
* |
019B: BCF 14.5 |
019C: BCF 25.5 |
019D: MOVF 25,W |
019E: BSF 03.5 |
019F: MOVWF 07 |
01A0: BCF 03.5 |
01A1: BSF 25.4 |
01A2: MOVF 25,W |
01A3: BSF 03.5 |
01A4: MOVWF 07 |
01A5: BCF 03.5 |
01A6: BCF 25.3 |
01A7: MOVF 25,W |
01A8: BSF 03.5 |
01A9: MOVWF 07 |
01AA: MOVLW 00 |
01AB: BCF 03.5 |
01AC: MOVWF 14 |
01AD: BSF 03.5 |
01AE: MOVWF 14 |
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); |
01AF: MOVF 01,W |
01B0: ANDLW C7 |
01B1: IORLW 08 |
01B2: MOVWF 01 |
.................... setup_timer_1(T1_DISABLED); |
01B3: BCF 03.5 |
01B4: CLRF 10 |
.................... setup_timer_2(T2_DISABLED,0,1); |
01B5: MOVLW 00 |
01B6: MOVWF 21 |
01B7: MOVWF 12 |
01B8: MOVLW 00 |
01B9: BSF 03.5 |
01BA: MOVWF 12 |
.................... |
.................... lcd_init(); |
01BB: BCF 03.5 |
01BC: GOTO 08C |
.................... Delay_ms(100); |
01BD: MOVLW 64 |
01BE: MOVWF 36 |
01BF: CALL 04C |
.................... set_adc_channel(1); |
01C0: MOVLW 08 |
01C1: MOVWF 21 |
01C2: MOVF 1F,W |
01C3: ANDLW C7 |
01C4: IORWF 21,W |
01C5: MOVWF 1F |
.................... |
.................... LCD_gotoxy(1,1); |
01C6: MOVLW 01 |
01C7: MOVWF 36 |
01C8: MOVWF 37 |
01C9: CALL 0C6 |
.................... printf(lcd_putc,"Gmetr 0.1.2 Beta"); |
01CA: CLRF 2B |
01CB: MOVF 2B,W |
01CC: CALL 00C |
01CD: IORLW 00 |
01CE: BTFSC 03.2 |
01CF: GOTO 1D4 |
01D0: INCF 2B,F |
01D1: MOVWF 35 |
01D2: CALL 0D7 |
01D3: GOTO 1CB |
.................... LCD_gotoxy(1,2); |
01D4: MOVLW 01 |
01D5: MOVWF 36 |
01D6: MOVLW 02 |
01D7: MOVWF 37 |
01D8: CALL 0C6 |
.................... printf(lcd_putc,"Kaklik@mlab.cz"); |
01D9: CLRF 2B |
01DA: MOVF 2B,W |
01DB: CALL 021 |
01DC: IORLW 00 |
01DD: BTFSC 03.2 |
01DE: GOTO 1E3 |
01DF: INCF 2B,F |
01E0: MOVWF 35 |
01E1: CALL 0D7 |
01E2: GOTO 1DA |
.................... Delay_ms(500); |
01E3: MOVLW 02 |
01E4: MOVWF 2B |
01E5: MOVLW FA |
01E6: MOVWF 36 |
01E7: CALL 04C |
01E8: DECFSZ 2B,F |
01E9: GOTO 1E5 |
.................... |
.................... LCD_clr(); |
01EA: CALL 10A |
.................... LCD_gotoxy(1,1); |
01EB: MOVLW 01 |
01EC: MOVWF 36 |
01ED: MOVWF 37 |
01EE: CALL 0C6 |
.................... printf(lcd_putc,"Clibration..."); |
01EF: CLRF 2B |
01F0: MOVF 2B,W |
01F1: CALL 034 |
01F2: IORLW 00 |
01F3: BTFSC 03.2 |
01F4: GOTO 1F9 |
01F5: INCF 2B,F |
01F6: MOVWF 35 |
01F7: CALL 0D7 |
01F8: GOTO 1F0 |
.................... |
.................... stred = 0; |
01F9: CLRF 27 |
01FA: CLRF 26 |
.................... for(i=0;i<=127;i++) |
01FB: CLRF 29 |
01FC: MOVF 29,W |
01FD: SUBLW 7F |
01FE: BTFSS 03.0 |
01FF: GOTO 210 |
.................... { |
.................... Delay_ms(10); |
0200: MOVLW 0A |
0201: MOVWF 36 |
0202: CALL 04C |
.................... stred = stred + read_adc(); |
0203: BSF 1F.2 |
0204: BTFSC 1F.2 |
0205: GOTO 204 |
0206: BSF 03.5 |
0207: MOVF 1E,W |
0208: BCF 03.5 |
0209: ADDWF 26,F |
020A: BTFSC 03.0 |
020B: INCF 27,F |
020C: MOVF 1E,W |
020D: ADDWF 27,F |
.................... } |
020E: INCF 29,F |
020F: GOTO 1FC |
.................... stred = stred >> 7; |
0210: RRF 27,F |
0211: RRF 26,F |
0212: RRF 27,F |
0213: RRF 26,F |
0214: RRF 27,F |
0215: RRF 26,F |
0216: RRF 27,F |
0217: RRF 26,F |
0218: RRF 27,F |
0219: RRF 26,F |
021A: RRF 27,F |
021B: RRF 26,F |
021C: RRF 27,F |
021D: RRF 26,F |
021E: MOVLW 01 |
021F: ANDWF 27,F |
.................... |
.................... while(true) |
.................... { |
.................... hodnota = read_adc(); |
0220: BSF 1F.2 |
0221: BTFSC 1F.2 |
0222: GOTO 221 |
0223: BSF 03.5 |
0224: MOVF 1E,W |
0225: BCF 03.5 |
0226: MOVWF 28 |
.................... Delay_ms(50); |
0227: MOVLW 32 |
0228: MOVWF 36 |
0229: CALL 04C |
.................... LCD_clr(); |
022A: CALL 10A |
.................... LCD_gotoxy(6,1); |
022B: MOVLW 06 |
022C: MOVWF 36 |
022D: MOVLW 01 |
022E: MOVWF 37 |
022F: CALL 0C6 |
.................... printf(lcd_putc," %03ld ",(stred - hodnota)); |
0230: CLRF 23 |
0231: MOVF 28,W |
0232: MOVWF 20 |
0233: BTFSC 28.7 |
0234: DECF 23,F |
0235: SUBWF 26,W |
0236: MOVWF 2B |
0237: MOVF 27,W |
0238: MOVWF 2C |
0239: MOVF 23,W |
023A: BTFSS 03.0 |
023B: INCFSZ 23,W |
023C: SUBWF 2C,F |
023D: MOVLW 20 |
023E: MOVWF 35 |
023F: CALL 0D7 |
0240: MOVLW 0B |
0241: MOVWF 04 |
0242: MOVF 2C,W |
0243: MOVWF 2E |
0244: MOVF 2B,W |
0245: MOVWF 2D |
0246: GOTO 10E |
0247: MOVLW 20 |
0248: MOVWF 35 |
0249: CALL 0D7 |
.................... if (hodnota >= stred) |
024A: CLRF 23 |
024B: MOVF 28,W |
024C: MOVWF 20 |
024D: BTFSC 20.7 |
024E: DECF 23,F |
024F: MOVWF 21 |
0250: BTFSS 27.7 |
0251: GOTO 255 |
0252: BTFSS 23.7 |
0253: GOTO 261 |
0254: GOTO 257 |
0255: BTFSC 23.7 |
0256: GOTO 278 |
0257: MOVF 27,W |
0258: SUBWF 23,W |
0259: BTFSS 03.0 |
025A: GOTO 278 |
025B: BTFSS 03.2 |
025C: GOTO 261 |
025D: MOVF 26,W |
025E: SUBWF 21,W |
025F: BTFSS 03.0 |
0260: GOTO 278 |
.................... { |
.................... offset = hodnota - stred; |
0261: CLRF 23 |
0262: MOVF 28,W |
0263: BTFSC 28.7 |
0264: DECF 23,F |
0265: MOVWF 21 |
0266: MOVF 26,W |
0267: SUBWF 21,W |
0268: MOVWF 20 |
0269: MOVF 27,W |
026A: BTFSS 03.0 |
026B: INCFSZ 27,W |
026C: SUBWF 23,F |
026D: MOVF 20,W |
026E: MOVWF 2A |
.................... offset = (offset >> 5) + 8; |
026F: SWAPF 2A,W |
0270: MOVWF 20 |
0271: RRF 20,F |
0272: MOVLW 07 |
0273: ANDWF 20,F |
0274: MOVF 20,W |
0275: ADDLW 08 |
0276: MOVWF 2A |
.................... } |
.................... else |
0277: GOTO 28C |
.................... { |
.................... offset = stred - hodnota; |
0278: CLRF 23 |
0279: MOVF 28,W |
027A: BTFSC 28.7 |
027B: DECF 23,F |
027C: SUBWF 26,W |
027D: MOVWF 20 |
027E: MOVF 23,W |
027F: BTFSS 03.0 |
0280: INCFSZ 23,W |
0281: GOTO 284 |
0282: MOVF 27,W |
0283: GOTO 285 |
0284: SUBWF 27,W |
0285: MOVWF 23 |
0286: MOVF 20,W |
0287: MOVWF 2A |
.................... offset = offset >> 5; |
0288: SWAPF 2A,F |
0289: RRF 2A,F |
028A: MOVLW 07 |
028B: ANDWF 2A,F |
.................... } |
.................... LCD_gotoxy(offset,2); |
028C: MOVF 2A,W |
028D: MOVWF 36 |
028E: MOVLW 02 |
028F: MOVWF 37 |
0290: CALL 0C6 |
.................... printf(lcd_putc,"*"); |
0291: CLRF 2B |
0292: MOVF 2B,W |
0293: CALL 046 |
0294: IORLW 00 |
0295: BTFSC 03.2 |
0296: GOTO 29B |
0297: INCF 2B,F |
0298: MOVWF 35 |
0299: CALL 0D7 |
029A: GOTO 292 |
.................... } |
029B: GOTO 220 |
.................... } |
029C: SLEEP |
|
Configuration Fuses: |
Word 1: 3F39 XT NOWDT NOPUT NOPROTECT NOBROWNOUT NOLVP NOCPD NOWRT NODEBUG |