1602.h
#ifndef _1602L_
#define _1602L_
sbit E=P3^5;
sbit RW=P3^6;
sbit RS=P3^7;
#define uchar unsigned char
//-------------------------------------
void Delay(unsigned int t) // delay 40us
{
for(;t!=0;t--) ;
}
//=============================================
void SendCommandByte(unsigned char ch)
{
RS=0;
RW=0;
P1=ch;
E=1;
Delay(1);
E=0;
Delay(100); //delay 40us
}
//-------------------------------------------------------
void SendDataByte(unsigned char ch)
{ RS=1;
RW=0;
P1=ch;
E=1;
Delay(1);
E=0;
Delay(100); //delay 40us
}
//-------------------------------------------------
void InitLcd()
{SendCommandByte(0x30);
SendCommandByte(0x30);
SendCommandByte(0x30);
SendCommandByte(0x38); //设置工作方式
SendCommandByte(0x0c); //显示状态设置
SendCommandByte(0x01); //清屏
SendCommandByte(0x06); //输入方式设置
}
//=============================================
void DisplayMsg( uchar *p)
{
unsigned char count;
SendCommandByte(0x80); //设置DDRAM地址
for(count=0;count <4;count++)
{SendDataByte(*p++);
}
}
#endif
.h应该没有问题,用了好久了,小弟让t1定时中断,没有用1s(直接65536us中断,读出此时的1602上面的显示2844),我测得是40K标准方波,晕用2844/65536us,结果是43.4khz,改了好长时间,请大家帮我看看,51的测频应该哦很准的吧