关于购买的战舰3.5寸触摸屏 显示问题

2019-07-20 21:23发布

file:///C:UserschenxiangAppDataRoamingTencentUsers871904663QQWinTempRichOleP4Q6%$EB]@{{}RSA~I@{B%G.png购买了一块战舰3.5寸触摸屏,使用STM32F407ZGT6驱动,电路图见图片, 没有用触摸屏的触摸功能。

相应配置程序如下,结果打印ID为0,就是没有读出驱动ID,不知道什么原因,求大神解答。

void LCD_Init(void)
{        
        vu32 i=0;
       
  GPIO_InitTypeDef  GPIO_InitStructure;
        FSMC_NORSRAMInitTypeDef  FSMC_NORSRAMInitStructure;
  FSMC_NORSRAMTimingInitTypeDef  readWriteTiming;
        FSMC_NORSRAMTimingInitTypeDef  writeTiming;
       
        RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD|RCC_AHB1Periph_GPIOE, ENABLE);//ê1ÄüPD,PEê±Öó  
  RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FSMC,ENABLE);//ê1ÄüFSMCê±Öó  
       
  GPIO_InitStructure.GPIO_Pin = (3<<0)|(3<<4)|(15<<7)|(3<<14);//PD0,1,4,5,7,8,9,10,12,14,15 AF OUT
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;//&#184;′ó&#195;ê&#228;3&#246;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//í&#198;íìê&#228;3&#246;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;//100MHz
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//é&#207;à-
  GPIO_Init(GPIOD, &GPIO_InitStructure);//3&#245;ê&#188;&#187;ˉ  
       
  GPIO_InitStructure.GPIO_Pin = (0X1FF<<7);//PE7~15,AF OUT
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;//&#184;′ó&#195;ê&#228;3&#246;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//í&#198;íìê&#228;3&#246;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;//100MHz
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//é&#207;à-
  GPIO_Init(GPIOE, &GPIO_InitStructure);//3&#245;ê&#188;&#187;ˉ  

        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;//PD13,FSMC_A18
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;//&#184;′ó&#195;ê&#228;3&#246;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//í&#198;íìê&#228;3&#246;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;//100MHz
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//é&#207;à-
  GPIO_Init(GPIOD, &GPIO_InitStructure);//3&#245;ê&#188;&#187;ˉ  


  GPIO_PinAFConfig(GPIOD,GPIO_PinSource0,GPIO_AF_FSMC);//PD0,AF12
  GPIO_PinAFConfig(GPIOD,GPIO_PinSource1,GPIO_AF_FSMC);//PD1,AF12
  GPIO_PinAFConfig(GPIOD,GPIO_PinSource4,GPIO_AF_FSMC);
  GPIO_PinAFConfig(GPIOD,GPIO_PinSource5,GPIO_AF_FSMC);
        GPIO_PinAFConfig(GPIOD,GPIO_PinSource7,GPIO_AF_FSMC);
  GPIO_PinAFConfig(GPIOD,GPIO_PinSource8,GPIO_AF_FSMC);
  GPIO_PinAFConfig(GPIOD,GPIO_PinSource9,GPIO_AF_FSMC);
  GPIO_PinAFConfig(GPIOD,GPIO_PinSource10,GPIO_AF_FSMC);
        GPIO_PinAFConfig(GPIOD,GPIO_PinSource13,GPIO_AF_FSMC);
  GPIO_PinAFConfig(GPIOD,GPIO_PinSource14,GPIO_AF_FSMC);
  GPIO_PinAFConfig(GPIOD,GPIO_PinSource15,GPIO_AF_FSMC);//PD15,AF12

  GPIO_PinAFConfig(GPIOE,GPIO_PinSource7,GPIO_AF_FSMC);//PE7,AF12
  GPIO_PinAFConfig(GPIOE,GPIO_PinSource8,GPIO_AF_FSMC);
  GPIO_PinAFConfig(GPIOE,GPIO_PinSource9,GPIO_AF_FSMC);
  GPIO_PinAFConfig(GPIOE,GPIO_PinSource10,GPIO_AF_FSMC);
  GPIO_PinAFConfig(GPIOE,GPIO_PinSource11,GPIO_AF_FSMC);
  GPIO_PinAFConfig(GPIOE,GPIO_PinSource12,GPIO_AF_FSMC);
  GPIO_PinAFConfig(GPIOE,GPIO_PinSource13,GPIO_AF_FSMC);
  GPIO_PinAFConfig(GPIOE,GPIO_PinSource14,GPIO_AF_FSMC);
  GPIO_PinAFConfig(GPIOE,GPIO_PinSource15,GPIO_AF_FSMC);//PE15,AF12


  readWriteTiming.FSMC_AddressSetupTime = 0XF;         //μ&#216;&#214;·&#189;¨á¢ê±&#188;&#228;£¨ADDSET£&#169;&#206;a16&#184;&#246;HCLK 1/168M=6ns*16=96ns       
  readWriteTiming.FSMC_AddressHoldTime = 0x00;         //μ&#216;&#214;·±£3&#214;ê±&#188;&#228;£¨ADDHLD£&#169;&#196;£ê&#189;A&#206;′ó&#195;μ&#189;       
  readWriteTiming.FSMC_DataSetupTime = 60;                        //êy&#190;Y±£′&#230;ê±&#188;&#228;&#206;a60&#184;&#246;HCLK        =6*60=360ns
  readWriteTiming.FSMC_BusTurnAroundDuration = 0x00;
  readWriteTiming.FSMC_CLKDivision = 0x00;
  readWriteTiming.FSMC_DataLatency = 0x00;
  readWriteTiming.FSMC_AccessMode = FSMC_AccessMode_A;         //&#196;£ê&#189;A


        writeTiming.FSMC_AddressSetupTime =9;              //μ&#216;&#214;·&#189;¨á¢ê±&#188;&#228;£¨ADDSET£&#169;&#206;a9&#184;&#246;HCLK =54ns
  writeTiming.FSMC_AddressHoldTime = 0x00;         //μ&#216;&#214;·±£3&#214;ê±&#188;&#228;£¨A               
  writeTiming.FSMC_DataSetupTime = 8;                 //êy&#190;Y±£′&#230;ê±&#188;&#228;&#206;a6ns*9&#184;&#246;HCLK=54ns
  writeTiming.FSMC_BusTurnAroundDuration = 0x00;
  writeTiming.FSMC_CLKDivision = 0x00;
  writeTiming.FSMC_DataLatency = 0x00;
  writeTiming.FSMC_AccessMode = FSMC_AccessMode_A;         //&#196;£ê&#189;A


  FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1;//  &#213;aà&#239;&#206;ò&#195;&#199;ê1ó&#195;NE1 £&#172;ò2&#190;í&#182;&#212;ó|BTCR[0],[1]&#161;£
  FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable; // 2&#187;&#184;′ó&#195;êy&#190;Yμ&#216;&#214;·
  FSMC_NORSRAMInitStructure.FSMC_MemoryType =FSMC_MemoryType_SRAM;// FSMC_MemoryType_SRAM;  //SRAM   
  FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;//′&#230;′¢&#198;÷êy&#190;Y&#191;í&#182;è&#206;a16bit   
  FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode =FSMC_BurstAccessMode_Disable;// FSMC_BurstAccessMode_Disable;
  FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
        FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait=FSMC_AsynchronousWait_Disable;
  FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;   
  FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;  
  FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable;        //  ′&#230;′¢&#198;÷D′ê1&#196;ü
  FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;   
  FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Enable; // &#182;áD′ê1ó&#195;2&#187;í&#172;μ&#196;ê±Dò
  FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
  FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &readWriteTiming; //&#182;áD′ê±Dò
  FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &writeTiming;  //D′ê±Dò

  FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure);  //3&#245;ê&#188;&#187;ˉFSMC&#197;&#228;&#214;&#195;

  FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE);  // ê1&#196;üBANK1
               
        delay_ms(50); // delay 50 ms


                //3¢ê&#212;9341 IDμ&#196;&#182;áè&#161;

        LCD_WR_REG(0XD3);                                  
        lcddev.id=LCD_RD_DATA();        //dummy read        
        lcddev.id=LCD_RD_DATA();        //&#182;áμ&#189;0X00
  lcddev.id=LCD_RD_DATA();           //&#182;áè&#161;93                                                                  
        lcddev.id<<=8;
        lcddev.id|=LCD_RD_DATA();          //&#182;áè&#161;41
        delay_ms(50);
  if(lcddev.id==0x9341)
  {       
    lcddev.dir=0;
    lcddev.wramcmd=0x2C;
    lcddev.setxcmd=0x2B;
    lcddev.setycmd=0x2A;
    lcddev.height=280;
    lcddev.width=320;
          //printf(" LCD ID:%x ",lcddev.id); //′òó&#161;LCD ID
  }       
        else
        {
                printf(" LCD ID IS NOT 9341,PLEASE CONFIG IT AGAIN LCD ID:%x ",lcddev.id); //′òó&#161;LCD ID
        }
}

友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
6条回答
正点原子
1楼-- · 2019-07-21 03:08
kepter 发表于 2016-7-4 12:52
这段程序在另外一款屏上 已经测试通过了。ID也是9341。
这款屏就是读不出ID, 触摸屏相关的硬件连接会 ...

不会,只要你接线对了,而且代码正常,就应该可以读取ID的
taizonglai
2楼-- · 2019-07-21 05:31
 精彩回答 2  元偷偷看……
kepter
3楼-- · 2019-07-21 10:40
哪些引脚定义?

正点原子
4楼-- · 2019-07-21 15:08
kepter 发表于 2016-6-24 15:05
哪些引脚定义?

与LCD相关的
kepter
5楼-- · 2019-07-21 19:16
 精彩回答 2  元偷偷看……
kepter
6楼-- · 2019-07-22 00:44
正点原子 发表于 2016-7-2 23:56
与LCD相关的

这段程序在另外一款屏上 已经测试通过了。ID也是9341。
这款屏就是读不出ID, 触摸屏相关的硬件连接会不会对读取ID有影响啊?

一周热门 更多>