Subversion Repositories svnkaklik

Compare Revisions

No changes between revisions

Ignore whitespace Rev 567 → Rev 659

/programy/C/PIC/test/C16F876A/blik/blik.PJT
0,0 → 1,38
[PROJECT]
Target=blik.HEX
Development_Mode=
Processor=0x876A
ToolSuite=CCS
 
[Directories]
Include=C:\Program Files\PICC\devices\;C:\Program Files\PICC\dr
Library=
LinkerScript=
 
[Target Data]
FileList=D:\KAKLIK\projekty\programy\C\PIC_C\test\C16F876A\blik\blik.c
BuildTool=C-COMPILER
OptionString=+FM
AdditionalOptionString=
BuildRequired=1
 
[blik.c]
Type=4
Path=
FileList=
BuildTool=
OptionString=
AdditionalOptionString=
 
[mru-list]
1=blik.c
 
[Windows]
0=0000 blik.c 0 0 796 451 3 0
 
[Opened Files]
1=D:\KAKLIK\projekty\programy\C\PIC_C\test\C16F876A\blik\blik.c
2=
[Units]
Count=1
1=D:\KAKLIK\projekty\programy\C\PIC_C\test\C16F876A\blik\blik.c (main)
/programy/C/PIC/test/C16F876A/blik/blik.cof
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programy/C/PIC/test/C16F876A/blik/blik.lst
0,0 → 1,175
CCS PCM C Compiler, Version 3.245, 27853 29-VI-08 23:25
 
Filename: D:\KAKLIK\projekty\programy\C\PIC_C\test\C16F876A\blik\blik.lst
 
ROM used: 114 words (1%)
Largest free fragment is 2048
RAM used: 7 (4%) at main() level
8 (5%) worst case
Stack: 1 locations
 
*
0000: MOVLW 00
0001: MOVWF 0A
0002: GOTO 017
0003: NOP
.................... #include ".\blik.h"
.................... #include <16F876A.h>
.................... //////// Standard Header file for the PIC16F876A device ////////////////
.................... #device PIC16F876A
.................... #list
....................
.................... #device adc=8
....................
.................... #FUSES NOWDT //No Watch Dog Timer
.................... #FUSES HS //High speed Osc (> 4mhz)
.................... #FUSES NOPUT //No Power Up Timer
.................... #FUSES NOPROTECT //Code not protected from reading
.................... #FUSES NODEBUG //No Debug mode for ICD
.................... #FUSES NOBROWNOUT //No brownout reset
.................... #FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
.................... #FUSES NOCPD //No EE protection
.................... #FUSES NOWRT //Program memory not write protected
....................
.................... #use delay(clock=20000000)
0004: MOVLW 22
0005: MOVWF 04
0006: MOVF 00,W
0007: BTFSC 03.2
0008: GOTO 016
0009: MOVLW 06
000A: MOVWF 78
000B: CLRF 77
000C: DECFSZ 77,F
000D: GOTO 00C
000E: DECFSZ 78,F
000F: GOTO 00B
0010: MOVLW 7B
0011: MOVWF 77
0012: DECFSZ 77,F
0013: GOTO 012
0014: DECFSZ 00,F
0015: GOTO 009
0016: RETLW 00
....................
....................
....................
....................
.................... void main()
.................... {
0017: CLRF 04
0018: MOVLW 1F
0019: ANDWF 03,F
001A: BSF 03.5
001B: BSF 1F.0
001C: BSF 1F.1
001D: BSF 1F.2
001E: BCF 1F.3
001F: MOVLW 07
0020: MOVWF 1C
....................
.................... setup_adc_ports(NO_ANALOGS);
*
0024: BSF 03.5
0025: BSF 1F.0
0026: BSF 1F.1
0027: BSF 1F.2
0028: BCF 1F.3
.................... setup_adc(ADC_OFF);
0029: BCF 03.5
002A: BCF 1F.0
.................... setup_spi(FALSE);
*
0021: MOVLW FF
0022: BCF 03.5
0023: MOVWF 20
*
002B: BCF 14.5
002C: BCF 20.5
002D: MOVF 20,W
002E: BSF 03.5
002F: MOVWF 07
0030: BCF 03.5
0031: BSF 20.4
0032: MOVF 20,W
0033: BSF 03.5
0034: MOVWF 07
0035: BCF 03.5
0036: BCF 20.3
0037: MOVF 20,W
0038: BSF 03.5
0039: MOVWF 07
003A: MOVLW 00
003B: BCF 03.5
003C: MOVWF 14
003D: BSF 03.5
003E: MOVWF 14
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
003F: MOVF 01,W
0040: ANDLW C7
0041: IORLW 08
0042: MOVWF 01
.................... setup_timer_1(T1_DISABLED);
0043: BCF 03.5
0044: CLRF 10
.................... setup_timer_2(T2_DISABLED,0,1);
0045: MOVLW 00
0046: MOVWF 78
0047: MOVWF 12
0048: MOVLW 00
0049: BSF 03.5
004A: MOVWF 12
.................... setup_comparator(NC_NC_NC_NC);
004B: MOVLW 07
004C: MOVWF 1C
004D: MOVF 05,W
004E: MOVLW 10
004F: MOVWF 77
0050: DECFSZ 77,F
0051: GOTO 050
0052: NOP
0053: MOVF 1C,W
0054: BCF 03.5
0055: BCF 0D.6
.................... setup_vref(FALSE);
0056: BSF 03.5
0057: CLRF 1D
....................
.................... While(true)
.................... {
.................... Delay_ms(500);
0058: MOVLW 02
0059: BCF 03.5
005A: MOVWF 21
005B: MOVLW FA
005C: MOVWF 22
005D: CALL 004
005E: DECFSZ 21,F
005F: GOTO 05B
.................... Output_high(PIN_B1);
0060: BSF 03.5
0061: BCF 06.1
0062: BCF 03.5
0063: BSF 06.1
.................... Delay_ms(500);
0064: MOVLW 02
0065: MOVWF 21
0066: MOVLW FA
0067: MOVWF 22
0068: CALL 004
0069: DECFSZ 21,F
006A: GOTO 066
.................... Output_low(PIN_B1);
006B: BSF 03.5
006C: BCF 06.1
006D: BCF 03.5
006E: BCF 06.1
.................... }
006F: BSF 03.5
0070: GOTO 058
....................
.................... }
0071: SLEEP
 
