cancel
Showing results for 
Search instead for 
Did you mean: 

Send data 16bit over SPI using DMA

tinhlagi9947
Associate II
Posted on November 08, 2016 at 13:46

Hi,

I want to transfer data 16bit over SPI using DMA, Like that

SPI_Transmit(SPIx, (uint16_t) value, (uint16_t) count);

For driver ILI9341 function clear screen faster than using SPI mode 8 bit.

Many thanks.
4 REPLIES 4
ST Renegade
Senior
Posted on November 08, 2016 at 14:22

Hi diep.ha,

Your question is kinda vague. You need to provide more information what kind of issue you are facing. However are you familiar with the STM32CubeMX tool? It uses the Cube libraries, which is a HAL implementation for STM32 devices.

In the tool you can configure the SPI for your device and in the main function call the HAL_SPI_Transmit_DMA() function, which will do exactly what you are trying to achieve. 🙂

I hope this answers your question,

Have a nice day,

Renegade

Posted on November 08, 2016 at 18:03

Which STM32 part, specifically are you using now?

Can you provide details of the board, or the SPI channel used?

Can't the controller block fill memory? Or copy the frame buffer internally?

Which library are you using currently? No need to use a new one if you have a code based in the other.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on December 10, 2016 at 20:12

Changing from 8 bit to 16 bit may not change anything as in both cases the DMA is used. The only difference is the frequency of the stolen DMA cycles on the internal bus of the STM32. With DMA 8 or 16 bit, the SPI stream on the oscilloscope probed lines should have no delay between bytes. To clear faster a graphics controller, increasing the SPI clock frequency or using different controller frame memory buffer fill/command would be better.

Please note that some SPI can go faster than others (depend on what is their root clock) and max frequency is either SYSCLK /2 or /4.

Posted on December 21, 2016 at 03:27

Thanks for you repone,

I want to transfer fill color in screen ILI9341. I use function

ILI9341_Width = 320, ILI9341_Height = 240. Color in 16 bit

for (i = 0; i < 320; i++)

{

   for (j = 0; j < 240; j++)

   {

      // transmit 1 byte color over SPI

      HAL_SPI_Transmit(SPIx, color >> 8, 1);

      

HAL_SPI_Transmit(SPIx, color, 1);

   }

}

It's OK. But very slow. I search in google, use SPI DMA transfer faster but not implementation HAL driver. There is STM32 Standard Peripheral Libraries.

uint32_t pixel_count = 240 * 320;

SPI_Init_16Bit();    // Go to 16-bit SPI mode

/* Send first 65535 bytes */

SPI_DMA_SendHalfWord(SPIx, color, (pixels_count > 0xFFFF) ? 0xFFFF : pixels_count);

/* check again */

if (pixels_count > 0xFFFF)

   SPI_DMA_SendHalfWord(SPIx, color, pixels_count - 0xFFFF);

Many Thanks.