2025-07-09 8:17 AM
Hi everyone,
I’m setting up LVGL on a custom PCB using an STM32H747BIT MCU. The display is connected via LVDS, and I’m using DMA2D for transferring the framebuffer to the screen.
The issue I’m facing is that the DMA2D transfer complete callback is never triggered, and as a result, lv_disp_flush_ready() is not called and the buffer is not pushed to the display.
Below is the relevant initialization code:
lv_init();
lv_tick_set_cb(HAL_GetTick); //FIXME: per ThreadX fer servir tx_time_get
disp = lv_display_create(LV_DISPLAY_HORIZONTAL_RES, LV_DISPLAY_VERTICAL_RES);
lv_display_set_buffers(disp, buf1, NULL, sizeof(buf1), LV_DISPLAY_RENDER_MODE_PARTIAL);
hdma2d.XferCpltCallback = disp_flush_complete;
lv_display_set_flush_cb(disp, my_flush_cb);
The my_flush_cb() function is as follows:
void my_flush_cb(lv_display_t * display, const lv_area_t * area, uint8_t * px_map)
{
lv_coord_t width = lv_area_get_width(area);
lv_coord_t height = lv_area_get_height(area);
SCB_CleanInvalidateDCache();
DMA2D->CR = 0x0U << DMA2D_CR_MODE_Pos;
DMA2D->FGPFCCR = DMA2D_INPUT_RGB565;
DMA2D->FGMAR = (uint32_t)px_map;
DMA2D->FGOR = 0;
DMA2D->OPFCCR = DMA2D_OUTPUT_RGB565;
DMA2D->OMAR = hltdc.LayerCfg[0].FBStartAdress + 2 * \
(area->y1 * LV_DISPLAY_HORIZONTAL_RES + area->x1);
DMA2D->OOR = LV_DISPLAY_HORIZONTAL_RES - width;
DMA2D->NLR = (width << DMA2D_NLR_PL_Pos) | (height << DMA2D_NLR_NL_Pos);
DMA2D->IFCR = 0x3FU;
DMA2D->CR |= DMA2D_CR_TCIE;
DMA2D->CR |= DMA2D_CR_START;
}
And the DMA2D completion callback:
static void
disp_flush_complete (DMA2D_HandleTypeDef *hdma2d)
{
lv_disp_flush_ready(disp);
}
And finally, this is the main loop where I call the LVGL handler:
while (1)
{
uint32_t time_till_next = lv_timer_handler();
if(time_till_next == LV_NO_TIMER_READY)
time_till_next = LV_DEF_REFR_PERIOD; // Fallback delay
HAL_Delay(time_till_next); // Delay to reduce CPU usage
}
At this point, I’m just trying to get LVGL to show something on the screen using DMA2D. If anyone has suggestions or sees something I’m missing in the configuration, I’d really appreciate the help.
Thanks!