2024-06-28 09:27 AM
Hello!
I'm using a 320x240 TFT display with ST7789V driver and SPI interface by X-CUBE-DISPLAY.
Pixel transfer works correctly when I use the BSP_LCD_WriteData function. I can also display images and animation using the TouchGFX framework.
However, when I use the BSP_LCD_WriteDataDMA function to perform the same process but with DMA, I encounter an anomalous behavior that I cannot explain.
The code transfers the data successfully and the display show the image during the first execution. Then, on the second execution, the display suddenly turns off, blacking out all pixels, as soon as the BSP_LCD_SetDisplayWindow function is called. Despite this, neither the driver nor the DMA reports any errors.
uint32_t Display_TransferData(uint8_t useDMA, uint8_t * data, uint32_t size)
{
uint8_t * ptr = data;
uint32_t i = 0;
while(i < size)
{
uint32_t n_byte = 65534;
if(size < i+n_byte)
n_byte = size - i;
uint32_t ret;
if(useDMA)
{
ret = BSP_LCD_WriteDataDMA(0, ptr, n_byte);
if(ret)
return ret;
BSP_LCD_WaitForTransferToBeDone(0);
} else
{
ret = BSP_LCD_WriteData(0, ptr, n_byte);
}
ptr += n_byte;
i += n_byte;
}
return 0;
}
Does anyone have any ideas or has anyone experienced similar problems?
Solved! Go to Solution.
2024-07-09 07:37 AM
Update:
It seems that the BSP_LCD_WaitForTransferToBeDone() function does not wait for the entire byte transmission to complete.
Therefore, it was necessary to replace it with the following line of code to make it work.
while (hspi2.State != HAL_SPI_STATE_READY)
{}
2024-07-05 02:54 AM
Hello @Dadigno ,
I can see you have set BSP_LCD_WaitForTransferToBeDone to 0, which I assume means no waiting. But, when you are using DMA, you should wait for it to transfer the pixels to the display, for instance, using a DMA completion interrupt.
You can take a look at the documentation of TouchGFX on how to set up a display with an SPI interface for inspiration. FMC and SPI Display Interface
I hope this helps you. Don't hesitate to ask more questions
2024-07-05 03:00 AM
Hi @Mohammad MORADI ESFAHANIASL ,
BSP_LCD_WaitForTransferToBeDone function take in input an index to the corresponding Instance. In this case 0 means instance 0.
/**
* @brief Wait for until complete LCD Transfer.
* @param Instance: LCD Instance.
*/
void BSP_LCD_WaitForTransferToBeDone(uint32_t Instance)
{
if (Instance < LCD_INSTANCES_NBR)
{
LCD_OS_WaitForTransferToBeDone(Instance);
}
}
Bye
2024-07-09 07:37 AM
Update:
It seems that the BSP_LCD_WaitForTransferToBeDone() function does not wait for the entire byte transmission to complete.
Therefore, it was necessary to replace it with the following line of code to make it work.
while (hspi2.State != HAL_SPI_STATE_READY)
{}
2024-07-10 12:51 AM
Hey @Dadigno ,
I'm glad you managed to solve your problem.
Could you please select your comment as the "Accepted Solution"?