/*内容:T0外部计数,T1计时1S,核算1S内外部脉冲个数,
并在1602液晶显示频率:单位时间内完结振荡的次数*/
#include
#include
#include
#define uchar unsigned char
#define CHECK_BUSY
sbit RS = P2^4; //界说端口
sbit RW = P2^5;
sbit EN = P2^6;
bit OVERFLOWFLAG;
bit TIMERFLAG;
void DelayMs(uchar t)
{
int x,y;
for (x=t;x>0;x–)
for(y=110;y>0;y–);
}
/*判忙函数*/
bit LCD_Check_Busy(void)
{
#ifdef CHECK_BUSY
P0= 0xFF;
RS=0;
RW=1;
EN=0;
_nop_();
EN=1;
return (bit)(P0 & 0x80);
#else
return 0;
#endif
}
/*写入指令函数*/
void write_Com(uchar com)
{
while(LCD_Check_Busy()); //忙则等候
RS=0;
RW=0;
EN=1;
P0= com;
_nop_();
EN=0;
}
/*写入数据函数*/
void write_dat(uchar dat)
{
while(LCD_Check_Busy()); //忙则等候
RS=1;
RW=0;
EN=1;
P0= dat;
_nop_();
EN=0;
}
/*清屏函数*/
void LCD_Clear(void)
{
write_Com(0x01);
DelayMs(5);
}
/*写入字符函数*/