Configuration Fuses:
Word 1: 3F3A HS NOWDT NOPUT NODEBUG NOPROTECT NOBROWNOUT NOLVP NOCPD NOWRT
/programy/C/PIC/test/C16F876A/blik/blik.sta
0,0 → 1,31
 
ROM used: 114 (1%)
114 (1%) including unused fragments
 
0 Average locations per line
8 Average locations per statement
 
RAM used: 7 (4%) at main() level
8 (5%) worst case
 
Lines Stmts % Files
----- ----- --- -----
25 14 100 D:\KAKLIK\projekty\programy\C\PIC_C\test\C16F876A\blik\blik.c
16 0 0 D:\KAKLIK\projekty\programy\C\PIC_C\test\C16F876A\blik\blik.h
270 0 0 C:\Program Files\PICC\devices\16F876A.h
----- -----
622 28 Total
 
Page ROM % RAM Functions:
---- --- --- --- ----------
0 19 17 1 @delay_ms1
0 91 80 1 main
 
Segment Used Free
--------- ---- ----
00000-00003 4 0
00004-007FF 110 1934
00800-00FFF 0 2048
01000-017FF 0 2048
01800-01FFF 0 2048
 
/programy/C/PIC/test/C16F876A/blik/blik.sym
0,0 → 1,45
015-016 CCP_1
015 CCP_1_LOW
016 CCP_1_HIGH
01B CCP_2_LOW
01B-01C CCP_2
01C CCP_2_HIGH
020 @TRIS_C
021 main.@SCRATCH
022 @delay_ms1.P1
077 @SCRATCH
078 @SCRATCH
078 _RETURN_
079 @SCRATCH
07A @SCRATCH
07B @SCRATCH
09C.6 C1OUT
09C.7 C2OUT
 
0004 @delay_ms1
0017 main
0017 @cinit
 
Project Files:
D:\KAKLIK\projekty\programy\C\PIC_C\test\C16F876A\blik\blik.c
D:\KAKLIK\projekty\programy\C\PIC_C\test\C16F876A\blik\blik.h
C:\Program Files\PICC\devices\16F876A.h
 
Units:
D:\KAKLIK\projekty\programy\C\PIC_C\test\C16F876A\blik\blik.c (main)
 
Compiler Settings:
Processor: PIC16F876A
Pointer Size: 8
ADC Range: 0-255
Opt Level: 9
Short,Int,Long: 1,8,16
 
Output Files:
Errors: D:\KAKLIK\projekty\programy\C\PIC_C\test\C16F876A\blik\blik.err
INHX8: D:\KAKLIK\projekty\programy\C\PIC_C\test\C16F876A\blik\blik.hex
Symbols: D:\KAKLIK\projekty\programy\C\PIC_C\test\C16F876A\blik\blik.sym
List: D:\KAKLIK\projekty\programy\C\PIC_C\test\C16F876A\blik\blik.lst
Debug/COFF: D:\KAKLIK\projekty\programy\C\PIC_C\test\C16F876A\blik\blik.cof
Call Tree: D:\KAKLIK\projekty\programy\C\PIC_C\test\C16F876A\blik\blik.tre
Statistics: D:\KAKLIK\projekty\programy\C\PIC_C\test\C16F876A\blik\blik.sta
/programy/C/PIC/test/C16F876A/blik/blik.BAK
0,0 → 1,24
#include "D:\KAKLIK\projekty\programy\PIC_C\test\PIC16F876A\blik\blik.h"
 
 
void main()
{
 
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
While(true)
{
Delay_ms(500);
Output_high(PIN_B1);
Delay_ms(500);
Output_low(PIN_B1);
}
 
}
/programy/C/PIC/test/C16F876A/blik/blik.c
0,0 → 1,24
#include ".\blik.h"
 
 
void main()
{
 
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
 
While(true)
{
Delay_ms(500);
Output_high(PIN_B1);
Delay_ms(500);
Output_low(PIN_B1);
}
 
}
/programy/C/PIC/test/C16F876A/blik/blik.err
0,0 → 1,2
No Errors
0 Errors, 0 Warnings.
/programy/C/PIC/test/C16F876A/blik/blik.h
0,0 → 1,15
#include <16F876A.h>
#device adc=8
 
