2025-10-17 3:08 PM - last edited on 2025-10-18 1:33 AM by Andrew Neil
(Please ignore the green area, which is Layer 1 of the LTDC.)
I am using an STM32N6570 development board with an external PSRAM (connected via XSPI1) to store camera frame buffers. I have implemented a double-buffering scheme where the DCMIPP writes camera frames into the external PSRAM buffers and the LTDC reads from them for display.
However, even with double buffering, I still observe screen tearing. I have tried:
Switching the LTDC display buffer only during VSync (vertical blanking)
Cleaning the CPU D-Cache before updating the LTDC address
Despite these measures, tearing persists. I suspect the cause is related to the limited bandwidth and high latency of the external PSRAM, combined with the LTDC FIFO prefetching. Essentially, the LTDC sometimes reads the external PSRAM while the DMA is still writing the new frame, causing partially updated frames to be displayed.
I want to find a reliable solution to eliminate screen tearing while still using the external PSRAM for camera frames.
This is my XSPI1 configuration.
This section is defined in SPRAM.
void HAL_DCMIPP_PIPE_FrameEventCallback(DCMIPP_HandleTypeDef *hdcmipp, uint32_t Pipe)
{
frame_ready_index = num % 2;
HAL_DCMIPP_CSI_PIPE_Start(
hdcmipp,
DCMIPP_PIPE1,
DCMIPP_VIRTUAL_CHANNEL0,
camera_framebuf[frame_ready_index],
DCMIPP_MODE_CONTINUOUS
);
num++;
NbMainFrames++;
}
void HAL_LTDC_LineEventCallback(LTDC_HandleTypeDef *hltdc)
{
if(frame_ready_index != frame_to_display)
{
SCB_CleanDCache_by_Addr(
(uint32_t*)camera_framebuf[frame_ready_index],
800 * 480
);
HAL_LTDC_SetAddress(hltdc, camera_framebuf[frame_ready_index], 0);
frame_to_display = frame_ready_index;
}
}I have tried using double buffering, but it couldn't resolve the issue.
2025-10-21 1:24 AM
Hello @实在太懒于是不想取名 and welcome to the community;
Could you please check the XSPI configuration?
The PSRAM memory integrated in STM32N6570-DK board is Hexadeca memory not Octo. Also the PSRAM size is 256Mb not 16 Bits.
I recommend you to look at the XSPI_PSRAM_MemoryMapped and precisely the ioc file and check the PSRAM configuration.
Thank you.
Kaouthar
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.
2025-11-03 7:27 AM
Hello @实在太懒于是不想取名 ;
Any update about the issue?
Is my reply help you to solve the tearing issue?
Thank you.
Kaouthar
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.