打印
[STM32]

STM32f4 TFTLCD显示实验代码(04)

[复制链接]
858|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
小乐Tzz|  楼主 | 2018-9-11 13:48 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
STM32f4————TFTLCD显示实验代码(04)
/*******************************************************/
   //③  引脚复用映射设置
   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_PinSource8,GPIO_AF_FSMC);   
   GPIO_PinAFConfig(GPIOD,GPIO_PinSource9,GPIO_AF_FSMC);
   GPIO_PinAFConfig(GPIOD,GPIO_PinSource10,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
   
   GPIO_PinAFConfig(GPIOF,GPIO_PinSource12,GPIO_AF_FSMC);//PF12,AF12
   GPIO_PinAFConfig(GPIOG,GPIO_PinSource12,GPIO_AF_FSMC);

   //④FSMC 初始化
   readWriteTiming.FSMC_AddressSetupTime = 0XF; //地址建立时间为16个HCLK
   readWriteTiming.FSMC_AddressHoldTime = 0x00;    //地址保持时间模式A 未用到   
   readWriteTiming.FSMC_DataSetupTime = 24;//数据保存时间为25个HCLK   
   readWriteTiming.FSMC_BusTurnAroundDuration = 0x00;
   readWriteTiming.FSMC_CLKDivision = 0x00;
   readWriteTiming.FSMC_DataLatency = 0x00;
   readWriteTiming.FSMC_AccessMode = FSMC_AccessMode_A;    //模式 A   
      
writeTiming.FSMC_AddressSetupTime =8;    //地址建立时间(ADDSET)为 8个 HCLK   
   writeTiming.FSMC_AddressHoldTime = 0x00; //地址保持时间     
   writeTiming.FSMC_DataSetupTime = 8;    //数据保存时间为6ns*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_NORSRAM4;
//这里我们使用NE4 ,也就对应BTCR[6],[7]。
   FSMC_NORSRAMInitStructure.FSMC_DataAddressMux   
=FSMC_DataAddressMux_Disable; // 不复用数据地址
   FSMC_NORSRAMInitStructure.FSMC_MemoryType =FSMC_MemoryType_SRAM;
// FSMC_MemoryType_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
   FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM4, ENABLE);  //  使能BANK1
delay_ms(50); // delay 50 ms   
   lcddev.id = LCD_ReadReg(0x0000);
/*******************************************************/


相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

70

主题

70

帖子

0

粉丝