Skip to main content

LTDC/Parallel RGB

For MCUs with a TFT controller (e.g. STM32F429, STM32F746, STM32H7), the TouchGFX Generator can generate the part of the HAL that configures the LTDC to transfer pixels from the framebuffer memory to the display. The generated code both starts the correct framebuffer transfer and unblocks the TouchGFX Engine main loop by calling OSWrappers::signalVSync() once a VSYNC interrupt is raised by the LTDC.

Display Interface

As opposed to a "Custom" display interface, where the developer must implement the whole driver by hand, for LTDC the TouchGFX Generator can generate all the code necessary for the TouchGFX HAL to support an LTDC configuration.

For "Parallel RGB (LTDC)" to be a selectable option through the TouchGFX Generator the LTDC must be enabled from the Multimedia group in the STM32CubeMX category list.

Once LTDC is enabled, the Parallel RGB (LTDC) option becomes available through the Display section of the TouchGFX Generator.

Even after LTDC is enabled through STM32CubeMX, some work is required in order to:

  1. Configure LTDC (GPIO and timings) to match connected display specifications
  2. Configure LTDC to match desired TouchGFX application specifications.

The TouchGFX Generator can read various configurations from STM32CubeMX and provide a list of warnings, recommendations or errors that are called Dependencies. The image below shows the list of dependencies present when initially enabling LTDC in CubeMX for any MCU (in this example we used an F429):

Note
LTDC recommendations, warnings and errors will be visible in the TouchGFX Generator interface as soon as LTDC is enabled through STM32CubeMX.
DependencyDescription
Number of layersTouchGFX is only capable of utilizing a single layer. While TouchGFX applications can work with two layers enabled, this is a warning to the user that the LTDC is potentially misconfigured. Change the number of layers in the LTDC block.
Window positionBy default, the Horizontal and Vertical window positions of the LTDC layer are 0. The window Horizontal and Vertical stop must be set equal to the displays dimensions.
Alpha Constant is 0By default, the alpha constant of LTDC layers is 0. This should be > 0 and preferably 255 unless there is an intent to have a global alpha at all times in an application.

Remember to actually select the Parallel RGB (LTDC) display interface after enabling the LTDC peripheral in the Multimedia section.

The following image shows the LTDC configuration that satisfies the conditions of the warnings, causing the Dependencies group to disappear from the TouchGFX Generator interface.

Reading settings from STM32CubeMX

By selecting Parallel RGB (LTDC) as the display interface through TouchGFX Generator, the width and height of the framebuffer is inherited from the LTDC configuration horizontal start/stop and vertical start/stop.

Defining the dimensions of Layer 0 according to the display and application dimensions a new entry in the Dependency window appears.

Ensuring that Framebuffer Image Width and Image Height match the size of the window, which is usually desired, will satisfy the warning.

Caution
TouchGFX Generator inherits the Width and Height values from the LTDC configuration, if LTDC is enabled. However, Width and Height can still be modified from the TouchGFX Generator interface. Changing these values can lead to a configuration mismatch if they do mot respect the Window LTDC Layer configuration.

TouchGFX Driver / VSYNC Signal

Once Parallel RGB (LTDC) is selected as Display Interface, developers gain access to the LTDC Application Tick Driver or TouchGFX Driver.

The following code is the interrupt handler (STM32F7) for the LTDC interrupt generated according to LTDC configuration. The generated handler automatically unblocks the TouchGFX Engine main loop.

extern "C"
irq void LTDC_IRQHandler(void)
{
if (LTDC->ISR & 1)
{
LTDC->ICR = 1;
if (LTDC->LIPCR == (LTDC->AWCR & 0x7FF) - 1)
{
//entering active area
OSWrappers::signalVSync();
}
}
}
Note
For the LTDC driver to work, users must enable the LTDC global interrupt through the LTDC NVIC settings or through Global NVIC settings, and also enable generation of handler code.

LTDC Frame Buffer configuration

The generated TouchGFX HAL will automatically configure the LTDC Layer Color Frame Buffer Start Address at runtime, so you should not set a value in LTDC configuration.

Conclusion

Enabling the Parallel RGB (LTDC) display interface option through TouchGFX Generator allows all required HAL code to be generated.

  • Sets the width, height and pixel format of the TouchGFX application in accordance with the STM32CubeMX LTDC configuration. The LTDC layer width and height impact the size of the canvas in TouchGFX Designer and the LTDC Pixel Format impacts the required TouchGFX framebuffer driver and also the format for generated assets.
  • Allow the LTDC application tick source to be selected which generates a handler to drive the TouchGFX Engine Main loop. Usually, with LTDC Configurations developers would always use the provided Application Tick Driver.