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;//¸′óÃêä3ö
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//íÆíìêä3ö
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;//100MHz
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//éÏà-
GPIO_Init(GPIOD, &GPIO_InitStructure);//3õê¼»ˉ
GPIO_InitStructure.GPIO_Pin = (0X1FF<<7);//PE7~15,AF OUT
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;//¸′óÃêä3ö
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//íÆíìêä3ö
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;//100MHz
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//éÏà-
GPIO_Init(GPIOE, &GPIO_InitStructure);//3õê¼»ˉ
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;//PD13,FSMC_A18
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;//¸′óÃêä3ö
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//íÆíìêä3ö
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;//100MHz
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//éÏà-
GPIO_Init(GPIOD, &GPIO_InitStructure);//3õê¼»ˉ
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; //μØÖ·½¨á¢ê±¼ä£¨ADDSET£©Îa16¸öHCLK 1/168M=6ns*16=96ns
readWriteTiming.FSMC_AddressHoldTime = 0x00; //μØÖ·±£3Ö걼䣨ADDHLD£©Ä£ê½AÎ′óÃμ½
readWriteTiming.FSMC_DataSetupTime = 60; //êy¾Y±£′æê±¼äÎa60¸öHCLK =6*60=360ns
readWriteTiming.FSMC_BusTurnAroundDuration = 0x00;
readWriteTiming.FSMC_CLKDivision = 0x00;
readWriteTiming.FSMC_DataLatency = 0x00;
readWriteTiming.FSMC_AccessMode = FSMC_AccessMode_A; //Ä£ê½A
writeTiming.FSMC_AddressSetupTime =9; //μØÖ·½¨á¢ê±¼ä£¨ADDSET£©Îa9¸öHCLK =54ns
writeTiming.FSMC_AddressHoldTime = 0x00; //μØÖ·±£3Ö걼䣨A
writeTiming.FSMC_DataSetupTime = 8; //êy¾Y±£′æê±¼äÎa6ns*9¸öHCLK=54ns
writeTiming.FSMC_BusTurnAroundDuration = 0x00;
writeTiming.FSMC_CLKDivision = 0x00;
writeTiming.FSMC_DataLatency = 0x00;
writeTiming.FSMC_AccessMode = FSMC_AccessMode_A; //Ä£ê½A
FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1;// ÕaàïÎòÃÇê1óÃNE1 £¬ò2¾í¶Ôó|BTCR[0],[1]¡£
FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable; // 2»¸′óÃêy¾YμØÖ·
FSMC_NORSRAMInitStructure.FSMC_MemoryType =FSMC_MemoryType_SRAM;// FSMC_MemoryType_SRAM; //SRAM
FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;//′æ′¢Æ÷êy¾Y¿í¶èÎ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; // ′æ′¢Æ÷D′ê1Äü
FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;
FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Enable; // ¶áD′ê1óÃ2»í¬μÄê±Dò
FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &readWriteTiming; //¶áD′ê±Dò
FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &writeTiming; //D′ê±Dò
FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure); //3õê¼»ˉFSMCÅäÖÃ
FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE); // ê1ÄüBANK1
delay_ms(50); // delay 50 ms
//3¢êÔ9341 IDμĶáè¡
LCD_WR_REG(0XD3);
lcddev.id=LCD_RD_DATA(); //dummy read
lcddev.id=LCD_RD_DATA(); //¶áμ½0X00
lcddev.id=LCD_RD_DATA(); //¶áè¡93
lcddev.id<<=8;
lcddev.id|=LCD_RD_DATA(); //¶áè¡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); //′òó¡LCD ID
}
else
{
printf("
LCD ID IS NOT 9341,PLEASE CONFIG IT AGAIN LCD ID:%x
",lcddev.id); //′òó¡LCD ID
}
}
这段程序在另外一款屏上 已经测试通过了。ID也是9341。
这款屏就是读不出ID, 触摸屏相关的硬件连接会不会对读取ID有影响啊?
一周热门 更多>