原创 CSTN driver

2009-1-8 14:55 4508 13 13 分类: MCU/ 嵌入式

1,IC:st7637


LCM:PZG15BW


MCU:


/*
**-----------------------------------------------------------------------------
**
**  Abstract:
** write command to lcd.
**
**  Parameters:
** x--lcd command.
**
**  Returns:
** None
**
**-----------------------------------------------------------------------------
*/


void LcdWrCom(unsigned char x)
{
 /*ADPC=0x8;
 PM2=0x00;
 PU7=0x00;
 PM7=0x00;
 LCD_CS=0;*/
 LCD_RS=0;
 LCD_WR=1;
 LCD_RD=1;
 LCD_BUS=x;
 LCD_WR=0;
 LCD_WR=1;
 LCD_BUS=0xff;
 LCD_RS=1; 
 //LCD_CS=1;
}
/*
**-----------------------------------------------------------------------------
**
**  Abstract:
** write a byte to lcd.
**
**  Parameters:
** x--lcd data.
**
**  Returns:
** None
**
**-----------------------------------------------------------------------------
*/
void LcdWrData(unsigned char x)
{
 
 /*ADPC=0x8;
 PM2=0x00;
 PU7=0x00;
 PM7=0x00;
 LCD_CS=0;
 */
 LCD_RS=1;
 LCD_WR=1;
 LCD_RD=1;
 //_NOP_();
 LCD_BUS=x;
 //_NOP_();
 LCD_WR=0;
 LCD_WR=1;


 LCD_BUS=0xff;
 LCD_RS=1;
 //LCD_CS=1; 



}
/*
**-----------------------------------------------------------------------------
**
**  Abstract:
** write a word to lcd.
**
**  Parameters:
** x--high byte.
**  y--low byte.
**  Returns:
** None
**
**-----------------------------------------------------------------------------
*/


