Skip to main content
Associate II
December 31, 2023
Solved

SPI DMA Correct Implementation

Hi, I am trying to use DMA in my project for SPI and noticed there are 2 type definitions as below:-

 

 

SPI_HandleTypeDef hspi1;
DMA_HandleTypeDef hdma_spi1_tx;

 

 

Which one do I need to use for SPI transmission as I am having problems using 'hspi1' as below:-

 

 

HAL_SPI_Transmit_DMA(&hspi1, "Test",sizeof"Test");

HAL_SPI_Transmit_DMA(&hdma_spi1_tx, "Test",sizeof"Test");

 

 

 I just wasn't sure which handle was the correct to use...

This topic has been closed for replies.
AScha.3
AScha.3Best answer
Super User
December 31, 2023

afaik you need it to do this way:

HAL_DMA_Init(&hdma_spi1_tx);
HAL_SPI_Transmit_DMA(&hspi1, "Test",sizeof"Test");

 

If you feel a post has answered your question, please click on " Best Answer ".

3 replies

STTwo-32
ST Technical Moderator
December 31, 2023

Hello @Linkpad 

I suggest you to take a look at the following example to understand how the spi dma configuration works exactly. 

Best Regards.

STTwo-32 

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.
AScha.3
AScha.3Best answer
Super User
December 31, 2023

afaik you need it to do this way:

HAL_DMA_Init(&hdma_spi1_tx);
HAL_SPI_Transmit_DMA(&hspi1, "Test",sizeof"Test");

 

If you feel a post has answered your question, please click on " Best Answer ".
LinkpadAuthor
Associate II
January 8, 2024

Hi,

Thanks for the explanation I now understand!