void Delay5Ms(void) {
unsigned int TempCyc = 5552; while(TempCyc--); }
//读状态
unsigned char ReadStatusLCD(void) {
LCD_Data = 0xFF; LCD_RS = 0; LCD_RW = 1; LCD_E = 0;
LCD_E = 0; LCD_E = 1;
while (LCD_Data & Busy); //检测忙信号 return(LCD_Data); }
//********* LCD1602驱动程序 *************** //写数据
void WriteDataLCD(unsigned char WDLCD) {
ReadStatusLCD(); //检测忙 LCD_Data = WDLCD; LCD_RS = 1;
LCD_RW = 0;
LCD_E = 0; //若晶振速度太高可以在这后加小的延时 LCD_E = 0; //延时
LCD_E = 1; }
//写指令
void WriteCommandLCD(unsigned char WCLCD,BuysC) //BuysC为0时忽略忙检测 {
if (BuysC)
ReadStatusLCD(); //根据需要检测忙 LCD_Data = WCLCD; LCD_RS = 0; LCD_RW = 0; LCD_E = 0; LCD_E = 0; LCD_E = 1; }