#FUSES NOWDT //No Watch Dog Timer
#FUSES HS //High speed Osc (> 4mhz)
#FUSES NOPUT //No Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#FUSES NOWRT //Program memory not write protected
 
#use delay(clock=20000000)
 
/programy/C/PIC/test/C16F876A/blik/blik.hex
0,0 → 1,18
:1000000000308A00172800002230840000080319FD
:1000100016280630F800F701F70B0C28F80B0B2810
:100020007B30F700F70B1228800B0928003484017D
:100030001F30830583161F149F141F159F1107304F
:100040009C00FF308312A00083161F149F141F15FD
:100050009F1183121F109412A0122008831687008C
:10006000831220162008831687008312A01120080F
:1000700083168700003083129400831694000108D1
:10008000C73908388100831290010030F8009200CF
:1000900000308316920007309C0005081030F700EE
:1000A000F70B502800001C0883120D1383169D01C6
:1000B00002308312A100FA30A2000420A10B5B28B9
:1000C00083168610831286140230A100FA30A20033
:1000D0000420A10B662883168610831286108316CF
:0400E0005828630039
:02400E003A3F37
:00000001FF
;PIC16F876A
/programy/C/PIC/test/C16F876A/blik/blik.tre
0,0 → 1,5
ÀÄblik
ÀÄmain 0/91 Ram=1
ÃÄ??0??
ÃÄ@delay_ms1 0/19 Ram=1
ÀÄ@delay_ms1 0/19 Ram=1
/programy/C/PIC/test/C16F876A/LCD/LCD.C
0,0 → 1,311
// 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
#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
delay_us(1); // pockej alespon 450ns od e nebo alespon 195ns od dat
output_bit(LCD_E,0); // sestupna hrana (minimalni perioda e je 1us)
}
 
 
// 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
swap(n);
lcd_send_nibble(n); // posli horni pulku bajtu
swap(n);
lcd_send_nibble(n); // posli spodni pulku bajtu
delay_us(40); // minimalni doba na provedeni prikazu
}
 
 
// 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
 
#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
#endif
 
output_bit(LCD_RS,0); // nastav jako vystup a nastav klidovy stav
output_bit(LCD_E, 0); // nastav jako vystup a nastav klidovy stav
 
for (i=0; i<3; i++) // nastav lcd do rezimu 8 bitu sbernice
{
delay_ms(2); // muze byt rozdelany prenos dat (2x 4 bity) nebo pomaly povel
lcd_send_nibble(3); // rezim 8 bitu
}
 
delay_us(40); // cas na zpracovani
lcd_send_nibble(2); // nastav rezim 4 bitu (plati od nasledujiciho prenosu)
delay_us(40); // cas na zpracovani
 
for (i=0;i<3;i++) // proved inicializaci (nastaveni modu, smazani apod)
{
lcd_send_byte(0,LCD_INIT_STRING[i]);
delay_ms(2);
}
}
 
 
// Proved presun kurzoru
//
// Pozice 1.1 je domu
//
void lcd_gotoxy( BYTE x, BYTE y)
{
 
BYTE Adr;
 
Adr=x-1;
if(y==2)
Adr+=LCD_LINE_2;
 
lcd_send_byte(0,0x80|Adr);
}
 
 
// Zapis znaku na displej, zpracovani ridicich znaku
//
void lcd_putc( char c)
{
 
switch (c)
{
case '\f' : lcd_send_byte(0,1); // smaz displej
delay_ms(2);
break;
case '\n' : lcd_gotoxy(1,2); break; // presun se na 1. znak 2. radky
case '\r' : lcd_gotoxy(1,1); break; // presun home
case '\b' : lcd_send_byte(0,0x10); break; // posun kurzor o 1 zpet
default : if (c<0x20) c&=0x7; // preklopeni definovatelnych znaku na rozsah 0 az 0x1F
lcd_send_byte(1,c); break; // zapis znak
}
}
 
 
// 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);
//}
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/programy/C/PIC/test/C16F876A/LCD/main.BAK
0,0 → 1,31
#include "main.h"
 
 
#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"
 
void main()
{
 
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
 
lcd_init();
 
while(true);
{
Delay_ms(100);
 
LCD_gotoxy(1,1);
printf(lcd_putc,"Ahoj, Display funguje");
}
 
}
/programy/C/PIC/test/C16F876A/LCD/main.PJT
0,0 → 1,39
 
[PROJECT]
Target=main.HEX
Development_Mode=
Processor=0x877F
ToolSuite=CCS
 
[Directories]
Library=
LinkerScript=
 
