根据原子旗舰版TFT初始化移植到F407上初始化不成功

2019-07-21 05:06发布

我使用的是NE1,初始化配置如下,
void LCD_Init(void)
{            
 GPIO_InitTypeDef GPIO_InitStructure;
 FSMC_NORSRAMInitTypeDef  FSMC_NORSRAMInitStructure;
 FSMC_NORSRAMTimingInitTypeDef  readWriteTiming;
 FSMC_NORSRAMTimingInitTypeDef  writeTiming;  
  RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FSMC,ENABLE); //使能FSMC时钟    RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA,ENABLE);
   RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB,ENABLE);
   RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC,ENABLE);
   RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD,ENABLE);
   RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE,ENABLE);
   RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOF,ENABLE);
   RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOG,ENABLE);//使能PORTA,B,C,D,E,F,G时钟
  GPIO_PinAFConfig(GPIOD,GPIO_PinSource14,GPIO_AF_FSMC);                 //FSMC_D0
 GPIO_PinAFConfig(GPIOD,GPIO_PinSource15,GPIO_AF_FSMC);                 //FSMC_D1
 GPIO_PinAFConfig(GPIOD,GPIO_PinSource0,GPIO_AF_FSMC);                  //FSMC_D2
 GPIO_PinAFConfig(GPIOD,GPIO_PinSource1,GPIO_AF_FSMC);                  //FSMC_D3
 GPIO_PinAFConfig(GPIOE,GPIO_PinSource7,GPIO_AF_FSMC);                  //FSMC_D4
 GPIO_PinAFConfig(GPIOE,GPIO_PinSource8,GPIO_AF_FSMC);                  //FSMC_D5
 GPIO_PinAFConfig(GPIOE,GPIO_PinSource9,GPIO_AF_FSMC);                  //FSMC_D6
 GPIO_PinAFConfig(GPIOE,GPIO_PinSource10,GPIO_AF_FSMC);                 //FSMC_D7
 GPIO_PinAFConfig(GPIOE,GPIO_PinSource11,GPIO_AF_FSMC);                 //FSMC_D8
 GPIO_PinAFConfig(GPIOE,GPIO_PinSource12,GPIO_AF_FSMC);                 //FSMC_D9
 GPIO_PinAFConfig(GPIOE,GPIO_PinSource13,GPIO_AF_FSMC);                 //FSMC_D10
 GPIO_PinAFConfig(GPIOE,GPIO_PinSource14,GPIO_AF_FSMC);                 //FSMC_D11
 GPIO_PinAFConfig(GPIOE,GPIO_PinSource15,GPIO_AF_FSMC);                 //FSMC_D12
 GPIO_PinAFConfig(GPIOD,GPIO_PinSource8,GPIO_AF_FSMC);                  //FSMC_D13
 GPIO_PinAFConfig(GPIOD,GPIO_PinSource9,GPIO_AF_FSMC);                  //FSMC_D14
 GPIO_PinAFConfig(GPIOD,GPIO_PinSource10,GPIO_AF_FSMC);                 //FSMC_D15
 GPIO_PinAFConfig(GPIOD,GPIO_PinSource7,GPIO_AF_FSMC);                  //FSMC_NE1
 GPIO_PinAFConfig(GPIOD,GPIO_PinSource13,GPIO_AF_FSMC);                 //FSMC_A18
 GPIO_PinAFConfig(GPIOD,GPIO_PinSource5,GPIO_AF_FSMC);                  //FSMC_NWE
 GPIO_PinAFConfig(GPIOD,GPIO_PinSource4,GPIO_AF_FSMC);                  //FSMC_NOE
 
 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 |GPIO_Pin_1 |GPIO_Pin_4 |GPIO_Pin_5 |GPIO_Pin_7 |GPIO_Pin_8 |GPIO_Pin_9 |GPIO_Pin_10 |GPIO_Pin_13 |GPIO_Pin_14 | GPIO_Pin_15;
 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
 GPIO_Init(GPIOD, &GPIO_InitStructure);                  //配置FSMC口   
                              
 
 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 |GPIO_Pin_8 |GPIO_Pin_9 |GPIO_Pin_10 |GPIO_Pin_12 |GPIO_Pin_13 |GPIO_Pin_14 | GPIO_Pin_15;
 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
 GPIO_Init(GPIOE, &GPIO_InitStructure);                                  //配置FSMC口    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
   GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
   GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
   GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
   GPIO_Init(GPIOC, &GPIO_InitStructure);                   //LCD_BL口(LCD背光控制)
    
   readWriteTiming.FSMC_AddressSetupTime = 0x0f;          //地址建立时间(ADDSET)
    readWriteTiming.FSMC_AddressHoldTime = 0x00;          //地址保持时间(ADDHLD)模式A未用到 
    readWriteTiming.FSMC_DataSetupTime = 0xff;           //数据保存时间
    readWriteTiming.FSMC_BusTurnAroundDuration = 0x00;
    readWriteTiming.FSMC_CLKDivision = 0x00;
    readWriteTiming.FSMC_DataLatency = 0x00;
    readWriteTiming.FSMC_AccessMode = FSMC_AccessMode_A;  //模式A
       writeTiming.FSMC_AddressSetupTime = 0x0f;              //地址建立时间(ADDSET)
    writeTiming.FSMC_AddressHoldTime = 0x00;              //地址保持时间 
    writeTiming.FSMC_DataSetupTime = 0x0f;               //数据保存时间
    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;//  这里我们使用NE1 ,也就对应BTCR[0],[1]。
    FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable; // 不复用数据地址
    FSMC_NORSRAMInitStructure.FSMC_MemoryType =FSMC_MemoryType_SRAM;// FSMC_MemoryType_SRAM;  //SRAM  
    FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;//存储器数据宽度为16bit  
    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; //  存储器写使能
    FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;  
    FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Enable; // 使能扩展模式
    FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
    FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &readWriteTiming; //读写时序
    FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &writeTiming;  //写时序     FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure);  //初始化FSMC配置     FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE);  // 使能BANK1


我LCD_BASE定义如下 
#define LCD_BASE        ((u32)(0x60000000 | 0x0007FFFE))
   因为用NE1,所以HADDR[27,26]=00,我用A18作为命令数据区分线


感觉我的初始化配置没什么问题,为了能成功读出DI,我把地址建立时间和数据保持时间都加大了不少,读ID和初始化命令都是移植原子的,发现初始化没成功
   我用jtag跟踪了下,最后LCD_Clear(RED);这个指令执行了,可是屏幕没有变 {MOD}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
9条回答
正点原子
1楼-- · 2019-07-21 18:47
回复【7楼】颓废ю小寶:
---------------------------------
你下载我们mini板例程,然后按复位,串口就会输出一次LCD ID的.
颓废ю小寶
2楼-- · 2019-07-22 00:20
 精彩回答 2  元偷偷看……
正点原子
3楼-- · 2019-07-22 06:12
回复【9楼】颓废ю小寶:
---------------------------------
把写时序搞慢点试试.

一周热门 更多>