# include <reg51.h>
sbit rw=P2^5;
sbit rs=P2^6;
sbit E=P2^7;
sbit CS = P3^2;
sbit RSET = P3^3;
void init ();
void writecom (unsigned char );
void writedate (unsigned char );
void delay ();
unsigned char com,date;
void main ()
{
unsigned char i;
init ();
writecom (0x80);
for (i=0;i<8;i++)
{
writedate (0x00+i);
delay ();
}
}
void writecom (unsigned char com)
{
/*unsigned char temp;
temp=0;
rs=0;
rw=1;
do
{
E=1;
delay ();
temp=P0;
E=0;
}
while (temp&0x80);
rs=0;
rw=0;
P0=com;
delay ();
E=1;
delay ();
E=0;
*/
CS = 0; //chip select,打开片选
E = 1; //disable read,读失能
rs = 0; //select command,选择命令
rw = 0; //select write,选择写模式
delay();
delay ();
P0 = com; //put command,放置命令
delay();
delay();
rw = 1;
}
void writedate (unsigned char date)
{
/* unsigned char temp;
temp=0;
rs=0;
rw=1;
do
{
E=1;
delay ();
temp=P0;
E=0;
}
while (temp&0x80);
rs=1;
rw=0;
P0=date;
delay ();
E=1;
delay ();
E=0;
*/
CS = 0; //chip select,打开片选
E = 1; //disable read,读失能
rs = 0; //select command,选择命令
rw = 0; //select write,选择写模式
delay();
delay();
P0 = date; //put command,放置命令
delay();
delay();
rw = 1;
}
void init ()
{
unsigned char i;
RSET = 0;
for (i=0; i<100; i++);
CS = 0;
RSET = 1;
writecom (0x01);
writecom (0x30);
writecom (0x02);
writecom (0x0c);
writecom (0x06);
writecom (0x01);
writecom (0x80);
}
void delay ()
{
unsigned char x,y;
for (x=5;x>0;x--)
for (y=110;y>0;y--);
}
此程序是为了让12864显示一行字符 感觉程序没错呀 但是液晶总是什么都不显示 为什么这是 跪求大神求解 小弟定当感恩不胜
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>