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.

1 Like

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.

I think it’s already fixed in the latest version of LVGL.

1 Like

As Patrick said. Same experience here, I still need to use:
#define LV_GPU_DMA2D_CMSIS_INCLUDE <stm32f7xx.h>
than:
#define LV_GPU_DMA2D_CMSIS_INCLUDE <stm32f767xx.h>
in the latest LVGL

1 Like

Don’t know if I understand you correctly:

#include <stm32f7xx.h> is the standard way (or include <stm32f4xx.h> or <stm32h7xx.h>

Within the stm32f7xx.h you have to uncomment the appropriate line for your used STM derivative,
or, as I do, set the controller type definition (in your example STM32F767xx) within the preprocessor definition list within your IDE.

In this case, you only have to include the family include file <stm32f7xx.h> (or <stm32f4xx.h>, or <stmh7xx.h> within your source files. So, if you change the controller derivative, you have to do the change only at one place,and not in every single source file (as long as you don’t change the family of course :grin:)

Also in lv_gpu_stm32_dma2d.c we have only to decide between the STM families and not for every derivative.

Yup, I see your pull request that only checks between STM32 family for enabling DMA2D clock.

I just confirm that using LV_GPU_DMA2D_CMSIS_INCLUDE <stm32f767xx.h> will not work to look up STM32 family definition.

STM32F7 is defined in stm32f7xx.h not in stm32f767xx.h, and also every derivative is included in stm32f7xx.h based on preprocessor definition.
I have STM32F767xx in my preprocessor list so stm32f7xx.h will including stm32f767xx.h header file :

1 Like