void LcdWrData16(unsigned char x,unsigned char y)
{
 /*ADPC=0x8;
 PM2=0x00;
 PU7=0x00;
 PM7=0x00;
 LCD_CS=0;*/
 //_NOP_();
 LCD_RS=1;
 LCD_WR=1;
 LCD_RD=1;
 LCD_BUS=x;
 LCD_BUS=y;
 LCD_WR=0;
 LCD_WR=1;


 LCD_BUS=0xff;
 LCD_BUS=0xff;
 LCD_RS=1;
 //LCD_CS=1; 
}
/*
**-----------------------------------------------------------------------------
**
**  Abstract:
** Initial lcd.
**
**  Parameters:
** None
**
**  Returns:
** None
**
**-----------------------------------------------------------------------------
*/
//-----------
void LcdInit(void)
{
 PM2=0x00;
 PM7=0x00;
 LCD_BUS=0xff;
 PM0=0x00;
 ADPC=0x8;
 LCD_RD=1;
 LCD_WR=1;
 LCD_CS=0;
 LCD_RS=1;
 LCD_RST=0;
 delay(0x7fff);
 LCD_RST=1;
 delay(0xff);
 //st7637 init.
 LcdWrCom(0x01);                  //Software Reset
 delay(0xffff);                    //Delayms 150mS
 delay(0xffff);
 LcdWrCom(0xD7);                  //Autoread control
 LcdWrData(0x9F);                //Disable Autoread
 LcdWrCom(0xE0);                  //Control OTP/MTP
 LcdWrData(0x00);                //Read Mode
 //Delayms(10);                      //Delayms 10mS
 delay(0xffff);
 LcdWrCom(0xE3);                  //Control OTP/MTP
 //Delayms(20);                      //Delayms 20mS
 delay(0xffff);
 LcdWrCom(0xE1);                  //Close Read Mode
 //-----------------------------------------------------------------------------------//
 //------------------------------OTP/MTP Set [XXXX/OTPB/MTP ]-------------------------//
 //-----------------------------------------------------------------------------------//
 //------------------------------------OTPB Set---------------------------------------//
 LcdWrCom(0x00C3);                  //Bias Set
 LcdWrData(0x0000);                //1/12
 LcdWrCom(0x00C4);                  //Booster Set
 LcdWrData(0x0005);                //
 LcdWrCom(0x00C5);                  //Booster Efficiency Set
 LcdWrData(0x0011);                //
 LcdWrCom(0x00CB);                  //VG Booster Set
 LcdWrData(0x0001);                //
 LcdWrCom(0x00CC);                  //ID1 Set
 LcdWrData(0x0045);                //
 LcdWrCom(0x00CE);                  //ID3 Set
 LcdWrData(0x0000);                //
 LcdWrCom(0x00B7);                  //Glass Direction
 LcdWrData(0x00C8);                //
 LcdWrCom(0x00D0);                  //Follower Type set
 LcdWrData(0x001D);                //
 //------------------------------------MTP Set----------------------------------------//
 LcdWrCom(0x00D7);                  //Autoread control
 LcdWrData(0x00BF);                //
 LcdWrCom(0x00C7);                  //V0 Offset Voltage Set
 LcdWrData(0x0000);                //
 LcdWrData(0x0000);                //
   
 LcdWrCom(0x00B5);                  //N-line Set
 LcdWrData(0x0002);                //??????????crosstalk//0000
   
 LcdWrCom(0x00CD);                  //ID2 Set
 LcdWrData(0x00D2);                //
 
 LcdWrCom(0x00D0);                  //Set Vg Source
 LcdWrData(0x001D);                //
 
 LcdWrCom(0x00B4);                  //PTL Saving Mode Set
 LcdWrData(0x0018);                //Power Normal Mode
 //-----------------------------------------------------------------------------------//
 //----------------------------Command Table 1----------------------------------------//
 //-----------------------------------------------------------------------------------//
 LcdWrCom(0x0011);                  //Sleep Out
 LcdWrCom(0x0020);                  //Normal Display
 LcdWrCom(0x0038);                  //Idle Mode Off
 LcdWrCom(0x0025);                  //Contrast Difference Set
 LcdWrData(0x005C);                //0059
 
 LcdWrCom(0x0013);                  //Partial Mode Off
 
 LcdWrCom(0x002A);                  //Column Range
 LcdWrData(0x0002);                //Start Address-4
 LcdWrData(0x0081);                //End Address-131
 
 LcdWrCom(0x002B);                  //Page Range
 LcdWrData(0x0000);                //Start Address-0
 LcdWrData(0x007F);                //End Address-0
 LcdWrCom(0x0034);                  //TE Off
 LcdWrCom(0x0033);                  //Scroll Area Set
 LcdWrData(0x0000);                //Top Address
 LcdWrData(0x0084);                //Height Address
 LcdWrData(0x0000);                //Botton Address
 LcdWrCom(0x0037);                  //Scroll Start Address Set
 LcdWrData(0x0000);                //
 LcdWrCom(0x003A);                  //Pixel Format Set
 LcdWrData(0x0005);                //
 LcdWrCom(0x0036);                  //Memory Access Control
 LcdWrData(0x0000);                //
 LcdWrCom(0x0029);                  //Display On
 //-----------------------------------------------------------------------------------//
 //------------------------Command Table 2 [XXXX/XXXX/GAMM]---------------------------//
 //-----------------------------------------------------------------------------------//
 LcdWrCom(0x00B0);                  //Duty Set
 LcdWrData(0x0083);                //
 LcdWrCom(0x00B1);                  //First COM Set
 LcdWrData(0x0000);                //
 LcdWrCom(0x00B3);                  //OSC Div. Set
 LcdWrData(0x0000);                //
 LcdWrCom(0x00C0);                  //V0 Voltage Set
 LcdWrData(0x0002);                //VOP=14.0V
 LcdWrData(0x0001);                //
 LcdWrCom(0x00C6);                  //V0 Bias Set
 LcdWrData(0x0000);                //
 LcdWrCom(0x00B7);                  //Glass Direction
 LcdWrData(0x00C8);                //
 //------------------------------Gamma Table Set--------------------------------------//
 LcdWrCom(0x00F9);                  //Gamma
 LcdWrData(0x0000);                //
 LcdWrData(0x0002);                //
 LcdWrData(0x0004);                //
 LcdWrData(0x0006);                //
 LcdWrData(0x0008);                //
 LcdWrData(0x000A);                //
 LcdWrData(0x000C);                //
 LcdWrData(0x000E);                //
 LcdWrData(0x0010);                //
 LcdWrData(0x0012);                //
 LcdWrData(0x0014);                //
 LcdWrData(0x0016);                //
 LcdWrData(0x0018);                //
 LcdWrData(0x001A);                //
 LcdWrData(0x001C);                //
 LcdWrData(0x001E);                //
   
 LcdWrCom(0x002C);


}


