4.0寸86盒显示屏调试(三)

读取了个把星期也没读取出正确的ID号,最终放弃了读取,考虑是不是液晶屏根本没有输出功能。在使用SPI驱动以后,也没有显示白屏或者任何可以让人感觉驱动正确的现象。最终也放弃了在SPI上搞出个现象。转而使用RGB协议直驱,但还是没有结果,最后还是使用SPI初始化后,再使用RGB驱动一次,发现有一次闪屏。于是乎有以下结论:SPI驱动时序没有错,屏不能读取数据。

SPI的驱动函数段:

SPI相关头文件定义:

  /* DCX    ~ PD4  */ //--SDO
  /* SDA    ~ PD5  */
  /* SCL    ~ PD6  */
  /* CSB    ~ PD7  */
  /* RESET  ~ PD8  */
#define Lcd_DCX_Out(x) {x? GPIO_SetBits(GPIOD, GPIO_Pin_4):GPIO_ResetBits(GPIOD, GPIO_Pin_4);}  //DCX数据命令线

#define Lcd_SDA_Out(x) {x? GPIO_SetBits(GPIOD, GPIO_Pin_5):GPIO_ResetBits(GPIOD, GPIO_Pin_5);}  //SPI数据线

#define Lcd_SCL_Out(x) {x? GPIO_SetBits(GPIOD, GPIO_Pin_6):GPIO_ResetBits(GPIOD, GPIO_Pin_6);}  //SPI时钟线

#define Lcd_CSB_Out(x) {x? GPIO_SetBits(GPIOD, GPIO_Pin_7):GPIO_ResetBits(GPIOD, GPIO_Pin_7);}  //片选信号

#define Lcd_RST_Out(x) {x? GPIO_SetBits(GPIOD, GPIO_Pin_8):GPIO_ResetBits(GPIOD, GPIO_Pin_8);}  //复位信号 

#define Lcd_SDA_Read() GPIO_ReadInputDataBit(GPIOD, GPIO_Pin_5)

SPI源文件定义:

//SPI_IO口初始化
void Lcd_Spi_GPIO_Init(void)
{
    GPIO_InitTypeDef GPIO_InitStructure;
  
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD, ENABLE);    
  /* DCX    ~ PD4  */
  /* SDA    ~ PD5  */
  /* SCL    ~ PD6  */
  /* CSB    ~ PD7  */
  /* RESET  ~ PD8  */
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;  //复用推挽输出
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init(GPIOD, &GPIO_InitStructure);
  
  Lcd_DCX_Out(1);
  Lcd_CSB_Out(1);
  Lcd_SCL_Out(1);
  Lcd_SDA_Out(1);
  Lcd_RST_Out(1);
}

/****************************************************************/
void Lcd_Spi_Senddata(uint8_t dat)
{
  uint8_t i;
  
  for(i=0; i<8; i++)
  {
    Lcd_SCL_Out(0);    
    if(dat&0x80)
    {
      Lcd_SDA_Out(1);
    }
    else
    {
      Lcd_SDA_Out(0);
    }     
    Lcd_SCL_Out(1);
    dat <<= 1;
  }
}


void Lcd_Spi_Writecmd(uint8_t cmd)
{
  Lcd_CSB_Out(0);
  Lcd_DCX_Out(0);
  
  Lcd_Spi_Senddata(cmd);
  
  Lcd_CSB_Out(1);
}

/***************************************************************/
void Lcd_Spi_Writedata(uint8_t data)
{
  Lcd_CSB_Out(0);
  Lcd_DCX_Out(1);
  
  Lcd_Spi_Senddata(data);
  
  Lcd_CSB_Out(1);
}

