AnsweredAssumed Answered

SPI DMA - too much delay time between bytes

Question asked by kecskes.gergely on Nov 11, 2015
Latest reply on Nov 11, 2015 by karpavicius.linas
Hello there!

In my application, I have a 320x240 graphic display (IlI9341 disp dirver), which I'm communicating with on SPI interface; the SPI clock is 10MHz, this is the max supported speed for the display. Now, when I fill the entire screen with some color, the filling process is kinda slow, it takes about 1 sec. In my opinion, this could be done so much faster. 
This is when I thought, it'll be good idea to use DMA. Now, I use the HAL_SPI_Transmit_DMA() function, but for surprise it is a bit slower than without the DMA use. At this point, I wanted to check on scope, how the bytes transfer happens. What really hit me, is that when I use the polling SPI functions, the delay between two bytes is around 6400 ns, but when I use DMA, it is doubled.

Since I'm writing every pixel on the screen (320x240), this much delay is just unacceptable. So again, I dig myself into the HAL library, and I found there the HAL_SPI_TxCpltCallback() function. My only problem is that I dont really know how to use it. I do understand that is get called, when the SPI is ready for another transfer, but how am I supposed to use it for sending data to the screen.
This is what I tried, but it does not seem to boost up the write process:

void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef *hspi)
{
    isILI9341Ready = SET;
}
 
And then

void ILI9341_SendData(uint8_t data)
{
    /*Wait for the callback flag*/
    while(isILI9341Ready!= SET);    
 
    ILI9341_DC(1);
    ILI9341_SPI_nSS(0);
     
    if(HAL_SPI_Transmit_DMA(SPI_HandleDef, &Value, size)!= HAL_OK)
    {      
        ErrorHandler();
    }
     
    ILI9341_SPI_nSS(1);
      isReady = RESET;
}

Well, I'm guessing I'm using the calback function wrong. Can you guys please help me? I' sure, I'm missing something. There is no way, that the SPI communication has that much delay between each byte transfer. 

Outcomes