[Target Data]
FileList=C:\windows\profiles\kaklik\My Documents\projekty\programy\C\PIC_C\test\C16F876A\LCD\main.c
BuildTool=C-COMPILER
OptionString=+FM
AdditionalOptionString=
BuildRequired=1
 
[main.]
Type=4
Path=
FileList=
BuildTool=
OptionString=
AdditionalOptionString=
 
[mru-list]
1=main.
 
[Windows]
0=0000 main. 0 0 796 451 3 0
 
[Opened Files]
1=C:\windows\profiles\kaklik\My Documents\projekty\programy\C\PIC_C\test\C16F876A\LCD\main.c
2=
 
[Units]
Count=1
1=C:\windows\profiles\kaklik\My Documents\projekty\programy\C\PIC_C\test\C16F876A\LCD\main.c (main)
/programy/C/PIC/test/C16F876A/LCD/main.c
0,0 → 1,34
#include "main.h"
 
 
#define LCD_RS PIN_C7 // rizeni registru LCD displeje <lcd.c>
#define LCD_E PIN_B7 // enable LCD displeje <lcd.c>
#define LCD_D0 PIN_B3 // data LCD <lcd.c>
#define LCD_D1 PIN_B2
#define LCD_D2 PIN_B1
#define LCD_D3 PIN_B0
 
#include "LCD.C"
 
void main()
{
 
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
 
lcd_init();
 
while(true);
{
Delay_ms(100);
 
LCD_gotoxy(1,1);
printf(lcd_putc,"Ahoj, Display funguje");
}
 
}
/programy/C/PIC/test/C16F876A/LCD/main.cof
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programy/C/PIC/test/C16F876A/LCD/main.err
0,0 → 1,2
No Errors
0 Errors, 0 Warnings.
/programy/C/PIC/test/C16F876A/LCD/main.h
0,0 → 1,15
#include <16F877.h>
#device adc=8
 
#FUSES NOWDT //No Watch Dog Timer
#FUSES XT //Crystal osc <= 4mhz
#FUSES NOPUT //No Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#FUSES NOWRT //Program memory not write protected
#FUSES NODEBUG //No Debug mode for ICD
 
#use delay(clock=4000000)
 
/programy/C/PIC/test/C16F876A/LCD/main.hex
0,0 → 1,44
:1000000000308A00FC2800000A108A100A118207BA
:1000100028340C34013406340A108A100A1182077D
:10002000413468346F346A342C34203444346934B5
:10003000733470346C3461347934203466347534FC
:100040006E34673475346A34653400342330840088
:10005000000803193A280130F800F701F70B2E28A1
:10006000F80B2D284A30F700F70B34280000000069
:10007000800B2B28003429183F288611402886152C
:10008000831686118312A9184728061148280615D9
:1000900083160611831229194F28861050288614BA
:1000A000831686108312A91957280610582806149B
:1000B0008316061083128617831686130000831298
:1000C00086138316861383120034A708031D6A283B
:1000D00087136B288717A0132008831687008312C5
:1000E000A80E2808A9003B20A80E2808A9003B203C
:1000F0000D30F700F70B7A2800341430A3002620C7
:100100008713A01320088316870083128613831693
:1001100086138312A1012108023C031C9728023098
:10012000A30026200330A9003B20A10A8B280D3014
:10013000F700F70B99280230A9003B200D30F7009B
:10014000F70BA028A1012108023C031CB3282108B9
:100150000420A200A7012208A80065200230A30005
:100160002620A10AA3288A110A123329013023026A
:10017000A5002408023C031DBF284030A507250820
:100180008038A600A7012608A800652000342208B0
:100190000C3A0319D528063A0319DD28073A031942
:1001A000E328053A0319E828ED28A7010130A80043
:1001B00065200230A3002620F9280130A300023078
:1001C000A400B620F9280130A300A400B620F92825
:1001D000A7011030A8006520F92822081F3C031C45
:1001E000F3280730A2050130A7002208A8006520E7
:1001F000F9288A110A12442984011F3083058316C5
:100200001F149F141F159F11FF308312A000831627
:100210001F149F141F159F1183121F10831609129C
:1002200083129412A01220088316870083122016CE
:100230002008831687008312A011200883168700E8
:10024000003083129400831694000108C7390838DF
:100250008100831290010030F80092000030831674
:10026000920083127D2833296430A30026200130B8
:10027000A300A400B620A10121080C200038031916
:0C0280004529A10AA200C7283C29630000
:02400E00393F38
:00000001FF
;PIC16F877
/programy/C/PIC/test/C16F876A/LCD/main.lst
0,0 → 1,675
CCS PCM C Compiler, Version 3.245, 27853 16-XII-07 14:06
 
Filename: C:\windows\profiles\kaklik\My Documents\projekty\programy\C\PIC_C\test\C16F876A\LCD\main.lst
 
ROM used: 326 words (4%)
Largest free fragment is 2048
RAM used: 7 (4%) at main() level
15 (9%) worst case
Stack: 4 locations
 
