2023-07-18 02:13 AM
Hi, 2 questions:
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.
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?
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);
}
With optimization -Ofast it is faster and takes 10ms.
Is it top performace? Is using DMA2D and copy-paste some batches will increase speed?
2023-07-19 02:06 AM
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.
2023-07-21 05:41 AM
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:
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.
I tried divinding framerate with software and ghosts are less visible
2023-07-28 07:07 AM
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:
Regarding the display, some information in the UM2967 Discovery kit with STM32U5A9NJ MCU - User manual:
-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.