一、硬件介绍
硬件使用STM32F429IGT6,外部flash为W25Q256FVEI,屏幕为TFTLCD分辨率为1024*600,SDRAM使用的是W9825G6KH-6I。使用TouchGFX(版本为4.16.1)作为界面,外部falsh存储图片。
二、MXcube配置
1.时钟配置为
2.SDRAM配置为
3. DMA2D配置为
打开中断
4.LTDC配置为
图层配置
打开中断
5.Free RTOS配置
6.touchGFX配置
三、touchGFX Designer配置
图片配置
界面配置,界面包含一个主界面和三个次界面。主界面包含三个按钮,按钮增加和页面跳转功能;分界面包含一个图片和一个返回按钮,返回按钮可以返回主界面。
四、软件配置
1.去掉MicroLIB选项和下载校准选项
2.增加下载算法
3.增加代码段
五、增加代码
1.在TouchGFXHAL.cpp中增加代码
2.在TouchFGXCongratulation.cpp中增加代码
3.在STM32TouchController.cpp中增加触控代码
4.SDRAM初始化
void MX_SDRAM_InitEx(void)
{
__IO uint32_t tmpmrd = 0;
FMC_SDRAM_CommandTypeDef Command;
/* Step 1: Configure a clock configuration enable command */
Command.CommandMode = FMC_SDRAM_CMD_CLK_ENABLE;
Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1;
Command.AutoRefreshNumber = 1;
Command.ModeRegisterDefinition = 0;
/* Send the command */
HAL_SDRAM_SendCommand(&hsdram1, &Command,0X1000);
/* Step 2: Insert 100 us minimum delay */
/* Inserted delay is equal to 1 ms due to systick time base unit (ms) */
osDelay(1);
/* Step 3: Configure a PALL (precharge all) command */
Command.CommandMode = FMC_SDRAM_CMD_PALL;
Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1;
Command.AutoRefreshNumber = 1;
Command.ModeRegisterDefinition = 0;
/* Send the command */
HAL_SDRAM_SendCommand(&hsdram1, &Command, 0X1000);
/* Step 4: Configure an Auto Refresh command */
Command.CommandMode = FMC_SDRAM_CMD_AUTOREFRESH_MODE;
Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1;
Command.AutoRefreshNumber = 8;
Command.ModeRegisterDefinition = 0;
/* Send the command */
HAL_SDRAM_SendCommand(&hsdram1, &Command, 0X1000);
/* Step 5: Program the external memory mode register */
tmpmrd = (uint32_t)SDRAM_MODEREG_BURST_LENGTH_1 |\
SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL |\
SDRAM_MODEREG_CAS_LATENCY_3 |\
SDRAM_MODEREG_OPERATING_MODE_STANDARD |\
SDRAM_MODEREG_WRITEBURST_MODE_SINGLE;
Command.CommandMode = FMC_SDRAM_CMD_LOAD_MODE;
Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1;
Command.AutoRefreshNumber = 1;
Command.ModeRegisterDefinition = tmpmrd;
/* Send the command */
HAL_SDRAM_SendCommand(&hsdram1, &Command, 0X1000);
/* Step 6: Set the refresh rate counter */
/* Set the device refresh rate */
HAL_SDRAM_ProgramRefreshRate(&hsdram1, 683);
}
5.LTDC初始化
void LTDC_Init(void)
{
HAL_LTDC_SetWindowPosition(&hltdc,0,0,0); //设置窗口的位置
HAL_LTDC_SetWindowSize(&hltdc,1024,600,0);//设置窗口大小
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, GPIO_PIN_SET);//屏幕灯点亮
}
6.LCD线程
void LTCD_Thread(void const * argument)
{
FT5206_Init();//触摸初始化
osDelay(100);
MX_TouchGFX_Process();
while (1) {
osDelay(10);
}
}
六、测试结果