void LcdDispIco(unsigned char StartXAddr,unsigned char StartYAddr,unsigned char IcoWidth ,unsigned char IcoHeight, unsigned  char  *p)
{
 unsigned char i,j;
 unsigned int temp;


 PM2=0x00;
 ADPC=0x08;
 LCD_BUS=0xff;
 
 LcdWrCom(0x2a);
 LcdWrData(StartXAddr+0x04);
 LcdWrData((StartXAddr+IcoWidth-1)+0x04);
 LcdWrCom(0x2b);
 LcdWrData(StartYAddr+0x04);
 LcdWrData((StartYAddr+IcoHeight-1)+0x04);
 LcdWrCom(0x2c);
 LCD_RS=1;
 LCD_WR=1;
 LCD_RD=1;
 for(i=0;i<IcoHeight;i++)
 {
  for(j=0;j<IcoWidth;j++)
  {
   LCD_BUS=*p++;
   LCD_WR=0;
   LCD_WR=1;
   LCD_BUS=*p++;
   LCD_WR=0;
   LCD_WR=1;
  }
 }
}
void LcdDispHz1616(unsigned char StartXAddr,unsigned char StartYAddr,unsigned char *p)
{
 unsigned char i,j;
 unsigned char temp;
 
 PM2=0x00;
 ADPC=0x08;
 LCD_BUS=0xff;
 
 LcdWrCom(0x2a);
 LcdWrData(StartXAddr+0x04);
 LcdWrData((StartXAddr+15)+0x04);
 LcdWrCom(0x2b);
 LcdWrData(StartYAddr+4);
 LcdWrData((StartYAddr+15)+4);
 LcdWrCom(0x2c);
 LCD_RS=1;
 LCD_WR=1;
 LCD_RD=1;
 for(i=0;i<32;i++)
 {
  temp=*p++;
  
  for(j=0;j<8;j++)
  {
   if(temp&0x80)
   {
    LCD_BUS=0xf8;//(unsigned char)((temp&0xff00)>>8);
    LCD_WR=0;
    LCD_WR=1;    
    LCD_BUS=0x00;//(unsigned char)(temp&0x00ff);
    LCD_WR=0;
    LCD_WR=1;
    
   }
   else
   {
    LCD_BUS=0xff;
    LCD_WR=0;
    LCD_WR=1;    
    LCD_BUS=0xff;
    LCD_WR=0;
    LCD_WR=1;
    
   } 
   temp<<=1;
  }
 }
 
}