*
0000: MOVLW 00
0001: MOVWF 0A
0002: GOTO 0FC
0003: NOP
.................... #include "main.h"
.................... #include <16F877.h>
.................... //////// Standard Header file for the PIC16F877 device ////////////////
.................... #device PIC16F877
.................... #list
....................
.................... #device adc=8
....................
.................... #FUSES NOWDT //No Watch Dog Timer
.................... #FUSES XT //Crystal osc <= 4mhz
.................... #FUSES NOPUT //No Power Up Timer
.................... #FUSES NOPROTECT //Code not protected from reading
.................... #FUSES NOBROWNOUT //No brownout reset
.................... #FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
.................... #FUSES NOCPD //No EE protection
.................... #FUSES NOWRT //Program memory not write protected
.................... #FUSES NODEBUG //No Debug mode for ICD
....................
.................... #use delay(clock=4000000)
0026: MOVLW 23
0027: MOVWF 04
0028: MOVF 00,W
0029: BTFSC 03.2
002A: GOTO 03A
002B: MOVLW 01
002C: MOVWF 78
002D: CLRF 77
002E: DECFSZ 77,F
002F: GOTO 02E
0030: DECFSZ 78,F
0031: GOTO 02D
0032: MOVLW 4A
0033: MOVWF 77
0034: DECFSZ 77,F
0035: GOTO 034
0036: NOP
0037: NOP
0038: DECFSZ 00,F
0039: GOTO 02B
003A: RETLW 00
....................
....................
....................
....................
.................... #define LCD_RS PIN_C7 // rizeni registru LCD displeje <lcd.c>
.................... #define LCD_E PIN_B7 // enable LCD displeje <lcd.c>
.................... #define LCD_D0 PIN_B3 // data LCD <lcd.c>
.................... #define LCD_D1 PIN_B2
.................... #define LCD_D2 PIN_B1
.................... #define LCD_D3 PIN_B0
....................
.................... #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
.................... #else
.................... // data jsou na libovolnych 4 bitech libovolnych portu
.................... output_bit(LCD_D0,bit_test(n,0));
003B: BTFSC 29.0
003C: GOTO 03F
003D: BCF 06.3
003E: GOTO 040
003F: BSF 06.3
0040: BSF 03.5
0041: BCF 06.3
.................... output_bit(LCD_D1,bit_test(n,1));
0042: BCF 03.5
0043: BTFSC 29.1
0044: GOTO 047
0045: BCF 06.2
0046: GOTO 048
0047: BSF 06.2
0048: BSF 03.5
0049: BCF 06.2
.................... output_bit(LCD_D2,bit_test(n,2));
004A: BCF 03.5
004B: BTFSC 29.2
004C: GOTO 04F
004D: BCF 06.1
004E: GOTO 050
004F: BSF 06.1
0050: BSF 03.5
0051: BCF 06.1
.................... output_bit(LCD_D3,bit_test(n,3));
0052: BCF 03.5
0053: BTFSC 29.3
0054: GOTO 057
0055: BCF 06.0
0056: GOTO 058
0057: BSF 06.0
0058: BSF 03.5
0059: BCF 06.0
.................... #endif
.................... output_bit(LCD_E,1); // vzestupna hrana
005A: BCF 03.5
005B: BSF 06.7
005C: BSF 03.5
005D: BCF 06.7
.................... delay_us(1); // pockej alespon 450ns od e nebo alespon 195ns od dat
005E: NOP
.................... output_bit(LCD_E,0); // sestupna hrana (minimalni perioda e je 1us)
005F: BCF 03.5
0060: BCF 06.7
0061: BSF 03.5
0062: BCF 06.7
.................... }
0063: BCF 03.5
0064: 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
0065: MOVF 27,F
0066: BTFSS 03.2
0067: GOTO 06A
0068: BCF 07.7
0069: GOTO 06B
006A: BSF 07.7
006B: BCF 20.7
006C: MOVF 20,W
006D: BSF 03.5
006E: MOVWF 07
*
0104: MOVLW FF
0105: BCF 03.5
0106: MOVWF 20
.................... swap(n);
*
006F: BCF 03.5
0070: SWAPF 28,F
.................... lcd_send_nibble(n); // posli horni pulku bajtu
0071: MOVF 28,W
0072: MOVWF 29
0073: CALL 03B
.................... swap(n);
0074: SWAPF 28,F
.................... lcd_send_nibble(n); // posli spodni pulku bajtu
0075: MOVF 28,W
0076: MOVWF 29
0077: CALL 03B
.................... delay_us(40); // minimalni doba na provedeni prikazu
0078: MOVLW 0D
0079: MOVWF 77
007A: DECFSZ 77,F
007B: GOTO 07A
.................... }
007C: 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
007D: MOVLW 14
007E: MOVWF 23
007F: CALL 026
....................
.................... #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
.................... #endif
....................
.................... output_bit(LCD_RS,0); // nastav jako vystup a nastav klidovy stav
0080: BCF 07.7
0081: BCF 20.7
0082: MOVF 20,W
0083: BSF 03.5
0084: MOVWF 07
.................... output_bit(LCD_E, 0); // nastav jako vystup a nastav klidovy stav
0085: BCF 03.5
0086: BCF 06.7
0087: BSF 03.5
0088: BCF 06.7
....................
.................... for (i=0; i<3; i++) // nastav lcd do rezimu 8 bitu sbernice
0089: BCF 03.5
008A: CLRF 21
008B: MOVF 21,W
008C: SUBLW 02
008D: BTFSS 03.0
008E: GOTO 097
.................... {
.................... delay_ms(2); // muze byt rozdelany prenos dat (2x 4 bity) nebo pomaly povel
008F: MOVLW 02
0090: MOVWF 23
0091: CALL 026
.................... lcd_send_nibble(3); // rezim 8 bitu
0092: MOVLW 03
0093: MOVWF 29
0094: CALL 03B
.................... }
0095: INCF 21,F
0096: GOTO 08B
....................
.................... delay_us(40); // cas na zpracovani
0097: MOVLW 0D
0098: MOVWF 77
0099: DECFSZ 77,F
009A: GOTO 099
.................... lcd_send_nibble(2); // nastav rezim 4 bitu (plati od nasledujiciho prenosu)
009B: MOVLW 02
009C: MOVWF 29
009D: CALL 03B
.................... delay_us(40); // cas na zpracovani
009E: MOVLW 0D
009F: MOVWF 77
00A0: DECFSZ 77,F
00A1: GOTO 0A0
....................
.................... for (i=0;i<3;i++) // proved inicializaci (nastaveni modu, smazani apod)
00A2: CLRF 21
00A3: MOVF 21,W
00A4: SUBLW 02
00A5: BTFSS 03.0
00A6: GOTO 0B3
.................... {
.................... lcd_send_byte(0,LCD_INIT_STRING[i]);
00A7: MOVF 21,W
00A8: CALL 004
00A9: MOVWF 22
00AA: CLRF 27
00AB: MOVF 22,W
00AC: MOVWF 28
00AD: CALL 065
.................... delay_ms(2);
00AE: MOVLW 02
00AF: MOVWF 23
00B0: CALL 026
.................... }
00B1: INCF 21,F
00B2: GOTO 0A3
.................... }
00B3: BCF 0A.3
00B4: BCF 0A.4
00B5: GOTO 133 (RETURN)
....................
....................
.................... // Proved presun kurzoru
.................... //
.................... // Pozice 1.1 je domu
.................... //
.................... void lcd_gotoxy( BYTE x, BYTE y)
.................... {
....................
.................... BYTE Adr;
....................
.................... Adr=x-1;
00B6: MOVLW 01
00B7: SUBWF 23,W
00B8: MOVWF 25
.................... if(y==2)
00B9: MOVF 24,W
00BA: SUBLW 02
00BB: BTFSS 03.2
00BC: GOTO 0BF
.................... Adr+=LCD_LINE_2;
00BD: MOVLW 40
00BE: ADDWF 25,F
....................
.................... lcd_send_byte(0,0x80|Adr);
00BF: MOVF 25,W
00C0: IORLW 80
00C1: MOVWF 26
00C2: CLRF 27
00C3: MOVF 26,W
00C4: MOVWF 28
00C5: CALL 065
.................... }
00C6: RETLW 00
....................
....................
.................... // Zapis znaku na displej, zpracovani ridicich znaku
.................... //
.................... void lcd_putc( char c)
.................... {
....................
.................... switch (c)
.................... {
00C7: MOVF 22,W
00C8: XORLW 0C
00C9: BTFSC 03.2
00CA: GOTO 0D5
00CB: XORLW 06
00CC: BTFSC 03.2
00CD: GOTO 0DD
00CE: XORLW 07
00CF: BTFSC 03.2
00D0: GOTO 0E3
00D1: XORLW 05
00D2: BTFSC 03.2
00D3: GOTO 0E8
00D4: GOTO 0ED
.................... case '\f' : lcd_send_byte(0,1); // smaz displej
00D5: CLRF 27
00D6: MOVLW 01
00D7: MOVWF 28
00D8: CALL 065
.................... delay_ms(2);
00D9: MOVLW 02
00DA: MOVWF 23
00DB: CALL 026
.................... break;
00DC: GOTO 0F9
.................... case '\n' : lcd_gotoxy(1,2); break; // presun se na 1. znak 2. radky
00DD: MOVLW 01
00DE: MOVWF 23
00DF: MOVLW 02
00E0: MOVWF 24
00E1: CALL 0B6
00E2: GOTO 0F9
.................... case '\r' : lcd_gotoxy(1,1); break; // presun home
00E3: MOVLW 01
00E4: MOVWF 23
00E5: MOVWF 24
00E6: CALL 0B6
00E7: GOTO 0F9
.................... case '\b' : lcd_send_byte(0,0x10); break; // posun kurzor o 1 zpet
00E8: CLRF 27
00E9: MOVLW 10
00EA: MOVWF 28
00EB: CALL 065
00EC: GOTO 0F9
.................... default : if (c<0x20) c&=0x7; // preklopeni definovatelnych znaku na rozsah 0 az 0x1F
00ED: MOVF 22,W
00EE: SUBLW 1F
00EF: BTFSS 03.0
00F0: GOTO 0F3
00F1: MOVLW 07
00F2: ANDWF 22,F
.................... lcd_send_byte(1,c); break; // zapis znak
00F3: MOVLW 01
00F4: MOVWF 27
00F5: MOVF 22,W
00F6: MOVWF 28
00F7: CALL 065
00F8: GOTO 0F9
.................... }
.................... }
00F9: BCF 0A.3
00FA: BCF 0A.4
00FB: GOTO 144 (RETURN)
....................
....................
.................... // 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);
.................... //}
....................
....................
.................... void main()
.................... {
00FC: CLRF 04
00FD: MOVLW 1F
00FE: ANDWF 03,F
00FF: BSF 03.5
0100: BSF 1F.0
0101: BSF 1F.1
0102: BSF 1F.2
0103: BCF 1F.3
....................
.................... setup_adc_ports(NO_ANALOGS);
*
0107: BSF 03.5
0108: BSF 1F.0
0109: BSF 1F.1
010A: BSF 1F.2
010B: BCF 1F.3
.................... setup_adc(ADC_OFF);
010C: BCF 03.5
010D: BCF 1F.0
.................... setup_psp(PSP_DISABLED);
010E: BSF 03.5
010F: BCF 09.4
.................... setup_spi(FALSE);
0110: BCF 03.5
0111: BCF 14.5
0112: BCF 20.5
0113: MOVF 20,W
0114: BSF 03.5
0115: MOVWF 07
0116: BCF 03.5
0117: BSF 20.4
0118: MOVF 20,W
0119: BSF 03.5
011A: MOVWF 07
011B: BCF 03.5
011C: BCF 20.3
011D: MOVF 20,W
011E: BSF 03.5
011F: MOVWF 07
0120: MOVLW 00
0121: BCF 03.5
0122: MOVWF 14
0123: BSF 03.5
0124: MOVWF 14
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
0125: MOVF 01,W
0126: ANDLW C7
0127: IORLW 08
0128: MOVWF 01
.................... setup_timer_1(T1_DISABLED);
0129: BCF 03.5
012A: CLRF 10
.................... setup_timer_2(T2_DISABLED,0,1);
012B: MOVLW 00
012C: MOVWF 78
012D: MOVWF 12
012E: MOVLW 00
012F: BSF 03.5
0130: MOVWF 12
....................
.................... lcd_init();
0131: BCF 03.5
0132: GOTO 07D
....................
.................... while(true);
0133: GOTO 133
.................... {
.................... Delay_ms(100);
0134: MOVLW 64
0135: MOVWF 23
0136: CALL 026
....................
.................... LCD_gotoxy(1,1);
0137: MOVLW 01
0138: MOVWF 23
0139: MOVWF 24
013A: CALL 0B6
.................... printf(lcd_putc,"Ahoj, Display funguje");
013B: CLRF 21
013C: MOVF 21,W
013D: CALL 00C
013E: IORLW 00
013F: BTFSC 03.2
0140: GOTO 145
0141: INCF 21,F
0142: MOVWF 22
0143: GOTO 0C7
0144: GOTO 13C
.................... }
....................
.................... }
0145: SLEEP
 
