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

📄 demo12864.c

📁 LCD液晶驱动程序代码
💻 C
字号:
#include <reg51.h>
#include <absacc.h>
#include <IO.h>
#define	 Uint unsigned int
#define  Uchar unsigned char
#define  Max197dh  XBYTE[0x8001]  //A/D高四位地址
#define  Max197dl  XBYTE[0x8000]  //A/D低八位地址
#define  Max197com XBYTE[0x8000]  //Control byte
#define  Com8255   XBYTE[0x4003]
#define  Pa8255    XBYTE[0x4000]
#define  Pb8255    XBYTE[0x4001] 
#define  Pc8255    XBYTE[0x4002] 
sbit Ea=P1^0;
unsigned char a=0,b=0,i=0;
void    DisplayListCharDelay(unsigned char X, unsigned char Y,unsigned int T, unsigned char code *DData);		
void 	DisplayListChar(Uchar X, Uchar Y,Uchar code *DData);
void 	DisplayOneChar(Uchar X, Uchar Y,Uchar DData);
void 	DelayMs(Uint x) ;
void 	LCMInit(void);
void    DisplayInt(Uchar X,Uchar Y,Uint f);
void 	WriteCommandLCM(Uchar WCLCM,BuysC);
void    DisplayFloat( Uchar X,Uchar Y,float f,Uchar g); 
void    dealay(unsigned char c,unsigned char d);
void 	WriteDataLCM(Uchar WDLCM);
void    Max197(); 
extern  Uchar M;
Uchar code str1[]="This is a test!";
Uchar code str0[]="Keil Software development tools. 18/05/2005";
//Uchar code str1[]="The Voltage is:"; 
//Uchar code str2[]="123 1234567 78:"; 
Uchar code str2[]="The SOFTWARE PRODUCT is owned by KEIL.";
Uchar code str3[]="Now loading please wait!"; 
Uchar code str4[]="Copyright (c) 2005 Keil Software and Keil Elektronik.";
Uchar code str5[]="Test OK!";
float  AdData=0;
Uchar s=0;
int d=-1;


timer1() interrupt 3 using 2
	{
	 
	 PCON=0x02;
	 //TH0=(65365-0)/256;
     //TL0=(65365-0)%256;
	}




void main() 
{	

	
	//Uchar i;
	PSB=1;
    RST=0;
	DelayMs(100);
	RST=1;
    DelayMs(100);
	LCMInit();
	DelayMs(5);
/*/while(1) 
	//{
		WriteCommandLCM(0x01,1);
		DisplayListChar(1, 0,str1);
		DisplayOneChar(0,2,0x1A);
		for(i=0;i<=14;i++)
		{
		   DisplayOneChar(0,0,0x1A);
		   DelayMs(900); 
		}
		DelayMs(4000); 
		WriteCommandLCM(0x01,1);
		DisplayListCharDelay(1, 0,250,str0);
		DelayMs(8000);
		WriteCommandLCM(0x01,1); 
		DisplayListCharDelay(1, 0,250,str2);
		DelayMs(8000); 
		WriteCommandLCM(0x01,1); 
		DisplayListCharDelay(1, 0,250,str3);
		DelayMs(8000); 
		WriteCommandLCM(0x01,1); 
		DisplayListCharDelay(1, 0,250,str4);
		//DelayMs(8000); 
   // }		 */
		//DisplayInt(7,0,65364);
		//DisplayInt(2,1,65364);
		//DisplayInt(4,2,65364);
		//DisplayInt(6,3,65364);
	    
		//DisplayOneChar(5,0,'-');
		//DisplayFloat(0,0,-12.345987,6);
		//DisplayFloat(7,1,1.0123456,7);
		//DisplayFloat(0,2,1.0123456,7);
		//DisplayOneChar(0,0,'M');
		//DisplayOneChar(0,0,'h');
		//DisplayOneChar(0,0,'z'); 
		
	
		
		  //PCON=0x02;
		   while(1)
	 {
		  
		  /*WriteDataLCM(0xcd);
		  WriteDataLCM(0xea);
		  WriteDataLCM(0xd1);
		  WriteDataLCM(0xd5);
		  WriteDataLCM(0xc9);
		  WriteDataLCM(0xdc);
		  WriteDataLCM(0xc6);
		  WriteDataLCM(0xbd);*/
		  //Max197();
		 // AdData=(b<<8)+a;
		 // AdData=AdData/819.2;
		  //DelayMs(300);
		  
		 // DisplayListChar(0,0,str1);
		  //WriteCommandLCM(0x34,1);
		  //WriteCommandLCM(0x04,1);
		  //WriteCommandLCM(0x02,1);
		  //WriteCommandLCM(0x08,1);
		  //WriteCommandLCM(0x02,1);
		  //WriteCommandLCM(0x08,1);
		  //DisplayListCharDelay(3,1,400,str1);
		  //DisplayListCharDelay(5,2,400,str1);
		 // DisplayFloat(0,1,AdData,3);
		  //DisplayOneChar(3,1,'V'); 
		 // DelayMs(500);
		  //WriteCommandLCM(0x30,1);
		 // WriteCommandLCM(0x02,1);
		 // DelayMs(500);
		  //WriteDataLCM(0x03);
		  //WriteCommandLCM(0x30,1);
		  while(1)
		  {
		   
		   //if(s==5){s=0;}
		   //else
		    //{
			WriteCommandLCM(0x01,1);
		    DisplayListChar(1, 0,str3);
		    DisplayOneChar(0,2,0x1A);
		for(i=0;i<=14;i++)
		{
		   DisplayOneChar(0,0,0x1A);
		   DelayMs(900); 
		}
			WriteCommandLCM(0x01,1);
			DisplayListCharDelay(0,1,500,str1);
			DelayMs(2800);
			WriteCommandLCM(0x01,1);	
			DisplayListCharDelay(1,0,500,str0);
			DelayMs(1800);	
			WriteCommandLCM(0x01,1);
			DisplayListCharDelay(1,0,500,str2);
			DelayMs(1800);	
			WriteCommandLCM(0x01,1);
			DisplayListCharDelay(1,0,500,str4);
			DelayMs(1800);	
			WriteCommandLCM(0x01,1);
			 for(a=0;a<=3;a++)
			    for(s=0;s<=7;s++)
		     {
			   WriteCommandLCM(0x01,1);
		       DisplayFloat(s,a,0.123456*d,6);
		       DelayMs(2000);	
	           d=-d;
			 }
			 WriteCommandLCM(0x01,1);
			 DisplayListCharDelay(2,1,500,str5);
			 DelayMs(6800);


		    //}
		   
		
		}

	 }	   
		
		
}
   
/*////////////////////////////////////////////////////////////////////////////
voltage measure
////////////////////////////////////////////////////////////////////////////*/

/*sendbyte(unsigned char f)
{
	SBUF=f;
	while(TI==0);
	TI=0;
}	 */

void Max197()
{
	 
	 
	 Max197com=0x67;
	 Max197com=0x47;
	 dealay(5,5);
	 a=Max197dl;
	 b=Max197dh;

     
}


///////////////////////////////////
void dealay(unsigned char c,unsigned char d)
{
 
  unsigned char i,j;
  for(i=0;i<=c;i++)
  for(j=0;j<=d;j++)
  {
    ;
  }

}
/////////////////////////////////////////////














⌨️ 快捷键说明

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