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

📄 8301v20070104.c

📁 nt7538 tl8201 c初始化代码
💻 C
字号:
/************************************************
module		LDM176220TC14
LCD			2.2"TFT 176*220
IC			R61503
VDD			2.8V
IDD			
Iled		
interface	8080/16bits
programed	Li Ming
date		2006.3.1
************************************************/
#include <reg51.h>


#define     uchar       unsigned char

sbit    rd		=P1^3;
sbit	wr		=P1^4;
sbit    cs	 	=P1^5;
sbit	res		=P1^6;
sbit    rs     	=P1^7;
sbit	Key		=P3^3;

sbit	rom_cs0		=P3^4;

//P2: DB17-10 P0:DB8-DB1

uchar code ModuleName[];
uchar code GrayPic[];
uchar code Picture[];
uchar *p;
unsigned char m,n;

void WCom(uchar d)
{
	
    uchar m,n;
    m=d;
    n=d;
    n=n>>7;
    m=m<<1;
    P2=(n)&0x01;
	P0=(m)&0xfe;
	rd=1; 
	cs=0;
	rd=1;
	rs=0;
 	wr=0;
 	wr=1;
 	cs=1;
}
void WData(uchar dh,dl)
{
    uchar dl1;
    uchar dh1;
    dl1=dl;
    dh1=dh;
	P0=(dl<<1)&0xfe;
	P2=((dh<<2)&0xfc)+((dl1>>7)&0x01);
 	P3=((dh1>>6)&0x03)|0xfc;
	rd=1;
 	cs=0;
	rd=1;
	rs=1;
 	wr=0;
 	wr=1;
 	cs=1;
}
void WDataB(uchar dh,dl)
{
    uchar dl1;
    uchar dh1;
    dl1=dl;
    dh1=dh;
//	P0=(dl<<1)|0xc1;
	P0=(dl<<1)|0xc1;
	P2=0x00;
 	P3=0xfc;
	rd=1;
 	cs=0;
	rd=1;
	rs=1;
 	wr=0;
 	wr=1;
 	cs=1;
}
void WDataR(uchar dh,dl)
{
    uchar dl1;
    uchar dh1;
    dl1=dl;
    dh1=dh;
	P0=0x00;
	P2=((dh<<2)&0xe0);
	
 	P3=((dh1>>6)&0x03)|0xfc;
	rd=1;
 	cs=0;
	rd=1;
	rs=1;
 	wr=0;
 	wr=1;
 	cs=1;
}
void WDataG(uchar dh,dl)
{
    uchar dl1;
    uchar dh1;
    dl1=dl;
    dh1=dh;
	P0=(dl<<1)&0xc0;
	P2=((dh<<2)&0x1c)+((dl1>>7)&0x01);
 	P3=0xfc;
	rd=1;
 	cs=0;
	rd=1;
	rs=1;
 	wr=0;
 	wr=1;
 	cs=1;
}
void Delay(int Nms)//1ms
{
 int i,j,k;
 for(i=0;i<Nms;i++)
	for(j=0;j<2;j++)
		for(k=0;k<131;k++);
}
void WaitKey()
{
 Key=1;
 while(Key);
 Delay(100);
 while(!Key);
}
void Black()
{
	int Row,Column;
	WCom(0x50);
	WData(0,0);
	WCom(0x51);
	WData(0,175);
	WCom(0x52);
	WData(0,0);
	WCom(0x53);
	WData(0,219);
	WCom(0x20);
	WData(0,0);
	WCom(0x21);
	WData(0,0);
	WCom(0x22);
	for(Row=0;Row<220;Row++)
		for(Column=0;Column<176;Column++)
			WData(0x00,0x00);
}


void Green()
{
	int Row,Column;
	WCom(0x50);
	WData(0,0);
	WCom(0x51);
	WData(0,175);
	WCom(0x52);
	WData(0,0);
	WCom(0x53);
	WData(0,219);
	WCom(0x20);
	WData(0,0);
	WCom(0x21);
	WData(0,0);
	WCom(0x22);
	for(Row=0;Row<220;Row++)
		for(Column=0;Column<176;Column++)
			WData(0x07,0xe0);
}
void Blue()
{
	int Row,Column;
	WCom(0x50);
	WData(0,0);
	WCom(0x51);
	WData(0,175);
	WCom(0x52);
	WData(0,0);
	WCom(0x53);
	WData(0,219);
	WCom(0x20);
	WData(0,0);
	WCom(0x21);
	WData(0,0);
	WCom(0x22);
	for(Row=0;Row<220;Row++)
		for(Column=0;Column<176;Column++)
			WData(0x00,0x17);
}
void White()
{
	int Row,Column;
	WCom(0x50);
	WData(0,0);
	WCom(0x51);
	WData(0,175);
	WCom(0x52);
	WData(0,0);
	WCom(0x53);
	WData(0,219);
	WCom(0x20);
	WData(0,0);
	WCom(0x21);
	WData(0,0);
	WCom(0x22);
	for(Row=0;Row<220;Row++)
		for(Column=0;Column<176;Column++)
			WData(0xff,0xff);
}
void Red()
{
	int Row,Column;
	WCom(0x50);
	WData(0,0);
	WCom(0x51);
	WData(0,175);
	WCom(0x52);
	WData(0,0);
	WCom(0x53);
	WData(0,219);
	WCom(0x20);
	WData(0,0);
	WCom(0x21);
	WData(0,0);
	WCom(0x22);
	for(Row=0;Row<220;Row++)
		for(Column=0;Column<176;Column++)
			{WData(0xf8,0x00);
			//Delay(1);
			}
}