Configuration Fuses:
Word 1: 3F39 XT NOWDT NOPUT NOPROTECT NOBROWNOUT NOLVP NOCPD NOWRT NODEBUG
/programy/C/PIC/test/C16F876A/LCD/main.sta
0,0 → 1,39
 
ROM used: 326 (4%)
326 (4%) including unused fragments
 
1 Average locations per line
5 Average locations per statement
 
RAM used: 7 (4%) at main() level
15 (9%) worst case
 
Lines Stmts % Files
----- ----- --- -----
35 14 22 C:\windows\profiles\kaklik\My Documents\projekty\programy\C\PIC_C\test\C16F876A\LCD\main.c
16 0 0 C:\windows\profiles\kaklik\My Documents\projekty\programy\C\PIC_C\test\C16F876A\LCD\main.h
280 0 0 Z:\home\kaklik\%SystemDrive%\Program Files\PICC\devices\16F877.h
312 49 64 C:\windows\profiles\kaklik\My Documents\projekty\programy\C\PIC_C\test\C16F876A\LCD\LCD.C
----- -----
1286 126 Total
 
Page ROM % RAM Functions:
---- --- --- --- ----------
0 21 6 1 @delay_ms1
0 8 2 0 @const36
0 42 13 1 lcd_send_nibble
0 24 7 2 lcd_send_byte
0 57 17 2 lcd_init
0 17 5 4 lcd_gotoxy
0 53 16 1 lcd_putc
0 74 23 1 main
0 26 8 0 @const10117
 
