cancel
Showing results for 
Search instead for 
Did you mean: 

CubeMX not generating all needed DMA_HandleType inits when Circular SPI transfer is selected?

devinw
Associate III

Using STM32H533RE and successfully got SPI1 doing DMA transfers with HAL_SPI_Transmit_DMA() one shot at a time. As soon as I select Circular transfer and re-gen, the above function fails because a bunch of fields in my 

DMA_HandleType for that DMA channel are left at 0. I get a bunch of NEW inits for the 
DMA_NodeConfTypeDef. I decided to cut and paste the handful of items from the old HAL_SPI_MspInit() when in non-circular mode, and paste them into the circular config re-generated HAL_SPI_MspInit() and voila DMA SPI in circular mode works fine. 
 
Is this a cube MX bug? Or am I missing something?
 
See attached screenshots
1 ACCEPTED SOLUTION

Accepted Solutions

Hello @devinw 

I appreciate your contribution.

A ticket  182039 has been raised to dev team to fix this issue . 

As a simple  workaround , try to add the following line of code 

 

handle_GPDMA1_Channel4.Init = NodeConfig.Init;

 

 Here 

 handle_GPDMA1_Channel4.Instance = GPDMA1_Channel4;

 handle_GPDMA1_Channel4.InitLinkedList.Priority = DMA_LOW_PRIORITY_HIGH_WEIGHT;

 handle_GPDMA1_Channel4.InitLinkedList.LinkStepMode = DMA_LSM_FULL_EXECUTION;

 handle_GPDMA1_Channel4.InitLinkedList.LinkAllocatedPort = DMA_LINK_ALLOCATED_PORT0;

 handle_GPDMA1_Channel4.InitLinkedList.TransferEventMode = DMA_TCEM_BLOCK_TRANSFER;

 handle_GPDMA1_Channel4.InitLinkedList.LinkedListMode = DMA_LINKEDLIST_CIRCULAR;

if (HAL_DMAEx_List_Init(&handle_GPDMA1_Channel4) != HAL_OK)

 {

 Error_Handler();

 }



if (HAL_DMAEx_List_LinkQ(&handle_GPDMA1_Channel4, &List_GPDMA1_Channel4) != HAL_OK)

 {

 Error_Handler();

 }



 __HAL_LINKDMA(hspi, hdmatx, handle_GPDMA1_Channel4);



if (HAL_DMA_ConfigChannelAttributes(&handle_GPDMA1_Channel4, DMA_CHANNEL_NPRIV) != HAL_OK)

 {

 Error_Handler();

 }



/* SPI1 interrupt Init */

 HAL_NVIC_SetPriority(SPI1_IRQn, 0, 0);

 HAL_NVIC_EnableIRQ(SPI1_IRQn);

/* USER CODE BEGIN SPI1_MspInit 1 */

 handle_GPDMA1_Channel4.Init = NodeConfig.Init;

/* USER CODE END SPI1_MspInit 1 */

 }

View solution in original post

8 REPLIES 8
Ghofrane GSOURI
ST Employee

Hello @devinw 

First let me thank you for posting.

I would appreciate it if you could share your IOC so that I can verify your configuration.

I will be waiting for your feedback.

THX

Ghofrane

Thanks Ghofrane. IOC file is attached!

Hello @devinw 

Could you please try to use the latest version of CubeMX 6.13.0 .It could help you solve the issue .

I will be waiting for your feedback.

THX 

Ghofrane

Hi Ghofrane,  I updated to MX 6.13.0, which actually also updated my H5 FW from 1.2.0 to 1.4.0 and migrated the project for the new FW but the problem still persists. My SPI MSP init is missing all this:

Need but missing:

handle_GPDMA1_Channel4.Init.Request = GPDMA1_REQUEST_SPI1_TX;
handle_GPDMA1_Channel4.Init.BlkHWRequest = DMA_BREQ_SINGLE_BURST;
handle_GPDMA1_Channel4.Init.Direction = DMA_MEMORY_TO_PERIPH;
handle_GPDMA1_Channel4.Init.SrcInc = DMA_SINC_INCREMENTED;
handle_GPDMA1_Channel4.Init.DestInc = DMA_DINC_FIXED;
handle_GPDMA1_Channel4.Init.SrcDataWidth = DMA_SRC_DATAWIDTH_WORD;
handle_GPDMA1_Channel4.Init.DestDataWidth = DMA_DEST_DATAWIDTH_WORD;
handle_GPDMA1_Channel4.Init.SrcBurstLength = 1;
handle_GPDMA1_Channel4.Init.DestBurstLength = 1;
handle_GPDMA1_Channel4.Init.Mode = DMA_NORMAL;

 

Generated OK by MX:

