野火电子论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 10952|回复: 0

FSMC挂起TFT

[复制链接]
发表于 2014-12-21 22:53:17 | 显示全部楼层 |阅读模式
求救:我自己弄的FSMC挂起TFT的时候,配置有没有错  
void LCD_GPIO_Config( void )
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_AHBPeriphClockCmd( RCC_AHBPeriph_FSMC, ENABLE );//使能FSMC时钟
RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE , ENABLE );//使能FSMC对应相应管脚时钟
   
  /* FSMC数据线PD:0 1 8 9 10 14 15   PE:7 8 9 10 11 12 13 14 15*/
GPIO_InitStructure.GPIO_Mode =  GPIO_Mode_AF_PP;//复用推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_14 | GPIO_Pin_15;
GPIO_Init( GPIOD, &GPIO_InitStructure );
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 |  GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;
GPIO_Init( GPIOE, &GPIO_InitStructure );
  /*
  FSMC_NOE : PD4 : LCD_RD
  FSMC_NWE : PD5 : LCD_WR
  FSMC_NE1 : PD7 : LCD_CS
  FSMC_A23 : PE2 : LCD_RS
  */
GPIO_InitStructure.GPIO_Mode =  GPIO_Mode_AF_PP;//复用推挽输出
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5 |GPIO_Pin_7;
GPIO_Init( GPIOD, &GPIO_InitStructure );
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
GPIO_Init( GPIOE, &GPIO_InitStructure );
  /*
  LCD背光 : PD3
  LCD复位 : PE0
  */
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;//通用推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;//LCD背光
GPIO_Init( GPIOD, &GPIO_InitStructure );
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;//LCD复位
GPIO_Init( GPIOE, &GPIO_InitStructure );
  /* 开背光 */
GPIO_ResetBits( GPIOD , GPIO_Pin_3 ) ;
}
/*
初始化FSMC外设
*/
void LCD_FSMC_Config( void )
{
FSMC_NORSRAMInitTypeDef  FSMC_NORSRAMInitStructure;
FSMC_NORSRAMTimingInitTypeDef  FSMC_NORSRAMTimingInitStructure;
FSMC_NORSRAMTimingInitStructure.FSMC_AddressSetupTime = 0x01;//(0-0xF) 地址建立时间
FSMC_NORSRAMTimingInitStructure.FSMC_AddressHoldTime = 0x08;//(0-0xF) 地址保持时间
FSMC_NORSRAMTimingInitStructure.FSMC_DataSetupTime = 0x02;//(0-0xFF) 数据建立时间
FSMC_NORSRAMTimingInitStructure.FSMC_BusTurnAroundDuration = 0x08;//(0-0xF) 总线恢复时间
FSMC_NORSRAMTimingInitStructure.FSMC_CLKDivision = 0x00;//(0-0xF) 时钟分频
FSMC_NORSRAMTimingInitStructure.FSMC_DataLatency = 0x02;//数据保持时间
FSMC_NORSRAMTimingInitStructure.FSMC_AccessMode = FSMC_AccessMode_B;

FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1;
FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;//地址数据不复用
FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_NOR;//数据类型NOR FLASH
FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;//数据宽度16位
FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;//禁止突出模式,使用异步写
FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait =  FSMC_AsynchronousWait_Disable;
FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;//只在突发模式有效,等待信号极性为低
FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;//禁止非对齐突发模式
FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;//只在突发模式有效,NWAIT信号在什么时期产生
FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable;//写使能
FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;//只在突发模式有效,禁用NWAIT信号
FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable;//禁止扩展模式,
FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;//禁止突发写
FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &FSMC_NORSRAMTimingInitStructure;//配置读写时序
FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &FSMC_NORSRAMTimingInitStructure;//配置写时序
FSMC_NORSRAMInit( &FSMC_NORSRAMInitStructure );
    /* 使能 FSMC Bank1_SRAM Bank */
    FSMC_NORSRAMCmd( FSMC_Bank1_NORSRAM2, ENABLE );   
}


#define Bank1_LCD_C    ((u32)0x60000000)    //命令基地址
#define Bank1_LCD_D    ((u32)0x61000000)       //数据基地址(A23 PE2)
#define LCD_WR_CMD(index)         ((*(__IO u16 *)(Bank1_LCD_C)) = ((u16)index))//选定LCD指定寄存器
#define LCD_WR_Parameter(val)     ((*(__IO u16 *)(Bank1_LCD_D)) = ((u16)(val)))//往LCD GRAM写入数据
#define LCD_WR_REG( index )    LCD_WR_CMD( index )
#define LCD_WR_Data( val )    LCD_WR_Parameter( val )

我所使用的块1(NOR)中的第一块  ,TFT的读写控制端用NE1 所以其寄存器基地址是 : 0X60000000  ,  RAM基地址 : 0X6100 0000 = 0X6000 0000+2^23*2 = 0X6000 0000 + 0X100 0000 = 0X6100 0000
然后在写寄存器的时候,初始化TFT感觉上没有错,因为我以前我用  I/O  模拟8080接口的时候我做过,我所用的TFT驱动是 HX8352A ,以前我弄成功过,现在想用FSMC驱动快一点,请问一下我这里设置FSMC有没有错?
谢谢啦
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

联系站长|手机版|野火电子官网|野火淘宝店铺|野火电子论坛 ( 粤ICP备14069197号 ) 大学生ARM嵌入式2群

GMT+8, 2024-9-21 03:13 , Processed in 0.024127 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表