Synchronising flush with vsync


I have LVGL working and the results are good. I have a slight tearing effect during animation which I was looking to reduce. I can not use true double buffering as my target will only have the on board RAM of the STM32F429, with a 320 x 240 display.

I would like to synchronize the flush / buffer updates to the line interrupt of the LTDC peripheral (the interrupt will fire at a programmable display line). What I don’t understand at the moment is how to work out when LVGL has completed a frame update. I’m also not sure of the best way to hold up LVGL while I wait for the next line interrupt.

I have two ideas. In the flush function I spin on a flag which is set in the line interrupt. But I would need to know in the flush function whether or not LVGL has finished updating the frame, which I don’t think I can at present. Or I synchronize the calling of lv_task_handler() to the line interrupt, therefore ensuring all functions are run synchronized with the frame write, but this seems very heavy handed.

Does anyone have experience with this and can share some ideas?


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

STM32F429, on the discovery board at the moment, by the final target will not have the off board RAM.

What do you want to achieve?

Synchronized frame updates with display frame write.


There is no simple built-in method for this but it could be.
A correct solution would be to add a sync_cb (which can return LV_RES_OK or LV_RES_INV) to the display driver struct and keep sync_cb spinning before refreshing.

What do you think about it?

A quick and dirty solution would be to add this synchronization manually to disp_refr_task in lv_refr_c.

sync_cb sounds like a good idea. At the moment I am synchronizing lv_task_handler() to the LTDC line interrupt, just to see if it helped with the tearing and to be honest, it didn’t really. I realise without double frame buffers it can’t be eliminated.

I still think this is a good idea and could be used for all types of LCD controllers that provide tearing or line position feedback.

On which line do you synchronize? I suppose it should be the last one.