cancel
Showing results for 
Search instead for 
Did you mean: 

SPI with DMA and TFT Display ST7735

Hans345
Associate

Dear STM32 community

I am trying to setup the ST7735 Display (ST7735) with SPI and DMA for a faster refresh rate. Without DMA everything works fine. When i setting up DMA nothing is displayed on the Display.

My DMA and SPI Settings are:

Hans345_0-1715755303173.pngHans345_1-1715755330465.png

Hans345_2-1715755355614.png

Hans345_4-1715756756137.png

I want to fill the Screen with black color, for this i use the function fillScreen() from GFX_FUNCTIONS.c. To Transmit the data via DMA i have replaced the old functions in ST7735.c with the DMA Transmit function in ST7735_FillRectangle(), ST7735_WriteCommand() and ST7735_WriteData().

Hans345_3-1715755585506.png

For detail view i have attached the main.c file and the library files from the Display (ST7735.c and GFX_FUNCTIONS.c). I am using a Nucleo-G474RE Boeard with STM32 Version 1.15.1.

I really someone of you guys could help me.
Thanks a lot for your time!
Best regards,
Raphael

1 ACCEPTED SOLUTION

Accepted Solutions
Techn
Senior III

I guess the issue is where you put in a loop to write the DMA request.. Here you have to wait for first DMA to complete before sending the next request. You need to use HAL_DMA_PollForTransfer() function to check if the previous DMA is complete or not. Alternatively, you need to enable the SPI and DMA  interrupt and use void HAL_SPI_TxCpltCallback (SPI_HandleTypeDef * hspi) to write the bytes, but then the logic has to be re-arranged.

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

4 REPLIES 4
Techn
Senior III

I guess the issue is where you put in a loop to write the DMA request.. Here you have to wait for first DMA to complete before sending the next request. You need to use HAL_DMA_PollForTransfer() function to check if the previous DMA is complete or not. Alternatively, you need to enable the SPI and DMA  interrupt and use void HAL_SPI_TxCpltCallback (SPI_HandleTypeDef * hspi) to write the bytes, but then the logic has to be re-arranged.

If you feel a post has answered your question, please click "Accept as Solution".
MM..1
Chief III

Seems you completely misunderstand how DMA works and where you read , that one pixel DMA make better refresh rate??? Your DMA code when works after mistakes removed, will slower as original without DMA.

AScha.3
Chief III

Hi,

how much time it needs for cls, black screen fill ?

btw.

I tried also to speed it up by using DMA (on H743 cpu, DMA only used for "fill", if more than 4 pix to write, otherwise DMA would be slower than a direct SPI write) , but the St7735 TFT not so happy with my test: at first seems to work fine, but after cold start it had a strange effect: the black was not "really black", it had some strange colored touch, when looking with some angle to the display. So i took again the HAL_SPI write and display full black again.

If you feel a post has answered your question, please click "Accept as Solution".

Hi Techn

This helps. I have adapted my code as follows:

Hans345_0-1716275089094.png

Thank you!