Segment Used Free
--------- ---- ----
00000-00003 4 0
00004-007FF 322 1722
00800-00FFF 0 2048
01000-017FF 0 2048
01800-01FFF 0 2048
 
/programy/C/PIC/test/C16F876A/LCD/main.sym
0,0 → 1,62
008 PSP_DATA
015-016 CCP_1
015 CCP_1_LOW
016 CCP_1_HIGH
01B CCP_2_LOW
01B-01C CCP_2
01C CCP_2_HIGH
020 @TRIS_C
021 lcd_init.i
021 main.@SCRATCH
022 lcd_putc.c
022 lcd_init.@SCRATCH
023 @delay_ms1.P1
023 lcd_gotoxy.x
024 lcd_gotoxy.y
025 lcd_gotoxy.Adr
026 lcd_gotoxy.@SCRATCH
027 lcd_send_byte.Adr
028 lcd_send_byte.n
029 lcd_send_nibble.n
077 @SCRATCH
078 @SCRATCH
078 _RETURN_
079 @SCRATCH
07A @SCRATCH
07B @SCRATCH
 
0026 @delay_ms1
0004 @const36
003B lcd_send_nibble
0065 lcd_send_byte
007D lcd_init
00B6 lcd_gotoxy
00C7 lcd_putc
00FC main
000C @const10117
00FC @cinit
 
