#include <REG51.H>
#include <INTRINS.H>
sbit RS=0xb0;
sbit RW=0xb1;
sbit E=0xb2;
void lcd_w_cmd(unsigned char com);
void lcd_w_dat(unsigned char dat);
unsigned char lcd_r_start();
void int1();
void delay(unsigned char t);
void delay1();
void main()
{
unsigned char lcd[]="SHEN ZHEN";
unsigned char i;
P1=0xff; //
int1(); //3?ê??ˉlcd
delay(255);
lcd_w_cmd(0x83);
delay(255);
for(i=0;i<9;i++)
{
lcd_w_dat(lcd[ i]); // write data shen zhen
delay(200);
}
while(1); //?-μ?ì¤2?
}
void delay(unsigned char t)
{
unsigned char j,i;
for(i=0;i<t;i++)
for(j=0;j<50;j++);
}
void delay1()
{
_nop_();
_nop_();
_nop_();
}
void int1()
{
lcd_w_cmd(0x3c);
lcd_w_cmd(0x0e);
lcd_w_cmd(0x01);
lcd_w_cmd(0x06);
lcd_w_cmd(0x80);
}
unsigned char lcd_r_start() //r zhuangtai
{
unsigned char s;
RW=1;
delay1();
RS=0;
delay1();
E=1;
delay1();
s=P1;
delay1();
E=0;
delay1();
RW=0; //RS=1;
delay1();
return(s);
}
void lcd_w_cmd(unsigned char com)
{
unsigned char i;
do{
i=lcd_r_start();
i=i&0x80;
delay(2);
}
while(i!=0);
RW=0;
delay1();
RS=0;
delay1();
E=1;
delay1();
P1=com;
delay1();
E=0;
delay1();
RW=1;
delay(255);
}
void lcd_w_dat(unsigned char dat)
{
unsigned char i;
do{
i=lcd_r_start();
i=i&0x80;
delay(2);
}while(i!=0);
RW=0;
delay1();
RS=1;
delay1();
E=1;
delay1();
P1=dat;
delay1();
E=0;
delay1();
RW=1;
delay(255);
}
|