#includetypedefunsigned char uchar;
typedefunsigned int uint;
floatgetdata;
uinttemp;
unsignedchar dispbuf[8]={10,10,10,10,10,0,0,0};
uchar*p="0123456789";
sbitST=P3^0;
sbitOE=P3^1;
sbitEOC=P3^2;
sbitCLK=P3^3;
sbitrs=P2^5;
sbitrw=P2^6;
sbite=P2^7;
voiddelay(unsigned int t) //延时函数
{
unsigned int i;
for(t;t>0;t--)
for(i=120;i>0;i--);
}
voidwrite_com(uchar com) //写指令函数
{
rs=0; //选择写命令模式
rw=0; //写入
P0=com; //将要写的命令字送到数据总线上
delay(5);
//使能端给一高脉冲,因为初始化函数中将e置零
e=1;
delay(5);
e=0;//将使能端置0以完成高脉冲
}
voidwrite_data(uchar dat) //写数据函数
{
rs=1; //选择写数据命令模式
rw=0; //写入
P0=dat;
delay(5);
e=1;
delay(5);
e=0;
}
voidinit(