handle_GPDMA1_Channel4.Instance = GPDMA1_Channel4;
handle_GPDMA1_Channel4.InitLinkedList.Priority = DMA_LOW_PRIORITY_HIGH_WEIGHT;
handle_GPDMA1_Channel4.InitLinkedList.LinkStepMode = DMA_LSM_FULL_EXECUTION;
handle_GPDMA1_Channel4.InitLinkedList.LinkAllocatedPort = DMA_LINK_ALLOCATED_PORT0;
handle_GPDMA1_Channel4.InitLinkedList.TransferEventMode = DMA_TCEM_BLOCK_TRANSFER;
handle_GPDMA1_Channel4.InitLinkedList.LinkedListMode = DMA_LINKEDLIST_CIRCULAR;

 

I should note, I also get these parameters, which look similar to the stuff I'm missing, BUT HAL_SPITransmitDMA() does not seem to know to look to the "node" type struct to get the info. It's always looking in the regular DMA_HandleType.

 

/* GPDMA1_REQUEST_SPI1_TX Init */
NodeConfig.NodeType = DMA_GPDMA_LINEAR_NODE;
NodeConfig.Init.Request = GPDMA1_REQUEST_SPI1_TX;
NodeConfig.Init.BlkHWRequest = DMA_BREQ_SINGLE_BURST;
NodeConfig.Init.Direction = DMA_MEMORY_TO_PERIPH;
NodeConfig.Init.SrcInc = DMA_SINC_INCREMENTED;
NodeConfig.Init.DestInc = DMA_DINC_FIXED;
NodeConfig.Init.SrcDataWidth = DMA_SRC_DATAWIDTH_WORD;
NodeConfig.Init.DestDataWidth = DMA_DEST_DATAWIDTH_WORD;
NodeConfig.Init.SrcBurstLength = 1;
NodeConfig.Init.DestBurstLength = 1;
NodeConfig.Init.TransferAllocatedPort = DMA_SRC_ALLOCATED_PORT0|DMA_DEST_ALLOCATED_PORT0;
NodeConfig.Init.TransferEventMode = DMA_TCEM_BLOCK_TRANSFER;
NodeConfig.Init.Mode = DMA_NORMAL;
NodeConfig.TriggerConfig.TriggerMode = DMA_TRIGM_BLOCK_TRANSFER;
NodeConfig.TriggerConfig.TriggerPolarity = DMA_TRIG_POLARITY_RISING;
NodeConfig.TriggerConfig.TriggerSelection = GPDMA1_TRIGGER_TIM2_TRGO;
NodeConfig.DataHandlingConfig.DataExchange = DMA_EXCHANGE_NONE;
NodeConfig.DataHandlingConfig.DataAlignment = DMA_DATA_RIGHTALIGN_ZEROPADDED;

Hello @devinw 

I appreciate your contribution.

A ticket  182039 has been raised to dev team to fix this issue . 

As a simple  workaround , try to add the following line of code 

 

handle_GPDMA1_Channel4.Init = NodeConfig.Init;

 

 Here 

 handle_GPDMA1_Channel4.Instance = GPDMA1_Channel4;

 handle_GPDMA1_Channel4.InitLinkedList.Priority = DMA_LOW_PRIORITY_HIGH_WEIGHT;

 handle_GPDMA1_Channel4.InitLinkedList.LinkStepMode = DMA_LSM_FULL_EXECUTION;

 handle_GPDMA1_Channel4.InitLinkedList.LinkAllocatedPort = DMA_LINK_ALLOCATED_PORT0;

 handle_GPDMA1_Channel4.InitLinkedList.TransferEventMode = DMA_TCEM_BLOCK_TRANSFER;

 handle_GPDMA1_Channel4.InitLinkedList.LinkedListMode = DMA_LINKEDLIST_CIRCULAR;

if (HAL_DMAEx_List_Init(&handle_GPDMA1_Channel4) != HAL_OK)

 {

 Error_Handler();

 }



if (HAL_DMAEx_List_LinkQ(&handle_GPDMA1_Channel4, &List_GPDMA1_Channel4) != HAL_OK)

 {

 Error_Handler();

 }



 __HAL_LINKDMA(hspi, hdmatx, handle_GPDMA1_Channel4);



if (HAL_DMA_ConfigChannelAttributes(&handle_GPDMA1_Channel4, DMA_CHANNEL_NPRIV) != HAL_OK)

 {

 Error_Handler();

 }



/* SPI1 interrupt Init */

 HAL_NVIC_SetPriority(SPI1_IRQn, 0, 0);

 HAL_NVIC_EnableIRQ(SPI1_IRQn);

/* USER CODE BEGIN SPI1_MspInit 1 */

 handle_GPDMA1_Channel4.Init = NodeConfig.Init;

/* USER CODE END SPI1_MspInit 1 */

 }

Much appreciated!

 

And that is a smart idea to copy the init struct like that for the workaround. I will try this. That's a clean one-line solution :).

handle_GPDMA1_Channel4.Init = NodeConfig.Init

added to User code section of SPI NSP init function works great as a quick workaround. Thanks.