void init()
{
	cs=1;		//INIT STATE
	res=1;	      //INIT STATE

	Delay(1);
	res=0;	     //CHIP ENABLE,regulater work
	Delay(100);
	res=1;

	WCom(0x00);
	WData(0x00,0x01);	//ENABLE OSC,osc work
	Delay(100);

	WCom(0x02);
	WData(0x07,0x00);   	//line inversion
	WCom(0x08);
	WData(0x04,0x05);	//SET BP=8,FP=8
	
	WCom(0x01);
	WData(0x00,0x00);
	WCom(0x70);
	WData(0x1B,0x00);	//SET GATE LINE=220,START SCAN=00
	WCom(0x71);
	WData(0x00,0x01);	//normal white
	WCom(0x7A);
	WData(0x00,0x00);	//SET VL=00
	WCom(0x03);
	WData(0x10,0x30);	//choice 8 diretion,normal speed

	WCom(0x90);
	WData(0x00,0x0d);	//80SET DIVI=00,  LINE PERIOD=18 CLOCKS 
	WCom(0x91);
	WData(0x01,0x00);	//gate timing 
	WCom(0x92);
	WData(0x00,0x01);	//source timing

	WCom(0x98);
	WData(0x00,0x02);	//SET VSEL=10
	WCom(0x99);
	WData(0x07,0x15);
	WCom(0x9A);
    WData(0x07,0x15);

    WCom(0x30);
	WData(0x04,0x01);	//SET pkp1 pkp0 04 00
	WCom(0x36);
	WData(0x06,0x03);	//SET pkn5 pkn4 07 03
    
	WCom(0x31);
	WData(0x03,0x04);	//SET pkp3 pkp2 05 02
	WCom(0x35); 
	WData(0x03,0x04);	//SET pkn3 pkn2 05 02

	WCom(0x32);
	WData(0x02,0x05);	//SET pkp5 pkp4 00 06
	WCom(0x34);
	WData(0x02,0x05);	//SET pkn1 pkn0 01 07

	WCom(0x33);
	WData(0x00,0x07);	//SET prp1 prp0 01 02
	WCom(0x37);
	WData(0x07,0x00);	//SET prn1 prn0 02 01

	WCom(0x38);
	WData(0x14,0x03);	//1403SET vrp1 vrp0 10 10
	WCom(0x39);
	WData(0x03,0x14);	//0314SET vrn1 vrn0 10 10
	WCom(0x3A);
	WData(0x00,0x00);	//SET vajn1 vajn0 02 02

	WCom(0xB3);
	WData(0x00,0x01);	//SET 
    WCom(0x07);
	WData(0x00,0x21);	//SET gon=1,dte=0,d=1
    WCom(0x10);
    WData(0x01,0x90);	//ap=01
	
	WCom(0x11);
    WData(0x00,0x01);	//6 -4 fosc/8 vci---vci1
 	WCom(0x12);
	Delay(100);
    WData(0x01,0x12);	//SET vci--vreg
	
    WCom(0x13);
    WData(0x8f,0x0f);	//8f0fa7vcom=0.98vreg,vcomh=0.78vreg
 
	WCom(0xB1);
	WData(0x00,0x46);	//42 SET 
	Delay(100);
	WCom(0x12);
	WData(0x01,0x32);	//SET pon=1,step up on   
	Delay(200);


    WCom(0x10);
    WData(0x11,0x90);	//ap=01 

    WCom(0xB1);
    WData(0x00,0x67);	// 63SET 	


   Delay(200);
    Delay(100);

}
disp_on()
{
	WCom(0x07);
	WData(0x00,0x01);	//SET 
	Delay(100);	

    WCom(0x07);
	WData(0x00,0x01);	//SET 
	Delay(100);

	WCom(0x12);
	WData(0x11,0x32);	//SET pson=1,vregout=1.45vci1
	Delay(100);

	WCom(0x07);
	WData(0x02,0x33);	//SET 
	Delay(10);	
   
}


disp_off()
{
	WCom(0x07);
	WData(0x00,0x01);	//SET 

	WCom(0x10);
	WData(0x10,0x90);	//SET 
	Delay(30);	

	WCom(0x07);
	WData(0x00,0x00);	//SET 
}
void main()
{
	
          unsigned char xdata *pic;
          unsigned int i;
	     unsigned char keycounter;
         

         P1=0xff;
         P2=0xff;
         P3=0xff;
         P0=0xff;



Delay(10);
init();     	
disp_on(); 
 
Red();
WaitKey();
Black();
WaitKey();
White();
WaitKey();
Green();
WaitKey();
Blue();
WaitKey();

//disp_off();
	WCom(0x50);
	WData(0,0);
	WCom(0x51);
	WData(0,175);
	WCom(0x52);
	WData(0,0);
	WCom(0x53);
	WData(0,219);
	WCom(0x20);
	WData(0,0);
	WCom(0x21);
	WData(0,0);
	WCom(0x22);
 	Delay(100);
	
       while(1)
       {
       	 for(i=0;i<38720;i++)
          {
           	if(i<32768)
            P3=0xf8+keycounter;
         	else P3=0xf8+keycounter+1;   
           	 rom_cs0=0;
        	 P0=0xff;
        	 m=*pic;
       		 pic++;
         	 P0=0xff;
         	 n=*pic	;
         	 pic++;
        	 rom_cs0=1;
             P0=0xff;
         	 WData(n,m);
         		if(i==32767)
         			{
       				  pic=0;
           			} 
           }  
         Key=1;
         while(Key==1)
         { 
           Delay(1);
           }
           
         pic=0;
         keycounter=keycounter+2;
         if(keycounter==8)
         {keycounter=0;}
       }
}

⌨️ 快捷键说明

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