cancel
Showing results for 
Search instead for 
Did you mean: 

LTDC DSI GFXMMU Doublebuffer - STM32U5A9J-DK

PAdam.11
Associate III

Hi, 2 questions:

  • how to develop doubleframebuffer
  • is clear framebuffer time 10ms top performance (-Ofast 160MHz)?

Details:

I'm experimenting with STM32U5A9J-DK round display board. After many trials and errors, comparing U5 examples with much richer ones for F4 pack I got working DSI LCD with singlebuffer.

I created GFXMMU Excel as asked in Cube creator. Attached virtual GFXMMU buffer to LTDC. Got line interrupt on front vertical porch. Finally evaluated some timing.

PAdam11_0-1689667537698.png

Now I want to use double framebuffer, and mu question: what is best approach to do this? I used to implement similar solution with SPI, DMA and half complete callback for STx driver. But I'm not sure how shoud it look like in this case.

I see that LTDC has 2 layers. Should I pass 2 GFXMMU buffers and swap layers somehow? Or use 1 layer and replace buffers during blanking period?

PAdam11_1-1689667946786.png

Question 2: Despite that I have some bad feeling about clearing screen. How should I draw to framebuffer? With memset i takes 36ms :( 

void gfx_prepare() {
	int32_t ltdc_clear_sreen_start_us = microtimer_get_us();
	/* Clear screen */
	gfx_fillscreen(0xFFFF0000); // RED
	gfx_draw_fillrect(LCD_WIDTH/2 - 20, LCD_HEIGHT-40, 40, 40, 0xff0000ff);
	ltdc_clear_sreen_duriation_us = microtimer_get_us() - ltdc_clear_sreen_start_us;
}

void gfx_draw_fillrect(uint32_t x_pos, uint32_t y_pos, uint32_t width, uint32_t height, uint32_t color) {
  uint32_t  px_address = 0;
  uint32_t  i;
  uint32_t  j;

  /* Get the rectangle start address */
  uint32_t startaddress = (hltdc.LayerCfg[0].FBStartAdress + (4 * (y_pos * PIXEL_PERLINE + x_pos)));

  /* Fill the rectangle */
  for (i = 0; i < height; i++) {
    px_address = startaddress + (3072 * i); //768 * 4
    for (j = 0; j < width; j++) {
    	      *(__IO uint32_t *)(px_address) = color;
      px_address += 4;
    }
  }
}


void gfx_fillscreen(uint32_t color) {
	gfx_draw_fillrect(0, 0, LCD_WIDTH, LCD_HEIGHT, color);
}

PAdam11_3-1689671136305.png

With optimization -Ofast it is faster and takes 10ms.

PAdam11_4-1689671445739.png

Is it top performace? Is using DMA2D and copy-paste some batches will increase speed?

 

 

 

3 REPLIES 3
PAdam.11
Associate III

It seems I have solution to second question. By using DMA2D register-memory I got 3ms while polling. It can be acceptable with doublebuffering.

I'l try enquing DMA2D IT at first. Duing that 3ms period I'l make some logic calculations. Then I have 11-3ms time left for building up framebuffer content this time with mem-mem DMA2D.

According to question 2, I have found resources explaining that I should use 1 layer of LTDC and 2 buffers. 2nd layer can be useful to mix images. To implement doublebuffering il simply switch pointers during blanking period.

I have idea in mind to use second layer to overlay some static image or gui with transparencies. 

PAdam.11
Associate III

It seems I managed to solve some problem. I added 2 GFXMMU buffers and shifted pointer of LTDC each line event entering blanking. It is working fine, but now I have 2 other problems:

  • how to lower frequency of LTDC? I cannot achieve less than 70 framerate. I need 30FPS.
  • how to fix ghosting effect? When drawing moving object it leaves trail behing.

Here green square is static. White ones are blinking. Rest are moving and leaving train behind.

With slowmotion camera it is visible that pixel color is not turning of completly when blinking. It is somehow delayed.

Btw, there is completly no documentation for the display. Part number leads to chineese website without any further information. The display doesn't exist in the offer.

PAdam11_1-1689943096363.png

I tried divinding framerate with software and ghosts are less visible

Amel NASRI
ST Employee

Hi @PAdam.11 ,

Glad to know that you managed to find answers to some of your questions.

I would like just to suggest some useful application notes offered by ST that can help you to father go with your project: 

  • AN4860: Introduction to DSI host on STM32 MCUs and MPUs
  • AN4861: LCD-TFT display controller (LTDC) on STM32 MCUs

Regarding the display, some information in the UM2967 Discovery kit with STM32U5A9NJ MCU - User manual:

AmelNASRI_0-1690553239053.png

-Amel

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.