/**********************LCD***************************/
void Lcd_Spi_Init(void)
{
  Lcd_Reset();

  //***************************************************************//LCD SETING
  Lcd_Spi_Writecmd(0x11);
  delay_ms(120);
  
  //PAGE0 1
  Lcd_Spi_Writecmd(0xFF); 
  Lcd_Spi_Writedata(0x77);
  Lcd_Spi_Writedata(0x01);
  Lcd_Spi_Writedata(0x00);
  Lcd_Spi_Writedata(0x00);
  Lcd_Spi_Writedata(0x10);

  Lcd_Spi_Writecmd(0xC0);//Display Line Setting 
  Lcd_Spi_Writedata(0x3B);
  Lcd_Spi_Writedata(0x00);

  Lcd_Spi_Writecmd(0xC1);//Porch Control   
  Lcd_Spi_Writedata(0x0D);
  Lcd_Spi_Writedata(0x02);

  Lcd_Spi_Writecmd(0xC2);// Inversion set
  Lcd_Spi_Writedata(0x37);//31 2-DOT 37-Column
  Lcd_Spi_Writedata(0x05);

  Lcd_Spi_Writecmd(0xC3); //SET RGB MODE
  Lcd_Spi_Writedata(0x02); //00-DE MODE ,80-HV MODE     PCLK N
  Lcd_Spi_Writedata(0x00);
  Lcd_Spi_Writedata(0x00);

  Lcd_Spi_Writecmd(0xB0);    
  Lcd_Spi_Writedata(0x00); //Positive Voltage Gamma Control
  Lcd_Spi_Writedata(0x11);
  Lcd_Spi_Writedata(0x18);
  Lcd_Spi_Writedata(0x0E);
  Lcd_Spi_Writedata(0x11);
  Lcd_Spi_Writedata(0x06);
  Lcd_Spi_Writedata(0x07);
  Lcd_Spi_Writedata(0x08);
  Lcd_Spi_Writedata(0x07);
  Lcd_Spi_Writedata(0x22);
  Lcd_Spi_Writedata(0x04);
  Lcd_Spi_Writedata(0x12);
  Lcd_Spi_Writedata(0x0F);
  Lcd_Spi_Writedata(0xAA);
  Lcd_Spi_Writedata(0x31);
  Lcd_Spi_Writedata(0x18);


  Lcd_Spi_Writecmd(0xB1);   
  Lcd_Spi_Writedata(0x00); //Negative Voltage Gamma Control
  Lcd_Spi_Writedata(0x11);
  Lcd_Spi_Writedata(0x19);
  Lcd_Spi_Writedata(0x0E);
  Lcd_Spi_Writedata(0x12);
  Lcd_Spi_Writedata(0x07);
  Lcd_Spi_Writedata(0x08);
  Lcd_Spi_Writedata(0x08);
  Lcd_Spi_Writedata(0x08);
  Lcd_Spi_Writedata(0x22);
  Lcd_Spi_Writedata(0x04);
  Lcd_Spi_Writedata(0x11);
  Lcd_Spi_Writedata(0x11);
  Lcd_Spi_Writedata(0xA9);
  Lcd_Spi_Writedata(0x32);
  Lcd_Spi_Writedata(0x18);

  //*******power set********//
  //PAGE2
  Lcd_Spi_Writecmd(0xFF);    
  Lcd_Spi_Writedata(0x77);
  Lcd_Spi_Writedata(0x01);
  Lcd_Spi_Writedata(0x00);
  Lcd_Spi_Writedata(0x00);
  Lcd_Spi_Writedata(0x11);

  Lcd_Spi_Writecmd(0xB0);//Vop Amplitude setting
  Lcd_Spi_Writedata(0x60); //Vop=4.7375v

  Lcd_Spi_Writecmd(0xB1); //VCOM amplitude setting 
  Lcd_Spi_Writedata(0x26); //VCOM=32

  Lcd_Spi_Writecmd(0xB2); //VGH Voltage setting  
  Lcd_Spi_Writedata(0x07); //VGH=15v

  Lcd_Spi_Writecmd(0xB3); //TEST Command Setting  
  Lcd_Spi_Writedata(0x80);

  Lcd_Spi_Writecmd(0xB5); //VGL Voltage setting   
  Lcd_Spi_Writedata(0x49); //VGL=-10.17v

  Lcd_Spi_Writecmd(0xB7);//Power Control 1    
  Lcd_Spi_Writedata(0x85);

  Lcd_Spi_Writecmd(0xB8); //Power Control 2  
  Lcd_Spi_Writedata(0x21); //AVDD=6.6 & AVCL=-4.6

  Lcd_Spi_Writecmd(0xC1);//Source pre_drive timing set1    
  Lcd_Spi_Writedata(0x78);

  Lcd_Spi_Writecmd(0xC2);//Source EQ2 Setting    
  Lcd_Spi_Writedata(0x78);
  //*********GIP SET*************//
  Lcd_Spi_Writecmd(0xE0);    
  Lcd_Spi_Writedata(0x00);
  Lcd_Spi_Writedata(0x1B);
  Lcd_Spi_Writedata(0x02);

  Lcd_Spi_Writecmd(0xE1);   
  Lcd_Spi_Writedata(0x08);
  Lcd_Spi_Writedata(0xA0);
  Lcd_Spi_Writedata(0x00);
  Lcd_Spi_Writedata(0x00);
  Lcd_Spi_Writedata(0x07);
  Lcd_Spi_Writedata(0xA0);
  Lcd_Spi_Writedata(0x00);
  Lcd_Spi_Writedata(0x00);
  Lcd_Spi_Writedata(0x00);
  Lcd_Spi_Writedata(0x44);
  Lcd_Spi_Writedata(0x44);

  Lcd_Spi_Writecmd(0xE2);   
  Lcd_Spi_Writedata(0x11);
  Lcd_Spi_Writedata(0x11);
  Lcd_Spi_Writedata(0x44);
  Lcd_Spi_Writedata(0x44);
  Lcd_Spi_Writedata(0xED);
  Lcd_Spi_Writedata(0xA0);
  Lcd_Spi_Writedata(0x00);
  Lcd_Spi_Writedata(0x00);
  Lcd_Spi_Writedata(0xEC);
  Lcd_Spi_Writedata(0xA0);
  Lcd_Spi_Writedata(0x00);
  Lcd_Spi_Writedata(0x00);

  Lcd_Spi_Writecmd(0xE3);    
  Lcd_Spi_Writedata(0x00);
  Lcd_Spi_Writedata(0x00);
  Lcd_Spi_Writedata(0x11);
  Lcd_Spi_Writedata(0x11);

  Lcd_Spi_Writecmd(0xE4);    
  Lcd_Spi_Writedata(0x44);
  Lcd_Spi_Writedata(0x44);

  Lcd_Spi_Writecmd(0xE5);    
  Lcd_Spi_Writedata(0x0A);
  Lcd_Spi_Writedata(0xE9);
  Lcd_Spi_Writedata(0xD8);
  Lcd_Spi_Writedata(0xA0);
  Lcd_Spi_Writedata(0x0C);
  Lcd_Spi_Writedata(0xEB);
  Lcd_Spi_Writedata(0xD8);
  Lcd_Spi_Writedata(0xA0);
  Lcd_Spi_Writedata(0x0E);
  Lcd_Spi_Writedata(0xED);
  Lcd_Spi_Writedata(0xD8);
  Lcd_Spi_Writedata(0xA0);
  Lcd_Spi_Writedata(0x10);
  Lcd_Spi_Writedata(0xEF);
  Lcd_Spi_Writedata(0xD8);
  Lcd_Spi_Writedata(0xA0);

  Lcd_Spi_Writecmd(0xE6);    
  Lcd_Spi_Writedata(0x00);
  Lcd_Spi_Writedata(0x00);
  Lcd_Spi_Writedata(0x11);
  Lcd_Spi_Writedata(0x11);

  Lcd_Spi_Writecmd(0xE7);    
  Lcd_Spi_Writedata(0x44);
  Lcd_Spi_Writedata(0x44);

  Lcd_Spi_Writecmd(0xE8);   
  Lcd_Spi_Writedata(0x09);
  Lcd_Spi_Writedata(0xE8);
  Lcd_Spi_Writedata(0xD8);
  Lcd_Spi_Writedata(0xA0);
  Lcd_Spi_Writedata(0x0B);
  Lcd_Spi_Writedata(0xEA);
  Lcd_Spi_Writedata(0xD8);
  Lcd_Spi_Writedata(0xA0);
  Lcd_Spi_Writedata(0x0D);
  Lcd_Spi_Writedata(0xEC);
  Lcd_Spi_Writedata(0xD8);
  Lcd_Spi_Writedata(0xA0);
  Lcd_Spi_Writedata(0x0F);
  Lcd_Spi_Writedata(0xEE);
  Lcd_Spi_Writedata(0xD8);
  Lcd_Spi_Writedata(0xA0);
   
  Lcd_Spi_Writecmd(0xEB);   
  Lcd_Spi_Writedata(0x02);
  Lcd_Spi_Writedata(0x00);
  Lcd_Spi_Writedata(0xE4);
  Lcd_Spi_Writedata(0xE4);
  Lcd_Spi_Writedata(0x88);
  Lcd_Spi_Writedata(0x00);
  Lcd_Spi_Writedata(0x40);

  Lcd_Spi_Writecmd(0xEC);    
  Lcd_Spi_Writedata(0x3C);
  Lcd_Spi_Writedata(0x00);

  Lcd_Spi_Writecmd(0xED);    
  Lcd_Spi_Writedata(0xAB);
  Lcd_Spi_Writedata(0x89);
  Lcd_Spi_Writedata(0x76);
  Lcd_Spi_Writedata(0x54);
  Lcd_Spi_Writedata(0x02);
  Lcd_Spi_Writedata(0xFF);
  Lcd_Spi_Writedata(0xFF);
  Lcd_Spi_Writedata(0xFF);
  Lcd_Spi_Writedata(0xFF);
  Lcd_Spi_Writedata(0xFF);
  Lcd_Spi_Writedata(0xFF);
  Lcd_Spi_Writedata(0x20);
  Lcd_Spi_Writedata(0x45);
  Lcd_Spi_Writedata(0x67);
  Lcd_Spi_Writedata(0x98);
  Lcd_Spi_Writedata(0xBA);

  //-----------VAP & VAN---------------
  Lcd_Spi_Writecmd(0xFF);    
  Lcd_Spi_Writedata(0x77);
  Lcd_Spi_Writedata(0x01);
  Lcd_Spi_Writedata(0x00);
  Lcd_Spi_Writedata(0x00);
  Lcd_Spi_Writedata(0x13);

  Lcd_Spi_Writecmd(0xE5);    
  Lcd_Spi_Writedata(0xE4);
   
  Lcd_Spi_Writecmd(0xFF);//page     
  Lcd_Spi_Writedata(0x77);
  Lcd_Spi_Writedata(0x01);   
  Lcd_Spi_Writedata(0x00);
  Lcd_Spi_Writedata(0x00);   
  Lcd_Spi_Writedata(0x00);
    
  Lcd_Spi_Writecmd(0x36); 
  Lcd_Spi_Writedata(0x00); //10-180

  Lcd_Spi_Writecmd(0x3A); 
  Lcd_Spi_Writedata(0x70); //RGB888 24bit

  //Display on
  Lcd_Spi_Writecmd(0x29);                     
  delay_ms(25);
}

使用以上函数,可以初始化屏幕,但屏幕并不会有任何显示。这点和之前的MCU接口的TFT、LCD不一样。也不知道其他RGB屏是不是也是这个样。

下面需要使用RGB的数据协议,但ST7701S的手册上关于RGB的时序只有以下:

4.0寸86盒显示屏调试(三)_第1张图片

以上是DE模式的时序图,但除了时序图基本上就没有啥了,按照这个时序图,简单的写了一个时序。

时序是错误的,除了能闪一下屏就没啥现象了,所以暂时不贴代码了。下一章调试出结果后继续。

 

 

你可能感兴趣的:(显示屏,ST7701S,4.0寸RGB显示屏)