Em viết chương trình hiển thị ra LCD dùng PIC16F877A chạy trên proteus thì ngon lành, nạp ra chip và chạy thì nó hiển thị tiếng tàu không như vầy nè @@. Các bác các anh các chú giúp dùm e 
LCD em nối D7-4 vào A0-3
RS,R/W,E vào C2-0

Đây là code chương trình (e dùng CCS)
Còn đây là code lcd_lib_4bit
code e sai chỗ nào mong các anh chỉ dùm em ạ.
Cảm ơn các anh nhiều

LCD em nối D7-4 vào A0-3
RS,R/W,E vào C2-0

Đây là code chương trình (e dùng CCS)
Code:
#include <16f877a.h>
#device PIC16F877A*=16 ADC=10
#include <string.h>
#fuses nowdt,hs,noput,noprotect,nodebug,nobrownout,nolvp,nocpd,nowrt
#use delay(clock=11059200)
#include <lcd_lib_4bit.c>
#use fast_io(b)
#use fast_io(d)
#byte portb=0x06
#byte portc=0x07
#byte portd=0x08
#bit b1=portb.0
#bit b2=portb.1
#bit b3=portb.2
#bit b4=portb.3
/*#bit b5=portb.4
#bit b6=portb.5
#bit b7=portb.6
#bit b8=portb.7*/
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
char buffer[90],sdt[15];
int8 count,i,sms,d,n,dau,cuoi,ph,ring;
#INT_RDA
void ngat()
{
buffer[count]=getc();
count++;
}
void xoa_ndung_va_buffer();
void kt_buffer();
void dong_bo();
void tim_sdt();
void phan_hoi();
void xuly();
void main()
{
set_tris_b(0b11110000);
set_tris_d(0b00000000);
portb=0;
portd=0;
enable_interrupts(global);
enable_interrupts(int_rda);
LCD_init();
delay_ms(1000);
LCD_putcmd(0x01);
LCD_putcmd(0x80);Printf(LCD_putchar,"Tieu luan Tot Nghiep");
delay_ms(1000);
LCD_putcmd(0xC0);Printf(LCD_putchar,"DKTB - GSM");
delay_ms(1000);
LCD_putcmd(0x01);
LCD_putcmd(0x80);Printf(LCD_putchar,"GVHD:");
delay_ms(1000);
LCD_putcmd(0xC0);Printf(LCD_putchar,"Nguyen Minh Tung");
delay_ms(1000);
LCD_putcmd(0x01);
LCD_putcmd(0x80);Printf(LCD_putchar,"SVTH:");
delay_ms(1000);
LCD_putcmd(0xC0);Printf(LCD_putchar,"Tran Xuan Giang");
delay_ms(1000);
LCD_putcmd(0x01);
LCD_putcmd(0x80);Printf(LCD_putchar,"Lop: DV1K4");
delay_ms(1000);
LCD_putcmd(0xC0);Printf(LCD_putchar,"MSSV: 1051020052");
delay_ms(1000);
dong_bo();
sms=0;d=0;n=0,dau=0,cuoi=0,ph=0,ring=0;
LCD_putcmd(0x01);
LCD_putcmd(0x80);Printf(LCD_putchar,"DKTB - GSM");
delay_ms(1000);
LCD_putcmd(0xC0);Printf(LCD_putchar,"Da san sang...");
delay_ms(1000);
}
Còn đây là code lcd_lib_4bit
Code:
#include <stddef.h>
#define LCD_RS PIN_D1
#define LCD_RW PIN_D2
#define LCD_EN PIN_D3
#define LCD_D4 PIN_D4
#define LCD_D5 PIN_D5
#define LCD_D6 PIN_D6
#define LCD_D7 PIN_D7
// misc display defines-
#define Line_1 0x80
#define Line_2 0xC0
#define Clear_Scr 0x01
// prototype statements
#separate void LCD_Init ( void );// ham khoi tao LCD
#separate void LCD_SetPosition ( unsigned int cX );//Thiet lap vi tri con tro
#separate void LCD_PutChar ( unsigned int cX );// Ham viet1kitu/1chuoi len LCD
#separate void LCD_PutCmd ( unsigned int cX) ;// Ham gui lenh len LCD
#separate void LCD_PulseEnable ( void );// Xung kich hoat
#separate void LCD_SetData ( unsigned int cX );// Dat du lieu len chan Data
// D/n Cong
#use standard_io ( B )
#use standard_io (A)
//khoi tao LCD**********************************************
#separate void LCD_Init ( void )
{
LCD_SetData ( 0x00 );
delay_ms(200);
output_low ( LCD_RS );// che do gui lenh
output_low(LCD_RW);
LCD_SetData ( 0x03 );
LCD_PulseEnable();
LCD_PulseEnable();
LCD_PulseEnable();
LCD_SetData ( 0x02 );
LCD_PulseEnable();
LCD_PutCmd ( 0x2C );
LCD_PutCmd ( 0b00001100);
LCD_PutCmd ( 0x06 );
LCD_PutCmd ( 0x01 );
}
#separate void LCD_SetPosition ( unsigned int cX )
{
/* this subroutine works specifically for 4-bit Port A */
LCD_SetData ( swap ( cX ) | 0x08 );
LCD_PulseEnable();
LCD_SetData ( swap ( cX ) );
LCD_PulseEnable();
}
#separate void LCD_PutChar ( unsigned int cX )
{
/* this subroutine works specifically for 4-bit Port A */
output_high ( LCD_RS );
LCD_PutCmd( cX );
output_low ( LCD_RS );
}
#separate void LCD_PutCmd ( unsigned int cX )
{
/* this subroutine works specifically for 4-bit Port A */
LCD_SetData ( swap ( cX ) ); /* send high nibble */
LCD_PulseEnable();
LCD_SetData ( swap ( cX ) ); /* send low nibble */
LCD_PulseEnable();
}
#separate void LCD_PulseEnable ( void )
{
output_high ( LCD_EN );
delay_us ( 50); // was 10
output_low ( LCD_EN );
delay_ms ( 3); // was 5
}
#separate void LCD_SetData ( unsigned int cX )
{
output_bit ( LCD_D4, cX & 0x01 );
output_bit ( LCD_D5, cX & 0x02 );
output_bit ( LCD_D6, cX & 0x04 );
output_bit ( LCD_D7, cX & 0x08 );
}
Cảm ơn các anh nhiều

Comment