⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lcd.c

📁 汉字双排LCD液晶的驱动程序 KeilC
💻 C
字号:
/*  
连线定义:
	C51 ~~ LCD
	P0  =  DB  (P00--P07=D0-D7)
	P20 =  RW
	P21 =  RS
	P22 =  E
*/  
#include <c51.h>


sbit LCD_RW=  P2^0;  
sbit LCD_RS=  P2^1;
sbit LCD_E =  P2^2;

#define LCD_DB  P0

sbit LCD_DB0=  P0^0;
sbit LCD_DB1=  P0^1;
sbit LCD_DB2=  P0^2;
sbit LCD_DB3=  P0^3;
sbit LCD_DB4=  P0^4;
sbit LCD_DB5=  P0^5;
sbit LCD_DB6=  P0^6;
sbit LCD_DB7=  P0^7;


unsigned char   lcdStatus()   // no delay at all. get AC & busy flage(BF)
{
    unsigned char d;
    LCD_RS=0;
    LCD_RW=1;
	LCD_E=1;  //????
	d=LCD_DB;
	LCD_E=0;  //????
    return (d); 
}

void   lcdWrRAM(unsigned char dat)
{
    while(lcdIsBusy());
    LCD_RS=1;
    LCD_RW=0;
	LCD_E=1;
	LCD_DB=dat;
    delay(72);
	LCD_E=0;

	}

unsigned char   lcdRdRAM()
{
    unsigned char d;
    while(lcdIsBusy());
    LCD_RS=0;
    LCD_RW=0;
	LCD_E=1;
    delay(72);
	d=LCD_DB;
	LCD_E=0;
	return d;
}

void   lcdIdleMode()  //ex Function
{
    LCD_RS=0;
    LCD_RW=0;
	LCD_DB=1;
	LCD_E=1;
    delay(72);
	LCD_E=0;
}


void  lcdInstruction(unsigned char ins)
{
   while(lcdIsBusy());
   LCD_RS=0;
   LCD_RW=0;
   LCD_E=1;
   LCD_DB=ins;
   delay(72); 
   LCD_E=0;

}
   

void lcdInit()
{
   delay(40000);
   lcdInstruction(0x30);  
   delay(120);  
   lcdInstruction(0x30);
   delay(40);
   lcdInstruction(0x0e);
   delay(120);
   lcdInstruction(0x01);
   delay(10000);
   lcdInstruction(0x06);
   delay(100);
}


void lcdPrts(char *str)
{
   char *s;
   s=str;
   while (*s)
   {
     lcdWrRAM(*s);
     s++;
   };
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -