lcd_write_command(0x80+0x40);这句程序为什么不起作用,在液晶上只显示第一行的hello
#include"reg51.h"
#define uchar unsigned char
#define uint unsigned int
sbit lcd_E=P2^7;
sbit lcd_RS=P2^6;
sbit lcd_RW=P2^5;
uchar code table[]="hello";
uchar code table1[]="nihao";
uchar i;
void delay(uint z)
{
uint y;
for(;z>0;z--)
for(y=110;y>0;y--);
}
void lcd_write_command(uchar com)
{
lcd_RS=0;
lcd_RW=0;
P0=com;
lcd_E=1;
lcd_E=0;
delay(1);
}
void lcd_write_data(uchar dat)
{
lcd_RS=1;
lcd_RW=0;
P0=dat;
lcd_E=1;
lcd_E=0;
delay(20);
}
void init()
{
lcd_E=0;
lcd_write_command(0x38);
lcd_write_command(0x0c);
lcd_write_command(0x06);
lcd_write_command(0x80);
delay(20);
}
void main()
{
init();
for(i=0;i<5;i++)
{
lcd_write_data(table);
delay(20);
}
lcd_write_command(0x80+0x40);
for(i=0;i<5;i++)
{
lcd_write_data(table1);
delay(20);
}
while(1);
} |