void LcdDispRGB(unsigned char x,unsigned char y)
{
 unsigned char i,j;
 //LcdWrCom(0x28);
 PM2=0x00;
 ADPC=0x08;
 LCD_BUS=0xff;
 
 LcdWrCom(0x2a);
 LcdWrData(0x04);
 LcdWrData(131);
 LcdWrCom(0x2b);
 LcdWrData(0x04);
 LcdWrData(131);
 LcdWrCom(0x2c);
 LCD_RS=1;
 LCD_WR=1;
 LCD_RD=1;
 NOP();
 NOP();
 for(i=128;i!=0;i--)
 {
  for(j=128;j!=0;j--)
  {
   LCD_BUS=x;
   LCD_WR=0;
   LCD_WR=1;
   LCD_BUS=y;
   LCD_WR=0;
   LCD_WR=1;
   
  }
 }
}
void LcdDispChr816(unsigned char StartXAddr,unsigned char StartYAddr,unsigned char *p)
{
 unsigned char i,j;
 unsigned char temp;
 
 PM2=0x00;
 ADPC=0x08;
 LCD_BUS=0xff;
 
 LcdWrCom(0x2a);
 LcdWrData(StartXAddr+0x04);
 LcdWrData((StartXAddr+7)+0x04);
 LcdWrCom(0x2b);
 LcdWrData(StartYAddr+0x04);
 LcdWrData((StartYAddr+15)+0x04);
 LcdWrCom(0x2c);
 LCD_RS=1;
 LCD_WR=1;
 LCD_RD=1;
 for(i=0;i<16;i++)
 {
  temp=*p++;
  
  for(j=0;j<8;j++)
  {
   if(temp&0x80)
   {
    LCD_BUS=0xf8;//(unsigned char)((temp&0xff00)>>8);
    LCD_WR=0;
    LCD_WR=1;    
    LCD_BUS=0x00;//(unsigned char)(temp&0x00ff);
    LCD_WR=0;
    LCD_WR=1;
    
   }
   else
   {
    LCD_BUS=0xff;
    LCD_WR=0;
    LCD_WR=1;    
    LCD_BUS=0xff;
    LCD_WR=0;
    LCD_WR=1;
    
   } 
   temp<<=1;
  }
 }
 
}
void LcdDispDot(unsigned char StartXAddr,unsigned char StartYAddr)
{
 PM2=0x00;
 ADPC=0x08;
 LCD_BUS=0xff;
 
 LcdWrCom(0x2a);
 LcdWrData(StartXAddr+0x04);
 LcdWrData(StartXAddr+0x04);
 LcdWrCom(0x2b);
 LcdWrData(StartYAddr+0x04);
 LcdWrData(StartYAddr+0x04);
 LcdWrCom(0x2c);
 LCD_RS=1;
 LCD_WR=1;
 LCD_RD=1;
 
 LCD_BUS=0x00;//(unsigned char)((temp&0xff00)>>8);
 LCD_WR=0;
 LCD_WR=1;    
 LCD_BUS=0x00;//(unsigned char)(temp&0x00ff);
 LCD_WR=0;
 LCD_WR=1;
 
 
}


2 IC:ST7637


LCM:TM128128A


MCU:MCS-51


