Skip to main content
Visitor II
April 25, 2025
Question

linked-list GPDMA to SPI TX triggered by timer15 TRGO does not work

  • April 25, 2025
  • 1 reply
  • 451 views
/**
 * @brief DMA Linked-list yWaveQ configuration
 * @PAram None
 * @retval None
 */
HAL_StatusTypeDef MX_yWaveQ_Config(void)
{
 HAL_StatusTypeDef ret = HAL_OK;
 /* DMA node configuration declaration */
 DMA_NodeConfTypeDef pNodeConfig;

 /* Set node configuration ################################################*/
 pNodeConfig.NodeType = DMA_GPDMA_LINEAR_NODE;
 pNodeConfig.Init.Request = GPDMA1_REQUEST_SPI3_TX;
 pNodeConfig.Init.BlkHWRequest = DMA_BREQ_SINGLE_BURST;
 pNodeConfig.Init.Direction = DMA_MEMORY_TO_PERIPH;
 pNodeConfig.Init.SrcInc = DMA_SINC_INCREMENTED;
 pNodeConfig.Init.DestInc = DMA_DINC_FIXED;
 pNodeConfig.Init.SrcDataWidth = DMA_SRC_DATAWIDTH_BYTE;
 pNodeConfig.Init.DestDataWidth = DMA_DEST_DATAWIDTH_BYTE;
 pNodeConfig.Init.SrcBurstLength = 2;
 pNodeConfig.Init.DestBurstLength = 1;
 pNodeConfig.Init.TransferAllocatedPort = DMA_SRC_ALLOCATED_PORT0|DMA_DEST_ALLOCATED_PORT1;
 pNodeConfig.Init.TransferEventMode = DMA_TCEM_BLOCK_TRANSFER;
 pNodeConfig.TriggerConfig.TriggerMode = DMA_TRIGM_SINGLE_BURST_TRANSFER ;
 pNodeConfig.TriggerConfig.TriggerPolarity = DMA_TRIG_POLARITY_RISING;
 pNodeConfig.TriggerConfig.TriggerSelection = GPDMA1_TRIGGER_TIM15_TRGO;
 pNodeConfig.DataHandlingConfig.DataExchange = DMA_EXCHANGE_NONE;
 pNodeConfig.DataHandlingConfig.DataAlignment = DMA_DATA_RIGHTALIGN_ZEROPADDED;
 pNodeConfig.SrcAddress = (uint32_t)SpiTable[0];
 pNodeConfig.DstAddress = (uint32_t)&(SPI3->TXDR);
 pNodeConfig.DataSize = 8;

 /* Build DMASpi1 Node */
 ret |= HAL_DMAEx_List_BuildNode(&pNodeConfig, &DMASpi1);

 /* Insert DMASpi1 to Queue */
 ret |= HAL_DMAEx_List_InsertNode_Tail(&yWaveQ, &DMASpi1);

 /* Set node configuration ################################################*/
 pNodeConfig.SrcAddress = (uint32_t)SpiTable[1];

 /* Build DMASpi2 Node */
 ret |= HAL_DMAEx_List_BuildNode(&pNodeConfig, &DMASpi2);

 /* Insert DMASpi2 to Queue */
 ret |= HAL_DMAEx_List_InsertNode_Tail(&yWaveQ, &DMASpi2);

 ret |= HAL_DMAEx_List_SetCircularModeConfig(&yWaveQ, &DMASpi1);

 return ret;
}
 MX_yWaveQ_Config();
 HAL_DMAEx_List_LinkQ(&handle_GPDMA1_Channel2, &yWaveQ);
 HAL_DMAEx_List_Start(&handle_GPDMA1_Channel2);
 __HAL_SPI_ENABLE(&hspi3);
 HAL_TIM_Base_Start(&htim15);

There is no output observed at SPI SCK pin.

Any suggestion is welcome.

    This topic has been closed for replies.

    1 reply

    ST Employee
    May 6, 2025

    Hello @dh_leslie

    Have you verified that TIM15 is running and generating the trigger signal as expected? 

    dh_leslieAuthor
    Visitor II
    May 7, 2025

    Yes, TIM15 is running and triggers spi tx periodly as expected. But I cannot solve the delay issue.

    ST Employee
    May 7, 2025

    For the delay issue, ensure that the burst length (SrcBurstLength and DestBurstLength) are optimized for your application, same for data width.

    Another path is low spi baudrate? we don't have this information in the code section you provided