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

📄 init_lcd.#1

📁 ad转换的程序
💻 #1
字号:
/*=========================================================================================
                     INITLCD RUTINE
===========================================================================================
AHTH: GDY
DATE:
COMMENT: 
===========================================================================================*/
/*--------------------------------------INCLUDE--------------------------------------------*/
#include <c8051f020.h>
/*---------------------------------------FUCTION DECLARING---------------------------------*/
extern void set_xy(unsigned char x,unsigned char y);
extern void delay(int t);
unsigned char read_status();
unsigned char wcode(unsigned char c);
unsigned char wdata(unsigned char d);
/*---------------------------------------16BIT SFR DEFINE----------------------------------*/
sbit DINLCD=P1^0;
sbit RWLCD=P3^7;
sbit ESIG=P1^1;
/*---------------------------------------GLOBLE DEFINE OR DECLARING------------------------*/
extern unsigned char code zk[];
unsigned char read_status()
	{
	unsigned char status;
	RWLCD=1;
//	CSLCD=0;
	DINLCD=0;
	ESIG=1;
	status=0;
	ESIG=0;
	return(status);
	}
		
void init_lcd()
	{
   	unsigned char status;
	status=read_status()&0x80;
    while(status)
	status=read_status()&0x80;
	wcode(0x3f);
	status=read_status()&0x80;
    while(status)
	status=read_status()&0x80;
	wcode(0xc0);
	status=read_status()&0x80;
    while(status)
	status=read_status()&0x80;
	wcode(0xb8);
	status=read_status()&0x80;
    while(status)
	status=read_status()&0x80;
	wcode(0x40);
	}
/****************************************
 THE BLOCK IS FOR WRITTING CODE 
 WR=0
 DI=0
 and when the e's fall ,the code would be latched.
****************************************/
unsigned char wcode(unsigned char c)
	{
	RWLCD=0;
	delay(10);
//	CSLCD=0;
	DINLCD=0;
	delay(10);
	ESIG=1;
	delay(10);
	P2=c;
	delay(10);
	ESIG=0;
	delay(10);
	return(c);
	}
/****************************************
THE BLOCK IS FOR WRITTING DATA 
DI=1
RW=0
when e's falling ,the data would be latched
****************************************/

unsigned char wdata(unsigned char d)
	{
	DINLCD=1;
	delay(10);
//	CSLCD=0;
	RWLCD=0;
	delay(10);
	ESIG=1;
	delay(10);
//	delay(5);
	P2=d;
    delay(100);
	ESIG=0;
	delay(10);
	return(d);
	delay(10);
	}
/****************************************
THE BLOCK IS FOR CLEARING
****************************************/

void clear()
	{
	int i,x;
	for(x=0;x<8;x++)
		{ 
		  set_xy(x,0);
		  for(i=0;i<64;i++)
		     wdata(0xFF);
   		 }
	}
	

⌨️ 快捷键说明

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