• 【TouchGFX】使用CubeMX创建touchgfx项目 -- 初始篇


    1、系统构成,黑色块表示组件非必须

    2、环境准备

    CubeMX:6.0.1

    touchgfx:4.15.0

    rt-thread:2020-8-14 commit

    Keil:5.30

    board:stm32f29igt6 + SDRAM-256Mb(16M x 16)+  SPI-FLASH-16MB + LCD-1024*600

    3、打开CubeMX开始创建项目

    3.1、安装软件包touchgfx最新版本4.15.0

    3.2、系统时钟源RCC配置

    3.3、系统调试口及时基SYS配置

    3.4、配置SDRAM--W9825G6KH,电气参数及管脚配置

    参考博文【链接一】【链接二

     3.5、配置SPI-FLASH--W25Q128JVSQ

    3.6、配置图形加速器 ChromART

    3.7、显示LTDC接口配置

    3.8、触摸芯片I2C接口配置

      3.9、组件CRC激活,TouchGFX需要

    3.10、加入freertos操作系统,目的是生成touchgfx与操作系统接口文件,方便移植rt-thread,参数配置保持默认即可

     3.11、在附加软件管理器中选择TouchGFX用以生成其代码,并做相关配置

    3.12、IO口配置,LCD复位、背光,FLASH片选,LED等

    3.13、时钟树配置

    3.14、生成工程

    3.15、直接打开生成的Keil工程编译会报错,这是因为这些文件都是TouchGFX Designer生成,所以需要使用TouchGFX Designer 先生成代码

    3.16、打开CubeMX生成的TouchGFX Designer模板工程,加入TEXT、BOX和BUTTON控件后生成touchgfx代码

    3.17、再次编译Keil工程

    4、补全工程,使之能运行起来

    4.1、加入SDRAM配置代码

     1 #define REFRESH_COUNT                               636//1000//1755//636
     2 #define SDRAM_TIMEOUT                               ((uint32_t)0xFFFF)
     3 #define SDRAM_MODEREG_BURST_LENGTH_1                ((uint32_t)0x0000)
     4 #define SDRAM_MODEREG_BURST_LENGTH_2                ((uint32_t)0x0001)
     5 #define SDRAM_MODEREG_BURST_LENGTH_4                ((uint32_t)0x0002)
     6 #define SDRAM_MODEREG_BURST_LENGTH_8                ((uint32_t)0x0004)
     7 #define SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL         ((uint32_t)0x0000)
     8 #define SDRAM_MODEREG_BURST_TYPE_INTERLEAVED        ((uint32_t)0x0008)
     9 #define SDRAM_MODEREG_CAS_LATENCY_2                 ((uint32_t)0x0020)
    10 #define SDRAM_MODEREG_CAS_LATENCY_3                 ((uint32_t)0x0030)
    11 #define SDRAM_MODEREG_OPERATING_MODE_STANDARD       ((uint32_t)0x0000)
    12 #define SDRAM_MODEREG_WRITEBURST_MODE_PROGRAMMED    ((uint32_t)0x0000)
    13 #define SDRAM_MODEREG_WRITEBURST_MODE_SINGLE        ((uint32_t)0x0200)
    14 
    15 /**
    16   * @brief  Programs the SDRAM device.
    17   * @retval None
    18   */
    19 void MX_SDRAM_InitEx(void)
    20 {
    21     __IO uint32_t tmpmrd = 0;
    22     FMC_SDRAM_CommandTypeDef Command;
    23 
    24     /* Step 1: Configure a clock configuration enable command */
    25     Command.CommandMode            = FMC_SDRAM_CMD_CLK_ENABLE;
    26     Command.CommandTarget          = FMC_SDRAM_CMD_TARGET_BANK1;
    27     Command.AutoRefreshNumber      = 1;
    28     Command.ModeRegisterDefinition = 0;
    29 
    30     /* Send the command */
    31     HAL_SDRAM_SendCommand(&hsdram1, &Command, SDRAM_TIMEOUT);
    32 
    33     /* Step 2: Insert 100 us minimum delay */
    34     /* Inserted delay is equal to 1 ms due to systick time base unit (ms) */
    35     HAL_Delay(1);
    36 
    37     /* Step 3: Configure a PALL (precharge all) command */
    38     Command.CommandMode            = FMC_SDRAM_CMD_PALL;
    39     Command.CommandTarget          = FMC_SDRAM_CMD_TARGET_BANK1;
    40     Command.AutoRefreshNumber      = 1;
    41     Command.ModeRegisterDefinition = 0;
    42 
    43     /* Send the command */
    44     HAL_SDRAM_SendCommand(&hsdram1, &Command, SDRAM_TIMEOUT);
    45 
    46     /* Step 4: Configure an Auto Refresh command */
    47     Command.CommandMode            = FMC_SDRAM_CMD_AUTOREFRESH_MODE;
    48     Command.CommandTarget          = FMC_SDRAM_CMD_TARGET_BANK1;
    49     Command.AutoRefreshNumber      = 8;
    50     Command.ModeRegisterDefinition = 0;
    51 
    52     /* Send the command */
    53     HAL_SDRAM_SendCommand(&hsdram1, &Command, SDRAM_TIMEOUT);
    54 
    55     /* Step 5: Program the external memory mode register */
    56     tmpmrd = (uint32_t)SDRAM_MODEREG_BURST_LENGTH_1          | 
    57              SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL   | 
    58              SDRAM_MODEREG_CAS_LATENCY_3           | 
    59              SDRAM_MODEREG_OPERATING_MODE_STANDARD | 
    60              SDRAM_MODEREG_WRITEBURST_MODE_SINGLE;
    61 
    62     Command.CommandMode            = FMC_SDRAM_CMD_LOAD_MODE;
    63     Command.CommandTarget          = FMC_SDRAM_CMD_TARGET_BANK1;
    64     Command.AutoRefreshNumber      = 1;
    65     Command.ModeRegisterDefinition = tmpmrd;
    66 
    67     /* Send the command */
    68     HAL_SDRAM_SendCommand(&hsdram1, &Command, SDRAM_TIMEOUT);
    69 
    70     /* Step 6: Set the refresh rate counter */
    71     /* Set the device refresh rate */
    72     HAL_SDRAM_ProgramRefreshRate(&hsdram1, REFRESH_COUNT);
    73 }

    4.2、加入SPI-FLASH驱动

    4.3、加入触摸驱动

    5、FAQ

    5.1、LTDC刷新频率过高导致的屏幕闪烁错位情况,相同硬件第一次设置25M工作正常,第二次25M就出现下面现象,修改为23M后工作正常,感觉会变很奇怪

                     

     5.2 、framebuffer过小导致的显示断屏错位,大小应该是分辨率×色深 (800×480×3) Byte

    5.3、FT5436触摸IC获取第一点触摸Y坐标概率性负值,即MSB是1,须转为正值 ,可 & 0x7FFF,否则造成触摸间歇性失效,如 drag 效果达不到

    再牛逼的梦想也架不住傻逼似的坚持
  • 相关阅读:
    php设计模式 -- 数据映射模式
    php 守护进程 (简单)
    php 守护进程
    php rabbitmq demo
    linux 全局安装composer
    linux 安装rabbitmq
    linux php安装RabbitMq扩展
    http和tcp详解
    lnmp环境脚本自动配置
    30.输入年月日,判断它是该年的第多少天
  • 原文地址:https://www.cnblogs.com/skullboyer/p/13806806.html
Copyright © 2020-2023  润新知