Project Files:
C:\windows\profiles\kaklik\My Documents\projekty\programy\C\PIC_C\test\C16F876A\LCD\main.c
C:\windows\profiles\kaklik\My Documents\projekty\programy\C\PIC_C\test\C16F876A\LCD\main.h
Z:\home\kaklik\%SystemDrive%\Program Files\PICC\devices\16F877.h
C:\windows\profiles\kaklik\My Documents\projekty\programy\C\PIC_C\test\C16F876A\LCD\LCD.C
 
Units:
C:\windows\profiles\kaklik\My Documents\projekty\programy\C\PIC_C\test\C16F876A\LCD\main.c (main)
 
Compiler Settings:
Processor: PIC16F877
Pointer Size: 8
ADC Range: 0-255
Opt Level: 9
Short,Int,Long: 1,8,16
 
Output Files:
Errors: C:\windows\profiles\kaklik\My Documents\projekty\programy\C\PIC_C\test\C16F876A\LCD\main.err
INHX8: C:\windows\profiles\kaklik\My Documents\projekty\programy\C\PIC_C\test\C16F876A\LCD\main.hex
Symbols: C:\windows\profiles\kaklik\My Documents\projekty\programy\C\PIC_C\test\C16F876A\LCD\main.sym
List: C:\windows\profiles\kaklik\My Documents\projekty\programy\C\PIC_C\test\C16F876A\LCD\main.lst
Debug/COFF: C:\windows\profiles\kaklik\My Documents\projekty\programy\C\PIC_C\test\C16F876A\LCD\main.cof
Call Tree: C:\windows\profiles\kaklik\My Documents\projekty\programy\C\PIC_C\test\C16F876A\LCD\main.tre
Statistics: C:\windows\profiles\kaklik\My Documents\projekty\programy\C\PIC_C\test\C16F876A\LCD\main.sta
/programy/C/PIC/test/C16F876A/LCD/main.tre
0,0 → 1,38
ÀÄmain
ÀÄmain 0/74 Ram=1
ÃÄ??0??
ÃÄlcd_init 0/57 Ram=2
³ ÃÄ@delay_ms1 0/21 Ram=1
³ ÃÄ@delay_ms1 0/21 Ram=1
³ ÃÄlcd_send_nibble 0/42 Ram=1
³ ÃÄlcd_send_nibble 0/42 Ram=1
³ ÃÄ@const36 0/8 Ram=0
³ ÃÄlcd_send_byte 0/24 Ram=2
³ ³ ÃÄlcd_send_nibble 0/42 Ram=1
³ ³ ÀÄlcd_send_nibble 0/42 Ram=1
³ ÀÄ@delay_ms1 0/21 Ram=1
ÃÄ@delay_ms1 0/21 Ram=1
ÃÄlcd_gotoxy 0/17 Ram=4
³ ÀÄlcd_send_byte 0/24 Ram=2
³ ÃÄlcd_send_nibble 0/42 Ram=1
³ ÀÄlcd_send_nibble 0/42 Ram=1
ÃÄ@const10117 0/26 Ram=0
ÀÄlcd_putc 0/53 Ram=1
ÃÄlcd_send_byte 0/24 Ram=2
³ ÃÄlcd_send_nibble 0/42 Ram=1
³ ÀÄlcd_send_nibble 0/42 Ram=1
ÃÄ@delay_ms1 0/21 Ram=1
ÃÄlcd_gotoxy 0/17 Ram=4
³ ÀÄlcd_send_byte 0/24 Ram=2
³ ÃÄlcd_send_nibble 0/42 Ram=1
³ ÀÄlcd_send_nibble 0/42 Ram=1
ÃÄlcd_gotoxy 0/17 Ram=4
³ ÀÄlcd_send_byte 0/24 Ram=2
³ ÃÄlcd_send_nibble 0/42 Ram=1
³ ÀÄlcd_send_nibble 0/42 Ram=1
ÃÄlcd_send_byte 0/24 Ram=2
³ ÃÄlcd_send_nibble 0/42 Ram=1
³ ÀÄlcd_send_nibble 0/42 Ram=1
ÀÄlcd_send_byte 0/24 Ram=2
ÃÄlcd_send_nibble 0/42 Ram=1
ÀÄlcd_send_nibble 0/42 Ram=1