How to configure the DMA2D

Description

Hello guys,
I have tested the demos and they work fine.
When I select a new tab. The display is not so fast. The refresh is not good.
Can someone show her code using the DMA2D?

I have a stm32f746g-disco .
Video:
https://drive.google.com/file/d/1IpzJedliG81F0__ns2XLfuwGZKuEGZO5/view?usp=sharing
Thanks,

What MCU/Processor/Board and compiler are you using?

stm32f746g-disco .

What LVGL version are you using?

7.6.0

What do you want to achieve?

What have you tried so far?

Code to reproduce

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

The code block(s) should be formatted like:

/* 1: Enable GPU interface*/
#define LV_USE_GPU              1   /*Only enables `gpu_fill_cb` and `gpu_blend_cb` in the disp. drv- */
#define LV_USE_GPU_STM32_DMA2D  0
/*If enabling LV_USE_GPU_STM32_DMA2D, LV_GPU_DMA2D_CMSIS_INCLUDE must be defined to include path of CMSIS header of target processor
e.g. "stm32f769xx.h" or "stm32f429xx.h" */
#define LV_GPU_DMA2D_CMSIS_INCLUDE

/* Flush the content of the internal buffer the specific area on the display
 * You can use DMA or any hardware acceleration to do this operation in the background but
 * 'lv_flush_ready()' has to be called when finished
 * This function is required only when LV_VDB_SIZE != 0 in lv_conf.h*/
static void ex_disp_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t * color_p)
{
	int32_t x1 = area->x1;
	int32_t x2 = area->x2;
	int32_t y1 = area->y1;
	int32_t y2 = area->y2;
    /*Return if the area is out the screen*/

    if(x2 < 0) return;
    if(y2 < 0) return;
    if(x1 > TFT_HOR_RES - 1) return;
    if(y1 > TFT_VER_RES - 1) return;

    /*Truncate the area to the screen*/
    int32_t act_x1 = x1 < 0 ? 0 : x1;
    int32_t act_y1 = y1 < 0 ? 0 : y1;
    int32_t act_x2 = x2 > TFT_HOR_RES - 1 ? TFT_HOR_RES - 1 : x2;
    int32_t act_y2 = y2 > TFT_VER_RES - 1 ? TFT_VER_RES - 1 : y2;

    x1_flush = act_x1;
    y1_flush = act_y1;
    x2_flush = act_x2;
    y2_fill = act_y2;
    y_fill_act = act_y1;
    buf_to_flush = color_p;

    /*##-7- Start the DMA transfer using the interrupt mode #*/
    /* Configure the source, destination and buffer size DMA fields and Start DMA Stream transfer */
    /* Enable All the DMA interrupts */
    HAL_StatusTypeDef err;
    uint32_t length = (x2_flush - x1_flush + 1);
#if LV_COLOR_DEPTH == 24 || LV_COLOR_DEPTH == 32
    length *= 2; /* STM32 DMA uses 16-bit chunks so multiply by 2 for 32-bit color */
#endif
    err = HAL_DMA_Start_IT(&DmaHandle,(uint32_t)buf_to_flush, (uint32_t)&my_fb[y_fill_act * TFT_HOR_RES + x1_flush],
             length);
    if(err != HAL_OK)
    {
        while(1);	/*Halt on error*/
    }
}

Screenshot and/or video

Video Here,
https://drive.google.com/file/d/1IpzJedliG81F0__ns2XLfuwGZKuEGZO5/view?usp=sharing

Well, follow the comments :slight_smile:

#define LV_USE_GPU_STM32_DMA2D 1
#define LV_GPU_DMA2D_CMSIS_INCLUDE stm32f746xx.h

and try to compile again.

Hello Papadkostas. Thank you for your repply.
In this configuration the screen goes to black.

/* 1: Enable GPU interface*/
#define LV_USE_GPU 0 /*Only enables gpu_fill_cb and gpu_blend_cb in the disp. drv- */
#define LV_USE_GPU_STM32_DMA2D 1
/*If enabling LV_USE_GPU_STM32_DMA2D, LV_GPU_DMA2D_CMSIS_INCLUDE must be defined to include path of CMSIS header of target processor
e.g. “stm32f769xx.h” or “stm32f429xx.h” */
#define LV_GPU_DMA2D_CMSIS_INCLUDE “stm32f746xx.h”

Using this configuration the display is not fast, and the touch screen does not work.

/* 1: Enable GPU interface*/
#define LV_USE_GPU 1 /*Only enables gpu_fill_cb and gpu_blend_cb in the disp. drv- */
#define LV_USE_GPU_STM32_DMA2D 1
/*If enabling LV_USE_GPU_STM32_DMA2D, LV_GPU_DMA2D_CMSIS_INCLUDE must be defined to include path of CMSIS header of target processor
e.g. “stm32f769xx.h” or “stm32f429xx.h” */
#define LV_GPU_DMA2D_CMSIS_INCLUDE “stm32f746xx.h”

Regards,

Hi,

the first config should work.

With a debugger do you see if it halts somewhere?

I have a STM32F746NG-Discovery.
I make it work with this settings:

/* 1: Enable GPU interface*/
#define LV_USE_GPU 0 /*Only enables gpu_fill_cb and gpu_blend_cb in the disp. drv- */
#define LV_USE_GPU_STM32_DMA2D 1
/*If enabling LV_USE_GPU_STM32_DMA2D, LV_GPU_DMA2D_CMSIS_INCLUDE must be defined to include path of CMSIS header of target processor
e.g. “stm32f769xx.h” or “stm32f429xx.h” */
#define LV_GPU_DMA2D_CMSIS_INCLUDE <stm32f7xx.h>

If I set like this, according to the comment and my MCU:

#define LV_GPU_DMA2D_CMSIS_INCLUDE <stm32f746xx.h>

It doesn’t work because STM32F7 is not defined and so the DMA2D clock is not enabled (see lv_gpu_dma2d_init in lv_gpu/lv_gpu_stm32_dma2d.c.
STM32F7 is defined in stm32f7xx.h which then includes stm32f746xx.h.