TouchGFX interface development | Use STM32CubeMX to transplant TouchGFX

This article is based on the STM32F429IGT6 + RGB (800 * 480) hardware platform, and records in detail how to use STM32CubeMX to port TouchGFX to STM32F429IGT6 and drive the RGB screen. For the installation of related software, please refer to the TouchGFX software installation article

The application framework of TouchGFX is shown in the figure below:
insert image description here

1. STM32CubeMX configuration

STM32CubeMX is mainly used to configure the hardware abstraction layer and middleware layer in the application framework diagram shown above

  • RCC system clock: high-speed external clock (HSE) configured as an external crystal oscillator

insert image description here

  • Since the FreeRTOS operating system is to be used, it is recommended to change the Timebase Source of the HAL library from SysTick to other timers. After the timer is selected, the system will automatically configure TIM, which is set to TIM7 here

insert image description here

  • FMC setting: Configure external SDRAM as RGBLCD video memory, configure parameters and pins according to your own hardware

insert image description here
insert image description here

  • DMA2D settings: activate DMA2D, configure the color mode as RGB565, and enable DMA2D interrupt

insert image description here
insert image description here

  • LTDC parameter setting: Configure LTDC parameters according to the screen parameters used

insert image description here

  • LTDC layer setting: choose to use layer 1 here, and set the frame buffer address to the first address of SDRAM 0XC0000000

insert image description here

  • LTDC GPIO pin setting: According to the pin connection of the specific development board, configure GPIO, pay attention to set the output speed to "Very High"; and enable LTDC interrupt

insert image description here
insert image description here

  • Clock tree configuration: the pixel clock size is 1056 x 705 x 60 / 1024 / 1024 = 42M, the maximum pixel clock is 42M, here is set to 33M (1056 is the total width, 705 is the total height)

insert image description here
insert image description here

  • Backlight pin setting: The development board in this article uses PB5 as the backlight pin, which is set to push-pull output

insert image description here

  • Activate CRC: TouchGFX needs to enable CRC function

insert image description here

  • Activate the FreeRTOS system: set the heap size to 32768 bytes, and the rest of the default configuration; and add a TouchGFX task

insert image description here
insert image description here

  • Select the Touchgfx component package

insert image description here
insert image description here

  • TouchGFX parameter setting: select double buffer, RGB565, enable DMA2D acceleration

insert image description here

  • Generate engineering code: the minimum stack size is set to 0x800

insert image description here

After STM32CubeMX generates the project, there is no need to open the Keil project. If you compile the Keil project at this time, there will be a lot of errors

2. TouchGFX Designer interface design

After the Keil project is generated, it is necessary to execute Touch Designer to design the UI part and improve the project

  • After generating the project, there is an ApplicationTemplate.touchgfx.part in the TouchGFX directory, click to open TouchGFX Designer

insert image description here

  • After dragging and dropping some controls, click Generate Code to generate the code, and the TouchGFX related code will be automatically added to the project

insert image description here

3. Add code to MKD-ARM Keil

  • Add SDRAM driver source files and header files

insert image description here

  • Add the SDRAM initialization function in the fmc.c file MX_FMC_Init() function to drive the external memory chip

insert image description here

  • Light up the screen backlight in the touchgfxhal.cpp file

insert image description here

  • Add the corresponding task, add TouchGFX processing function

insert image description here

4. Download test

After the compilation is correct, download it to the development board

insert image description here
If TouchGFX is transplanted successfully, the development board screen will display the interface designed in TouchGFX Designer

insert image description here

Guess you like

Origin blog.csdn.net/Chuangke_Andy/article/details/129683674