基于51單片機(jī)的單通道頻率計(jì)1602顯示
并在1602液晶顯示頻率:?jiǎn)挝粫r(shí)間內(nèi)完成振動(dòng)的次數(shù)*/
#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--);
}
/*判忙函數(shù)*/
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
}
/*寫入命令函數(shù)*/
void write_Com(uchar com)
{
while(LCD_Check_Busy()); //忙則等待
RS=0;
RW=0;
EN=1;
P0= com;
_nop_();
EN=0;
}
/*寫入數(shù)據(jù)函數(shù)*/
void write_dat(uchar dat)
{
while(LCD_Check_Busy()); //忙則等待
RS=1;
RW=0;
EN=1;
P0= dat;
_nop_();
EN=0;
}
/*清屏函數(shù)*/
void LCD_Clear(void)
{
write_Com(0x01);
DelayMs(5);
}
/*寫入字符函數(shù)*/
評(píng)論