cancel
Showing results for 
Search instead for 
Did you mean: 

Different data after the 1st transfer using SPI via DMA (using LL Libs)

TheRaprus
Associate III

Hi everybody.

I'm facing a strange behaviour on my application. I'm using a STM 23H562, and I'm usign LL library to drive a SPI display (classic iLi).

I take the example from c:\Users\Massimo NUCLEO-H533RE\Examples_LL\SPI\*
and the display do what I want... only sometime!

Due to the 65535 max transfer length, I need to split it into 3 session. I wait the end of the previous as indicate in the example, using:

while (!LL_DMA_IsActiveFlag_TC(GPDMA2, LL_DMA_CHANNEL_0)){}
LL_DMA_ClearFlag_TC(GPDMA2, LL_DMA_CHANNEL_0);

But the color of the filling change (= the data transmitted to the display) from one session to the others. The 1st is correct, the second "sometime", the 3rd rarely.

But if I put a small delay from one session to the following everything work fine. 

How I can fix it?
It seems I must wait for some other flag, but donnow wich!

Moreover, the command to the display is based on a 8 bit spi data, so I change to 16 and back to 8 when I use the DMA. But the session of manual sending command to SPI after DMA fail because the TXC flag is always 0, it never change!

while (!LL_SPI_IsActiveFlag_TXC(SPI2)){}

Thank in advance.

2 REPLIES 2
MOBEJ
ST Employee

Hello @TheRaprus , 

Could you please specify which LCD you are using with SPI? Are you using a TFT LCD display module?

Thank you
Br

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.

I'm using a iLi9341 SPI display 320x240. It work only with SPI. With M4 DMA it work w/o problems.
SPI speed is 30MHz, but if I reduce there is no difference.

Because the total display memory is 320x240x2 byte = 153600B. I need 2 full DMA and one of ~22568B.

I tried to reduce the lengths to 60.000 and 20.000 but there is no differences.

What I presume is that the SPI shift reg isn't completely empty, so the 2nd or 3rd DMA Cycle had a dirty bit(s) in it, that "confuse" the display color command. 

Without DMA it work perfectly, changing the SPY from 8 to 16 bit, but I want the DMA, as in the M4 STM32!

The delay I mentioned above (between DMA calling) is 2 ms, 1 isn't enought.