TFTLCD
TFT液晶屏常用的通信模式主要有6800模式和8080模式,对于TFT彩屏通常都使用8080并口(简称80并口)模式
8080模式的读写时序其实跟LCD1602或者LCD12864的读写时序是差不多的。8080接口有5条基本的控制线和多条数据线,数据线的数量主要看液晶屏使用的是几位模式,有8根、9根、16根、18根四种类型
FSMC
FSMC模块能够与同步或异步存储器和16位PC存储器卡接口
将AHB传输信号转换到适当的外部设备协议
满足访问外部设备的时序要求
所有的外部存储器共享控制器输出的地址、数据和控制信号,每个外部设备可以通过一个唯一的片选信号加以区分。 FSMC在任一时刻只访问一个外部设备
STM32通过FSMC可以与SRAM、ROM、PSRAM、NOR Flash和NAND Flash等存储器的引脚直接相连
外部设备地址映像
从FSMC的角度看,把外部存储器划分为固定大小为256M字节的四个存储块
模式A读写操作
以模式A举例
模式A读操作:
模式A写操作:
FSMC配置步骤
1.使能对应引脚GPIO时钟
2.配置GPIO引脚模式
3.使能FSMC时钟
4.FSMC初始化
5.存储器块使能
6.应用TFTLCD库函数,写字符、数字等
举例
FSMC_NORSRAMTimingInitTypeDef:
FSMC_NORSRAMInitTypeDef:
void TFTLCD_gpio_init()
{
GPIO_InitTypeDef gpiod =
{
GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_14 | GPIO_Pin_15,
GPIO_Speed_50MHz,
GPIO_Mode_AF_PP
};
GPIO_InitTypeDef gpioe =
{
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_Speed_50MHz,
GPIO_Mode_AF_PP
};
GPIO_InitTypeDef gpiog =
{
GPIO_Pin_0 | GPIO_Pin_12,
GPIO_Speed_50MHz,
GPIO_Mode_AF_PP
};
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE | RCC_APB2Periph_GPIOG, ENABLE);
GPIO_Init(GPIOD, &gpiod);
GPIO_Init(GPIOE, &gpioe);
GPIO_Init(GPIOG, &gpiog);
}
void FSMC_init()
{
FSMC_NORSRAMInitTypeDef fsmc = {0};
FSMC_NORSRAMTimingInitTypeDef FSMC_ReadWriteTimingStruct = {0};
FSMC_NORSRAMTimingInitTypeDef FSMC_WriteTimingStruct = {0};
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);
FSMC_ReadWriteTimingStruct.FSMC_AddressSetupTime = 0x01; //ADDSET建立时间=2个HCLK时钟周期
FSMC_ReadWriteTimingStruct.FSMC_AddressHoldTime = 0x00; //模式A未用到
FSMC_ReadWriteTimingStruct.FSMC_DataSetupTime = 0x0f; //DATAST保持时间=16个HCLK时钟周期
FSMC_ReadWriteTimingStruct.FSMC_BusTurnAroundDuration = 0x00;
FSMC_ReadWriteTimingStruct.FSMC_CLKDivision = 0x00;
FSMC_ReadWriteTimingStruct.FSMC_DataLatency = 0x00;
FSMC_ReadWriteTimingStruct.FSMC_AccessMode = FSMC_AccessMode_A; //访问模式A
FSMC_WriteTimingStruct.FSMC_AddressSetupTime = 0x0f; //ADDSET建立时间=16个HCLK时钟周期
FSMC_WriteTimingStruct.FSMC_AddressHoldTime = 0x0f;
FSMC_WriteTimingStruct.FSMC_DataSetupTime = 0x05;
FSMC_WriteTimingStruct.FSMC_BusTurnAroundDuration = 0x00;
FSMC_WriteTimingStruct.FSMC_CLKDivision = 0x00;
FSMC_WriteTimingStruct.FSMC_DataLatency = 0x00;
FSMC_WriteTimingStruct.FSMC_AccessMode = FSMC_AccessMode_A;
fsmc.FSMC_Bank = FSMC_Bank1_NORSRAM4;
fsmc.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
fsmc.FSMC_MemoryType = FSMC_MemoryType_SRAM;
fsmc.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;
fsmc.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
fsmc.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable;
fsmc.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
fsmc.FSMC_WrapMode = FSMC_WrapMode_Disable;
fsmc.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
fsmc.FSMC_WriteOperation = FSMC_WriteOperation_Enable;
fsmc.FSMC_WaitSignal = FSMC_WaitSignal_Disable;
fsmc.FSMC_ExtendedMode = FSMC_ExtendedMode_Enable; //扩展模式使能
fsmc.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
fsmc.FSMC_ReadWriteTimingStruct = &FSMC_ReadWriteTimingStruct;
fsmc.FSMC_WriteTimingStruct = &FSMC_WriteTimingStruct;
FSMC_NORSRAMInit(&fsmc);
FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM4, ENABLE); //使能存储块1 NOR/PSRAM 4
}
手机扫一扫
移动阅读更方便
你可能感兴趣的文章