Mình viết code thế này nhưng chỉ chạy in ra màn hình có "Vu huu the""DCN2" mà không chạy tiếp in ra "Hoang gia thanh""DCN2" các bác giúp em với ạ ! thanks các bác đọc tin !
#include <REGX52.H>
#include <string.h>
#define LCDdata P2
sbit rs=P1^0;
sbit rw=P1^1;
sbit en=P1^2;
sbit BF=0xA7;
void delay(long time)
{
long n;
for(n=0;n<time;n++);
}
void lcd_wait()
{
long n=0;
en=1;
rs=0;
rw=1;
LCDdata=0xff;
while(BF)
{
n++;if(n>100)break;
}
en=0;
rw=0;
}
void lcd_control(unsigned char x)
{
en=1;
rs=0;
rw=0;
LCDdata=x;
en=0;
lcd_wait();
}
void lcd_init()
{
lcd_control(0x30);
lcd_control(0x30);
lcd_control(0x30);
lcd_control(0x38);
lcd_control(0x0c);
lcd_control(0x06);
lcd_control(0x01);
}
void lcd_writedata(unsigned char c)
{
rs=1;
rw=0;
LCDdata=c;
en=1;
en=0;
delay(1000);
}
void lcd_write()
{
unsigned char i;
en=1;
rs=1;
rw=0;
LCDdata=i;
en=0;
lcd_wait();
}
void lcd_puts(unsigned char *s)
{
while (*s)
{
lcd_writedata(*s);
s++;
}
}
void lcd_cmd(unsigned char x);
void main()
{
char x;
{
lcd_init();
lcd_puts("Vu huu The");
delay(3000);
lcd_control(0xC0+3);
lcd_puts("D6DCN2");
delay(3000);
lcd_cmd(0x01);
lcd_puts("Hoang gia thanh");
delay(3000);
lcd_control(0xC0+3);
lcd_puts("D6DCN2");
delay(3000);
lcd_cmd(0x01);
}
}
#include <REGX52.H>
#include <string.h>
#define LCDdata P2
sbit rs=P1^0;
sbit rw=P1^1;
sbit en=P1^2;
sbit BF=0xA7;
void delay(long time)
{
long n;
for(n=0;n<time;n++);
}
void lcd_wait()
{
long n=0;
en=1;
rs=0;
rw=1;
LCDdata=0xff;
while(BF)
{
n++;if(n>100)break;
}
en=0;
rw=0;
}
void lcd_control(unsigned char x)
{
en=1;
rs=0;
rw=0;
LCDdata=x;
en=0;
lcd_wait();
}
void lcd_init()
{
lcd_control(0x30);
lcd_control(0x30);
lcd_control(0x30);
lcd_control(0x38);
lcd_control(0x0c);
lcd_control(0x06);
lcd_control(0x01);
}
void lcd_writedata(unsigned char c)
{
rs=1;
rw=0;
LCDdata=c;
en=1;
en=0;
delay(1000);
}
void lcd_write()
{
unsigned char i;
en=1;
rs=1;
rw=0;
LCDdata=i;
en=0;
lcd_wait();
}
void lcd_puts(unsigned char *s)
{
while (*s)
{
lcd_writedata(*s);
s++;
}
}
void lcd_cmd(unsigned char x);
void main()
{
char x;
{
lcd_init();
lcd_puts("Vu huu The");
delay(3000);
lcd_control(0xC0+3);
lcd_puts("D6DCN2");
delay(3000);
lcd_cmd(0x01);
lcd_puts("Hoang gia thanh");
delay(3000);
lcd_control(0xC0+3);
lcd_puts("D6DCN2");
delay(3000);
lcd_cmd(0x01);
}
}