Skip to main content
Graduate
December 31, 2023
Solved

SPI DMA Correct Implementation

  • December 31, 2023
  • 2 replies
  • 1321 views

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.
    Best answer by AScha.3

    afaik you need it to do this way:

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

     

    2 replies

    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 

    AScha.3Answer
    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");

     

    LinkpadAuthor
    Graduate
    January 8, 2024

    Hi,

    Thanks for the explanation I now understand!