void delay(unsigned int x)
{
 while(x--);
}
void LcdWrCom(unsigned char x)
{
 LCD_RS=0;
 LCD_WR=1;
 LCD_RD=1;
 LCD_BUS=x;
 LCD_WR=0;
 LCD_WR=1;
 LCD_BUS=0xff;
 LCD_RS=1; 


}
void LcdWrData(unsigned char x)
{
 LCD_RS=1;
 LCD_WR=1;
 LCD_RD=1;
 LCD_BUS=x;
 LCD_WR=0;
 LCD_WR=1;
 LCD_BUS=0xff;
 LCD_RS=1; 


}
void LcdInit(void)
{
 //io port init.
 LCD_BUS=0xff;
 //LCD_BUS_H=0xff;
 LCD_RD=1;
 LCD_WR=1;
 LCD_CS=0;
 LCD_RS=1;
 LCD_RST=0;
 delay(0xffff);
 LCD_RST=1;
 delay(0xffff);
 //st7637 init.
 LcdWrCom(0x0001);                  //Software Reset
 delay(0xffff);                    //Delayms 150mS


 LcdWrCom(0x00D7);                  //Autoread control
 LcdWrData(0x009F);                //Disable Autoread
 LcdWrCom(0x00E0);                  //Control OTP/MTP
 LcdWrData(0x0000);                //Read Mode
 //Delayms(10);                      //Delayms 10mS
 delay(0x3fff);
 LcdWrCom(0x00E3);                  //Control OTP/MTP
 //Delayms(20);                      //Delayms 20mS
 delay(0x7fff);
 LcdWrCom(0x00E1);                  //Close Read Mode
 //-----------------------------------------------------------------------------------//
 //------------------------------OTP/MTP Set [XXXX/OTPB/MTP ]-------------------------//
 //-----------------------------------------------------------------------------------//
 //------------------------------------OTPB Set---------------------------------------//
 LcdWrCom(0x00C3);                  //Bias Set
 LcdWrData(0x0000);                //1/12
 LcdWrCom(0x00C4);                  //Booster Set
 LcdWrData(0x0005);                //
 LcdWrCom(0x00C5);                  //Booster Efficiency Set
 LcdWrData(0x0011);                //
 LcdWrCom(0x00CB);                  //VG Booster Set
 LcdWrData(0x0001);                //
 LcdWrCom(0x00CC);                  //ID1 Set
 LcdWrData(0x0045);                //
 LcdWrCom(0x00CE);                  //ID3 Set
 LcdWrData(0x0000);                //
 LcdWrCom(0x00B7);                  //Glass Direction
 LcdWrData(0x00C8);                //
 LcdWrCom(0x00D0);                  //Follower Type set
 LcdWrData(0x001D);                //
 //------------------------------------MTP Set----------------------------------------//
 LcdWrCom(0x00D7);                  //Autoread control
 LcdWrData(0x00BF);                //
 LcdWrCom(0x00C7);                  //V0 Offset Voltage Set
 LcdWrData(0x0000);                //
 LcdWrData(0x0000);                //
   
 LcdWrCom(0x00B5);                  //N-line Set
 LcdWrData(0x0002);                //??????????crosstalk//0000
   
 LcdWrCom(0x00CD);                  //ID2 Set
 LcdWrData(0x00D2);                //
 
 LcdWrCom(0x00D0);                  //Set Vg Source
 LcdWrData(0x001D);                //
 
 LcdWrCom(0x00B4);                  //PTL Saving Mode Set
 LcdWrData(0x0018);                //Power Normal Mode
 //-----------------------------------------------------------------------------------//
 //----------------------------Command Table 1----------------------------------------//
 //-----------------------------------------------------------------------------------//
 LcdWrCom(0x0011);                  //Sleep Out
 LcdWrCom(0x0020);                  //Normal Display
 LcdWrCom(0x0038);                  //Idle Mode Off
 LcdWrCom(0x0025);                  //Contrast Difference Set
 LcdWrData(0x005C);                //0059
 
 LcdWrCom(0x0013);                  //Partial Mode Off
 
 LcdWrCom(0x002A);                  //Column Range
 LcdWrData(0x0002);                //Start Address-4
 LcdWrData(0x0081);                //End Address-131
 
 LcdWrCom(0x002B);                  //Page Range
 LcdWrData(0x0000);                //Start Address-0
 LcdWrData(0x007F);                //End Address-0
 LcdWrCom(0x0034);                  //TE Off
 LcdWrCom(0x0033);                  //Scroll Area Set
 LcdWrData(0x0000);                //Top Address
 LcdWrData(0x0084);                //Height Address
 LcdWrData(0x0000);                //Botton Address
 LcdWrCom(0x0037);                  //Scroll Start Address Set
 LcdWrData(0x0000);                //
 LcdWrCom(0x003A);                  //Pixel Format Set
 LcdWrData(0x0005);                //
 LcdWrCom(0x0036);                  //Memory Access Control
 LcdWrData(0x00);                //
 LcdWrCom(0x0029);                  //Display On
 //-----------------------------------------------------------------------------------//
 //------------------------Command Table 2 [XXXX/XXXX/GAMM]---------------------------//
 //-----------------------------------------------------------------------------------//
 LcdWrCom(0x00B0);                  //Duty Set
 LcdWrData(0x0083);                //
 LcdWrCom(0x00B1);                  //First COM Set
 LcdWrData(0x0000);                //
 LcdWrCom(0x00B3);                  //OSC Div. Set
 LcdWrData(0x0000);                //
 LcdWrCom(0x00C0);                  //V0 Voltage Set
 LcdWrData(0x00f8);                //VOP=14.0V
 LcdWrData(0x0000);                //
 LcdWrCom(0x00C6);                  //V0 Bias Set
 LcdWrData(0x0000);                //
 LcdWrCom(0x00B7);                  //Glass Direction
 LcdWrData(0x00C8);                //
 //------------------------------Gamma Table Set--------------------------------------//
 LcdWrCom(0x00F9);                  //Gamma
 LcdWrData(0x0000);                //
 LcdWrData(0x0002);                //
 LcdWrData(0x0004);                //
 LcdWrData(0x0006);                //
 LcdWrData(0x0008);                //
 LcdWrData(0x000A);                //
 LcdWrData(0x000C);                //
 LcdWrData(0x000E);                //
 LcdWrData(0x0010);                //
 LcdWrData(0x0012);                //
 LcdWrData(0x0014);                //
 LcdWrData(0x0016);                //
 LcdWrData(0x0018);                //
 LcdWrData(0x001A);                //
 LcdWrData(0x001C);                //
 LcdWrData(0x001E);                //
   
 //LcdWrCom(0x002C);
 
}
void LcdDispRGB(unsigned char x,unsigned char y)
{
 unsigned char i,j;
 LcdWrCom(0x2a);
 LcdWrData(0x04);
 LcdWrData(131);
 LcdWrCom(0x2b);
 LcdWrData(0x04);
 LcdWrData(131);
// LcdWrCom(0xb1);
// LcdWrData(0x02);
 LcdWrCom(0x2c);
 LCD_RS=1;
 LCD_WR=1;
 LCD_RD=1;


 for(i=0;i<128;i++)
 {
  for(j=0;j<128;j++)
  {
   LCD_BUS=x;
   LCD_WR=0;
   LCD_WR=1;
   LCD_BUS=y;
   LCD_WR=0;
   LCD_WR=1;


  }
 }


}
void LcdDispFull(unsigned char *p)
{
 unsigned char i,j;
 LcdWrCom(0x2a);
 LcdWrData(0x4);
 LcdWrData(131);
 LcdWrCom(0x2b);
 LcdWrData(0x04);
 LcdWrData(131);
 LcdWrCom(0x2c);
 LCD_RS=1;
 LCD_WR=1;
 LCD_RD=1;
 p++;
 p++;
 for(i=0;i<128;i++)
 {
  for(j=0;j<128;j++)
  {
   LCD_BUS=*p++;//y;
   LCD_WR=0;
   LCD_WR=1;
   LCD_BUS=*p++;//y;
   LCD_WR=0;
   LCD_WR=1;


  }
 }


}


