/****************************************************************************** PROJECT: LCD che do 4 bit - EasyPIC PROGRAMMER: Pham Thai Hoa (phamthaihoa@gmail.com) MCU: PIC16F877A - 20Mhz COMPLIER: HTPICC 8.05PL2 DES: Hien thi tren LCD 1602 dung che do 4 bit /*****************************************************************************/ #include #include #include #include __CONFIG(UNPROTECT & WDTEN & HS & PWRTEN & BOREN & LVPDIS & DUNPROT & DEBUGDIS); //---------------------------------------------------------------------------// #define LED_ALAM RB3 #define LCD_EN RB2 #define LCD_RW RB1 #define LCD_RS RB0 #define TRIS_LCD TRISB #define LCD_PORT PORTB #define DELAY_STROBE 200 //nebo 500 #define LCD_STROBE() {LCD_EN=1; NOP(); LCD_EN=0;} // vlozi na dane misto toto //---------------------------------------------------------------------------// void delayms(unsigned int ms) //Ham delay ms { unsigned int count; T1CON = 0x00; // Zdroj Fosc/4 bez delicky TMR1ON = 1; // spusteni timeru for (count=0;count>4; CLRWDT(); }while(tmp&0x80); } //---------------------------------------------------------------------------// void LCD_WDATA(const char c) { LCD_RS = 1; LCD_Write(c); } //---------------------------------------------------------------------------// void LCD_WCMD(const char cmd) { LCD_RS = 0; LCD_Write(cmd); } //---------------------------------------------------------------------------// void LCD_Gotoxy(char x, char y) // Pozice, radek { char tg; switch (y){ case 1:tg = x-1; break; case 2:tg = 0x40 + x - 1; break; } LCD_WCMD(tg|0x80); } //---------------------------------------------------------------------------// void LCD_WriteString(const const char* s) { char i, len = strlen(s); for(i=0;i