0,0 → 1,762 |
CCS PCM C Compiler, Version 3.221, 27853 19-VIII-05 18:09 |
|
Filename: D:\KAKLIK\programy\PIC_C\mereni\otmer\16F873\otmer.LST |
|
ROM used: 486 words (12%) |
Largest free fragment is 2048 |
RAM used: 10 (5%) at main() level |
27 (14%) worst case |
Stack: 5 locations |
|
* |
0000: MOVLW 00 |
0001: MOVWF 0A |
0002: GOTO 158 |
0003: NOP |
.................... #include "D:\KAKLIK\programy\PIC_C\mereni\otmer\16F873\otmer.h" |
.................... #include <16F873.h> |
.................... //////// Standard Header file for the PIC16F873 device //////////////// |
.................... #device PIC16F873 |
.................... #list |
.................... |
.................... #device adc=8 |
.................... #fuses NOWDT,XT, NOPUT, NOPROTECT, BROWNOUT, NOLVP, NOCPD, NOWRT, NODEBUG |
.................... #use delay(clock=4000000) |
* |
0024: MOVLW 32 |
0025: MOVWF 04 |
0026: MOVF 00,W |
0027: BTFSC 03.2 |
0028: GOTO 038 |
0029: MOVLW 01 |
002A: MOVWF 21 |
002B: CLRF 20 |
002C: DECFSZ 20,F |
002D: GOTO 02C |
002E: DECFSZ 21,F |
002F: GOTO 02B |
0030: MOVLW 4A |
0031: MOVWF 20 |
0032: DECFSZ 20,F |
0033: GOTO 032 |
0034: NOP |
0035: NOP |
0036: DECFSZ 00,F |
0037: GOTO 029 |
0038: RETLW 00 |
.................... |
.................... |
.................... |
.................... //Definice portu: // Datovy port displeje pripojeny na 4 bity za sebou na jeden port |
.................... |
.................... #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 "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 |
0039: MOVF 07,W |
003A: ANDLW 0F |
003B: MOVWF 39 |
003C: SWAPF 38,W |
003D: MOVWF 20 |
003E: MOVLW F0 |
003F: ANDWF 20,F |
0040: MOVF 20,W |
0041: ANDLW F0 |
0042: IORWF 39,W |
0043: 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 |
0044: BSF 06.0 |
0045: BSF 03.5 |
0046: BCF 06.0 |
.................... delay_us(1); // pockej alespon 450ns od e nebo alespon 195ns od dat |
0047: NOP |
.................... output_bit(LCD_E,0); // sestupna hrana (minimalni perioda e je 1us) |
0048: BCF 03.5 |
0049: BCF 06.0 |
004A: BSF 03.5 |
004B: BCF 06.0 |
.................... } |
004C: BCF 03.5 |
004D: 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 |
004E: MOVF 36,F |
004F: BTFSS 03.2 |
0050: GOTO 053 |
0051: BCF 06.1 |
0052: GOTO 054 |
0053: BSF 06.1 |
0054: BSF 03.5 |
0055: BCF 06.1 |
.................... swap(n); |
0056: BCF 03.5 |
0057: SWAPF 37,F |
.................... lcd_send_nibble(n); // posli horni pulku bajtu |
0058: MOVF 37,W |
0059: MOVWF 38 |
005A: CALL 039 |
.................... swap(n); |
005B: SWAPF 37,F |
.................... lcd_send_nibble(n); // posli spodni pulku bajtu |
005C: MOVF 37,W |
005D: MOVWF 38 |
005E: CALL 039 |
.................... delay_us(40); // minimalni doba na provedeni prikazu |
005F: MOVLW 0D |
0060: MOVWF 20 |
0061: DECFSZ 20,F |
0062: GOTO 061 |
.................... } |
0063: 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 |
0064: MOVLW 14 |
0065: MOVWF 32 |
0066: CALL 024 |
.................... |
.................... #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 |
0067: MOVLW 0F |
0068: BSF 03.5 |
0069: ANDWF 07,F |
.................... #endif |
.................... |
.................... output_bit(LCD_RS,0); // nastav jako vystup a nastav klidovy stav |
006A: BCF 03.5 |
006B: BCF 06.1 |
006C: BSF 03.5 |
006D: BCF 06.1 |
.................... output_bit(LCD_E, 0); // nastav jako vystup a nastav klidovy stav |
006E: BCF 03.5 |
006F: BCF 06.0 |
0070: BSF 03.5 |
0071: BCF 06.0 |
.................... |
.................... for (i=0; i<3; i++) // nastav lcd do rezimu 8 bitu sbernice |
0072: BCF 03.5 |
0073: CLRF 28 |
0074: MOVF 28,W |
0075: SUBLW 02 |
0076: BTFSS 03.0 |
0077: GOTO 080 |
.................... { |
.................... delay_ms(2); // muze byt rozdelany prenos dat (2x 4 bity) nebo pomaly povel |
0078: MOVLW 02 |
0079: MOVWF 32 |
007A: CALL 024 |
.................... lcd_send_nibble(3); // rezim 8 bitu |
007B: MOVLW 03 |
007C: MOVWF 38 |
007D: CALL 039 |
.................... } |
007E: INCF 28,F |
007F: GOTO 074 |
.................... |
.................... delay_us(40); // cas na zpracovani |
0080: MOVLW 0D |
0081: MOVWF 20 |
0082: DECFSZ 20,F |
0083: GOTO 082 |
.................... lcd_send_nibble(2); // nastav rezim 4 bitu (plati od nasledujiciho prenosu) |
0084: MOVLW 02 |
0085: MOVWF 38 |
0086: CALL 039 |
.................... delay_us(40); // cas na zpracovani |
0087: MOVLW 0D |
0088: MOVWF 20 |
0089: DECFSZ 20,F |
008A: GOTO 089 |
.................... |
.................... for (i=0;i<3;i++) // proved inicializaci (nastaveni modu, smazani apod) |
008B: CLRF 28 |
008C: MOVF 28,W |
008D: SUBLW 02 |
008E: BTFSS 03.0 |
008F: GOTO 09C |
.................... { |
.................... lcd_send_byte(0,LCD_INIT_STRING[i]); |
0090: MOVF 28,W |
0091: CALL 004 |
0092: MOVWF 29 |
0093: CLRF 36 |
0094: MOVF 29,W |
0095: MOVWF 37 |
0096: CALL 04E |
.................... delay_ms(2); |
0097: MOVLW 02 |
0098: MOVWF 32 |
0099: CALL 024 |
.................... } |
009A: INCF 28,F |
009B: GOTO 08C |
.................... } |
009C: BCF 0A.3 |
009D: GOTO 19C (RETURN) |
.................... |
.................... |
.................... // Proved presun kurzoru |
.................... // |
.................... // Pozice 1.1 je domu |
.................... // |
.................... void lcd_gotoxy( BYTE x, BYTE y) |
.................... { |
.................... |
.................... BYTE Adr; |
.................... |
.................... Adr=x-1; |
* |
00B4: MOVLW 01 |
00B5: SUBWF 32,W |
00B6: MOVWF 34 |
.................... if(y==2) |
00B7: MOVF 33,W |
00B8: SUBLW 02 |
00B9: BTFSS 03.2 |
00BA: GOTO 0BD |
.................... Adr+=LCD_LINE_2; |
00BB: MOVLW 40 |
00BC: ADDWF 34,F |
.................... |
.................... lcd_send_byte(0,0x80|Adr); |
00BD: MOVF 34,W |
00BE: IORLW 80 |
00BF: MOVWF 35 |
00C0: CLRF 36 |
00C1: MOVF 35,W |
00C2: MOVWF 37 |
00C3: CALL 04E |
.................... } |
00C4: RETLW 00 |
.................... |
.................... |
.................... // Zapis znaku na displej, zpracovani ridicich znaku |
.................... // |
.................... void lcd_putc( char c) |
.................... { |
.................... |
.................... switch (c) |
.................... { |
00C5: MOVF 31,W |
00C6: XORLW 0C |
00C7: BTFSC 03.2 |
00C8: GOTO 0D3 |
00C9: XORLW 06 |
00CA: BTFSC 03.2 |
00CB: GOTO 0DB |
00CC: XORLW 07 |
00CD: BTFSC 03.2 |
00CE: GOTO 0E1 |
00CF: XORLW 05 |
00D0: BTFSC 03.2 |
00D1: GOTO 0E6 |
00D2: GOTO 0EB |
.................... case '\f' : lcd_send_byte(0,1); // smaz displej |
00D3: CLRF 36 |
00D4: MOVLW 01 |
00D5: MOVWF 37 |
00D6: CALL 04E |
.................... delay_ms(2); |
00D7: MOVLW 02 |
00D8: MOVWF 32 |
00D9: CALL 024 |
.................... break; |
00DA: GOTO 0F7 |
.................... case '\n' : lcd_gotoxy(1,2); break; // presun se na 1. znak 2. radky |
00DB: MOVLW 01 |
00DC: MOVWF 32 |
00DD: MOVLW 02 |
00DE: MOVWF 33 |
00DF: CALL 0B4 |
00E0: GOTO 0F7 |
.................... case '\r' : lcd_gotoxy(1,1); break; // presun home |
00E1: MOVLW 01 |
00E2: MOVWF 32 |
00E3: MOVWF 33 |
00E4: CALL 0B4 |
00E5: GOTO 0F7 |
.................... case '\b' : lcd_send_byte(0,0x10); break; // posun kurzor o 1 zpet |
00E6: CLRF 36 |
00E7: MOVLW 10 |
00E8: MOVWF 37 |
00E9: CALL 04E |
00EA: GOTO 0F7 |
.................... default : if (c<0x20) c&=0x7; // preklopeni definovatelnych znaku na rozsah 0 az 0x1F |
00EB: MOVF 31,W |
00EC: SUBLW 1F |
00ED: BTFSS 03.0 |
00EE: GOTO 0F1 |
00EF: MOVLW 07 |
00F0: ANDWF 31,F |
.................... lcd_send_byte(1,c); break; // zapis znak |
00F1: MOVLW 01 |
00F2: MOVWF 36 |
00F3: MOVF 31,W |
00F4: MOVWF 37 |
00F5: CALL 04E |
00F6: GOTO 0F7 |
.................... } |
.................... } |
00F7: 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'); |
.................... } |
.................... |
.................... |
.................... // 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); |
.................... //} |
.................... |
.................... |
.................... #define DATA PIN_A1 |
.................... #define CP PIN_A0 |
.................... #define STROBE PIN_A2 |
.................... |
.................... #include "C:\library\kaklik\ccs\shift_reg.c" |
.................... //////////////////////////////////////////////////////////////////////////////// |
.................... // KNIHOVNA PRO OVLADANI POSUVNEHO REGISTRU |
.................... // |
.................... //////////////////////////////////////////////////////////////////////////////// |
.................... // definice: |
.................... //#define DATA PIN_A1 |
.................... //#define CP PIN_A0 |
.................... //#define STROBE PIN_A2 |
.................... |
.................... void putreg(unsigned int8 out) // zapise do registru 8bitovou promenou. |
.................... { |
.................... int8 i; |
.................... output_low(STROBE); |
.................... |
.................... for(i=0;i<=7;i++) |
.................... { |
.................... output_bit(DATA,bit_test(out,7-i)); |
.................... output_low(CP); |
.................... output_high(CP); |
.................... } |
.................... output_high(STROBE); |
.................... } |
.................... |
.................... void reg_shift_left() |
.................... { |
.................... output_low(CP); |
.................... output_high(CP); |
.................... |
.................... } |
.................... |
.................... void reg_shift_right() |
.................... { |
.................... } |
.................... |
.................... |
.................... void main() |
.................... { |
* |
0158: CLRF 04 |
0159: MOVLW 1F |
015A: ANDWF 03,F |
015B: BSF 03.5 |
015C: BSF 1F.0 |
015D: BSF 1F.1 |
015E: BSF 1F.2 |
015F: BCF 1F.3 |
.................... unsigned int16 otacky; |
.................... |
.................... setup_adc_ports(NO_ANALOGS); |
* |
0163: BSF 03.5 |
0164: BSF 1F.0 |
0165: BSF 1F.1 |
0166: BSF 1F.2 |
0167: BCF 1F.3 |
.................... setup_adc(ADC_OFF); |
0168: BCF 03.5 |
0169: BCF 1F.0 |
.................... setup_spi(FALSE); |
* |
0160: MOVLW FF |
0161: BCF 03.5 |
0162: MOVWF 25 |
* |
016A: BCF 14.5 |
016B: BCF 25.5 |
016C: MOVF 25,W |
016D: BSF 03.5 |
016E: MOVWF 07 |
016F: BCF 03.5 |
0170: BSF 25.4 |
0171: MOVF 25,W |
0172: BSF 03.5 |
0173: MOVWF 07 |
0174: BCF 03.5 |
0175: BCF 25.3 |
0176: MOVF 25,W |
0177: BSF 03.5 |
0178: MOVWF 07 |
0179: MOVLW 00 |
017A: BCF 03.5 |
017B: MOVWF 14 |
017C: BSF 03.5 |
017D: MOVWF 14 |
.................... setup_timer_0(RTCC_EXT_H_TO_L|RTCC_DIV_1); |
017E: MOVF 01,W |
017F: ANDLW C7 |
0180: IORLW 38 |
0181: MOVWF 01 |
.................... setup_timer_1(T1_EXTERNAL|T1_DIV_BY_2); |
0182: MOVLW 97 |
0183: BCF 03.5 |
0184: MOVWF 10 |
.................... setup_timer_2(T2_DISABLED,0,1); |
0185: MOVLW 00 |
0186: MOVWF 21 |
0187: MOVWF 12 |
0188: MOVLW 00 |
0189: BSF 03.5 |
018A: MOVWF 12 |
.................... setup_ccp1(CCP_PWM); |
018B: BCF 03.5 |
018C: BCF 25.2 |
018D: MOVF 25,W |
018E: BSF 03.5 |
018F: MOVWF 07 |
0190: BCF 03.5 |
0191: BCF 07.2 |
0192: MOVLW 0C |
0193: MOVWF 17 |
.................... setup_ccp2(CCP_OFF); |
0194: BSF 25.1 |
0195: MOVF 25,W |
0196: BSF 03.5 |
0197: MOVWF 07 |
0198: BCF 03.5 |
0199: CLRF 1D |
019A: CLRF 1D |
.................... |
.................... lcd_init(); |
019B: GOTO 064 |
.................... |
.................... while (true) |
.................... { |
.................... set_timer1(0); |
019C: CLRF 0F |
019D: CLRF 0E |
.................... |
.................... Delay_ms(500); |
019E: MOVLW 02 |
019F: MOVWF 28 |
01A0: MOVLW FA |
01A1: MOVWF 32 |
01A2: CALL 024 |
01A3: DECFSZ 28,F |
01A4: GOTO 1A0 |
.................... otacky=get_timer1(); |
01A5: MOVF 0F,W |
01A6: MOVWF 23 |
01A7: MOVF 0E,W |
01A8: MOVWF 20 |
01A9: MOVF 0F,W |
01AA: SUBWF 23,W |
01AB: BTFSS 03.2 |
01AC: GOTO 1A5 |
01AD: MOVF 20,W |
01AE: MOVWF 26 |
01AF: MOVF 23,W |
01B0: MOVWF 27 |
.................... otacky=otacky*40; |
01B1: MOVF 27,W |
01B2: MOVWF 29 |
01B3: MOVF 26,W |
01B4: MOVWF 28 |
01B5: CLRF 2B |
01B6: MOVLW 28 |
01B7: MOVWF 2A |
01B8: GOTO 09E |
01B9: MOVF 22,W |
01BA: MOVWF 27 |
01BB: MOVF 21,W |
01BC: MOVWF 26 |
.................... |
.................... switch(otacky) |
.................... { |
01BD: MOVF 26,W |
01BE: MOVWF 20 |
01BF: MOVF 27,W |
01C0: MOVWF 23 |
01C1: GOTO 1C2 |
.................... |
.................... } |
.................... |
.................... LCD_gotoxy(2,2); |
01C2: MOVLW 02 |
01C3: MOVWF 32 |
01C4: MOVWF 33 |
01C5: CALL 0B4 |
.................... printf(lcd_putc,"otacky:%lu ot/min ",otacky); |
01C6: CLRF 28 |
01C7: MOVF 28,W |
01C8: CALL 00C |
01C9: INCF 28,F |
01CA: MOVWF 20 |
01CB: MOVWF 31 |
01CC: CALL 0C5 |
01CD: MOVLW 07 |
01CE: SUBWF 28,W |
01CF: BTFSS 03.2 |
01D0: GOTO 1C7 |
01D1: MOVLW 10 |
01D2: MOVWF 04 |
01D3: MOVF 27,W |
01D4: MOVWF 2A |
01D5: MOVF 26,W |
01D6: MOVWF 29 |
01D7: GOTO 0F8 |
01D8: MOVLW 0A |
01D9: MOVWF 29 |
01DA: MOVF 29,W |
01DB: CALL 00C |
01DC: INCF 29,F |
01DD: MOVWF 20 |
01DE: MOVWF 31 |
01DF: CALL 0C5 |
01E0: MOVLW 13 |
01E1: SUBWF 29,W |
01E2: BTFSS 03.2 |
01E3: GOTO 1DA |
.................... } |
01E4: GOTO 19C |
.................... |
.................... } |
.................... |
01E5: SLEEP |
|
Configuration Fuses: |
Word 1: 3F79 XT NOWDT NOPUT NOPROTECT BROWNOUT NOLVP NOCPD NOWRT NODEBUG |