3、 IC:NT7571


LCM:PH128128C


MCU:MCS-51


void delay(unsigned int x)
{
 unsigned int y;
 //y=x;
 //while(y--)
 for(y=0;y!=x;y++)
 {_nop_();}//x--;
}
void write_comm(unsigned char x)
{
 LCD_BUS_H=0xff;
 LCD_RS=0;
 LCD_WR=1;
 LCD_RD=1;
 LCD_BUS_L=x;
 LCD_WR=0;
 LCD_WR=1;
 LCD_RS=1;
}
/*
void LcdWrData(unsigned int x)
{
 LCD_RS=1;
 LCD_WR=1;
 LCD_RD=1;
 LCD_BUS_H=(unsigned char)((x&0xff00)>>8);
 LCD_BUS_L=(unsigned char)(x&0x00ff);
 LCD_WR=0;
 LCD_WR=1;


}
*/
void LcdInit(void)                  /* ????? */
{
    //// 80-8 bit
    //// Ext = 0
    delay(0xfff);
    LCD_RST=0;
    delay(0xfff);
    LCD_RST=1;
    LCD_WR=1;
    LCD_RD=1;
 LCD_CS=0;
 LCD_BUS_L=0x0ff;
 LCD_BUS_H=0xff;


    write_comm(0xf9);   //test mode command//
    write_comm(0x00);


    write_comm(0x02);   //OSC_MODE_SET//
    write_comm(0x00);


    write_comm(0x40);   //ENTRY_MODE_SET//
    write_comm(0x00);


    write_comm(0x2C);   //STANDBY_MODE_OFF//


    write_comm(0x02);   //OSC_MODE_SET//
    write_comm(0x01);


    write_comm(0x20);   //DC_DC_SELECT//
    write_comm(0x01);


    write_comm(0x24);   //DC_DC_CLK_DIV_SET//
    write_comm(0x00);


    write_comm(0x22);   //BIAS_SET
    write_comm(0x03);   //0x00 for 1/4bias ;(0x03)for 1/6 bias


    write_comm(0x26);   //DC_DC_AMP_SET//
    write_comm(0x01);
    delay(0x3fff);//20mS


    write_comm(0x26);   //DC_DC_AMP_SET//
    write_comm(0x09);
    delay(0x3fff);//100mS


    write_comm(0x26);   //DC_DC_AMP_SET//
    write_comm(0x0B);
    delay(0x3fff);//100mS


    write_comm(0x26);   //DC_DC_AMP_SET//
    write_comm(0x0F);
    delay(0x3fff);//20mS


    write_comm(0x2A);   //CONTRAST_CONTROL//
    write_comm(0xd0);   //c5


    write_comm(0x2B);   //CONTRAST_CONTROL2//
    write_comm(0x60);


    write_comm(0x10);   //DRIVER_OUT_SET//
    write_comm(0xb1);   //0x81:1/96 duty


    write_comm(0x34);   //N_BLOCK_INVERSION//
    write_comm(0x8D);


    write_comm(0x28);   //TEMP_COMP_SET//
    write_comm(0x01);


    write_comm(0x32);   //ROW_VECTOR_SET//
    write_comm(0x02);


 



    write_comm(0x30);   //ADDR_MODE_SET//
    write_comm(0x1A);


    write_comm(0x42);   //Y_ADDR_AREA_SET//
    write_comm(0x00);   //0x04
    write_comm(0x5f);   //0x83


    write_comm(0x43);   //X_ADDR_AREA_SET//
    write_comm(0x00);   //0x04
    write_comm(0x7f);   //0x83


    write_comm(0x51);   //DISPLAY_ON//


}
void DispFullRGB(unsigned char x,unsigned char y)
{
 unsigned char i,j;
 write_comm(0x42);   //Y_ADDR_AREA_SET//
    write_comm(0x00);   //0x04
    write_comm(0x7f);   //0x83


    write_comm(0x43);   //X_ADDR_AREA_SET//
    write_comm(0x04);   //0x04
    write_comm(0x83);   //0x83


   // write_comm()
   //i=128;
   //j=128;
   LCD_RS=1;
   LCD_RD=1;
   LCD_WR=1;
   LCD_BUS_L=0xff;
   LCD_BUS_H=0xff;
   //while(i--)
 for(i=0;i<128;i++)
   {
     //while(j--)
  for(j=0;j<128;j++)
  {
   //LCD_BUS_H=x;
   //LCD_BUS_L=y;
   LCD_BUS_L=x;
   LCD_WR=0;
   LCD_WR=1;
   LCD_BUS_L=y;
   LCD_WR=0;
   LCD_WR=1;
  }
   }



}
void DispFullPic(unsigned char *p)
{
 unsigned char i,j;
 write_comm(0x42);   //Y_ADDR_AREA_SET//
    write_comm(0x00);   //0x04
    write_comm(0x7f);   //0x83


    write_comm(0x43);   //X_ADDR_AREA_SET//
    write_comm(0x04);   //0x04
    write_comm(0x83);   //0x83


   // write_comm()
   //i=128;
   //j=128;
   LCD_RS=1;
   LCD_RD=1;
   LCD_WR=1;
   LCD_BUS_L=0xff;
   LCD_BUS_H=0xff;
   //while(i--)
 for(i=0;i<128;i++)
   {
     //while(j--)
  for(j=0;j<128;j++)
  {
   //LCD_BUS_H=x;
   //LCD_BUS_L=y;
   LCD_BUS_L=*p++;
   LCD_WR=0;
   LCD_WR=1;
   LCD_BUS_L=*p++;
   LCD_WR=0;
   LCD_WR=1;
  }
   }



}


