单片机
返回首页

STM32f4---TFTLCD显示实验代码(04)

2018-09-29 来源:eefocus

   //  引脚复用映射设置

   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);


进入单片机查看更多内容>>
相关视频
  • RISC-V嵌入式系统开发

  • SOC系统级芯片设计实验

  • 云龙51单片机实训视频教程(王云,字幕版)

  • 2022 Digi-Key KOL 系列: 你见过1GHz主频的单片机吗?Teensy 4.1开发板介绍

  • TI 新一代 C2000™ 微控制器:全方位助力伺服及马达驱动应用

  • MSP430电容触摸技术 - 防水Demo演示

精选电路图
  • 家用电源无载自动断电装置的设计与制作

  • PIC单片机控制的遥控防盗报警器电路

  • 短波AM发射器电路设计图

  • 使用ESP8266从NTP服务器获取时间并在OLED显示器上显示

  • 如何构建一个触摸传感器电路

  • 基于TDA2003的简单低功耗汽车立体声放大器电路

    相关电子头条文章