Move vsync to fix screen tearing
@@ -366,6 +366,10 @@ void blit_flip() {
} else {
// LORES mode
+ // wait for next frame if LTDC hardware currently drawing, ensures
+ // no tearing
+ while (!(LTDC->CDSR & LTDC_CDSR_VSYNCS));
+
// pixel double the framebuffer to the LTDC buffer
rgb *src = (rgb *)blit::fb.data;
@@ -389,10 +393,6 @@ void blit_flip() {
SCB_CleanInvalidateDCache_by_Addr((uint32_t *)&__ltdc_start, 320 * 240 * 2);
- // wait for next frame if LTDC hardware currently drawing, ensures
- // no tearing
- while (!(LTDC->CDSR & LTDC_CDSR_VSYNCS));
-
// set the LTDC layer framebuffer pointer shadow register
LTDC_Layer1->CFBAR = (uint32_t)(&__ltdc_start);
// force LTDC driver to reload shadow registers