4、 IC:NT7571


LCM:PH128128C


MCU:


void LcdWrCom(unsigned char x)
{
 /*ADPC=0x8;
 PM2=0x00;
 PU7=0x00;
 PM7=0x00;
 LCD_CS=0;*/
 LCD_RS=0;
 NOP();
 NOP();
 LCD_WR=1;
 LCD_RD=1;
 LCD_BUS=x;
 LCD_WR=0;
 LCD_WR=1;
// LCD_BUS=0xff;
 LCD_RS=1; 
 //LCD_CS=1;
}
/*
**-----------------------------------------------------------------------------
**
**  Abstract:
** Initial lcd.
**
**  Parameters:
** None
**
**  Returns:
** None
**
**-----------------------------------------------------------------------------
*/
//-----------
void LcdInit(void)
{
 PM2=0x00;
 PM7=0x00;
 LCD_BUS=0xff;
 PM0=0x00;
 ADPC=0x8;
 LCD_RST=0;
 delay(0x8fff);
 LCD_RST=1;
 delay(0xff);
 LCD_RD=1;
 LCD_WR=1;
 LCD_CS=0;
 LCD_RS=1;
 
 LcdWrCom(0xf9);   //test mode command//
    LcdWrCom(0x00);


    LcdWrCom(0x02);   //OSC_MODE_SET//
    LcdWrCom(0x00);


    LcdWrCom(0x40);   //ENTRY_MODE_SET//
  LcdWrCom(0x02);


    LcdWrCom(0x2C);   //STANDBY_MODE_OFF//
                           
    LcdWrCom(0x02);   //OSC_MODE_SET//
    LcdWrCom(0x01);


    LcdWrCom(0x20);   //DC_DC_SELECT//
    LcdWrCom(0x01);


    LcdWrCom(0x24);   //DC_DC_CLK_DIV_SET//
    LcdWrCom(0x00);


    LcdWrCom(0x22);   //BIAS_SET
    LcdWrCom(0x03);//0x00 for 1/4bias ;(0x03)for 1/6 bias


    LcdWrCom(0x26);//DC_DC_AMP_SET//
    LcdWrCom(0x01);
    delay(0x3fff);//20mS


    LcdWrCom(0x26);//DC_DC_AMP_SET//
    LcdWrCom(0x09);
    delay(0x3fff);//100mS


    LcdWrCom(0x26);   //DC_DC_AMP_SET//
    LcdWrCom(0x0B);
    delay(0x3fff);//100mS


    LcdWrCom(0x26);   //DC_DC_AMP_SET//
    LcdWrCom(0x0F);
    delay(0x3fff);//20mS


    LcdWrCom(0x2A);   //CONTRAST_CONTROL//
    LcdWrCom(0xd0);   //c5


    LcdWrCom(0x2B);   //CONTRAST_CONTROL2//
    LcdWrCom(0x60);


    LcdWrCom(0x10);   //DRIVER_OUT_SET//
    LcdWrCom(0xb1);   //0x81:1/96 duty


    LcdWrCom(0x34);   //N_BLOCK_INVERSION//
    LcdWrCom(0x8D);


    LcdWrCom(0x28);   //TEMP_COMP_SET//
    LcdWrCom(0x01);


    LcdWrCom(0x32);   //ROW_VECTOR_SET//
    LcdWrCom(0x02);
                                                                                                                                                                                                     
    LcdWrCom(0x30);   //ADDR_MODE_SET//
    LcdWrCom(0x1A);


    LcdWrCom(0x42);   //Y_ADDR_AREA_SET//
    LcdWrCom(0x00);   //0x04
    LcdWrCom(0x5f);   //0x83


    LcdWrCom(0x43);   //X_ADDR_AREA_SET//
    LcdWrCom(0x00);   //0x04
    LcdWrCom(0x7f);   //0x83


    LcdWrCom(0x51);   //DISPLAY_ON//
}



/*
**-----------------------------------------------------------------------------
**
**  Abstract:
** clear lcd .
**
**  Parameters:
** None
**
**  Returns:
** None
**
**-----------------------------------------------------------------------------
*/
void clear_select_window(unsigned char end_y, unsigned char colour_flag )
{
 unsigned char i,j;
 unsigned int RGB_val;
 PM2=0x00;
 PM7=0x00;
 LCD_BUS=0xff;
 PM0=0x00;
 ADPC=0x8;
 if( colour_flag == 0 )
  RGB_val = 0x0a0d;
 else
     if( colour_flag == 1 )
   RGB_val = 0x053e;
 LcdWrCom(0x42);                  //Column Range
 LcdWrCom(0x10);                //Start Address-4
 LcdWrCom(end_y-1);                //End Address-131
 LcdWrCom(0x43);
 LcdWrCom(ROW_OFFSET);
 LcdWrCom(127+ROW_OFFSET);
  
    LCD_RS=1;
    NOP();
    NOP();
    LCD_RD=1;
    LCD_WR=1;
    LCD_BUS=0xff;
   
 for(i=0;i<128;i++)
 {
  for(j=0;j<(end_y-0x10);j++)
  {
   LCD_BUS=(unsigned char)(RGB_val>>8);
   LCD_WR=0;
   LCD_WR=1;
   LCD_BUS=(unsigned char)RGB_val;
   LCD_WR=0;
   LCD_WR=1;
  }
 }
}

文章评论0条评论)

登录后参与讨论
我要评论
0
13
关闭 站长推荐上一条 /2 下一条