Showing results for 
Search instead for 
Did you mean: 

GPDMA SPI tx+rx circular mode on STM32H5 possible incorrect initialization code

On a Nucleo-H563ZI with CubeIDE 1.14.0 and firmware package for H5 1.1.1.

I managed to get SPI transmit and receive using DMA, triggered by a timer, going not using linked lists. I get my requested number of transmissions and results into my buffers as witnessed on an oscilloscope and a live watchpoint.

But when I enable circular mode, no other modifications, in MX_SPI1_Init - HAL_SPI_Init - HAL_SPI_MspInit it sets up

 NodeConfig.Init.SrcDataWidth = DMA_SRC_DATAWIDTH_WORD;
NodeConfig.Init.DestDataWidth = DMA_DEST_DATAWIDTH_HALFWORD;

builds the node (whatever that is), inserts it into the correct DMA channel, sets circular mode, basically looks like magic but I can imagine what it is doing. But then the stuff in the NodeConfig doesn't get applied to handle_GPDMA1_Channel1, so later when I finally call HAL_SPI_TransmitReceive_DMA, it gets grumpy around line 2230 because hspi->hdmarx->Init is all zeros still. It never got updated maybe?

I think there is a problem with HAL_SPI_MspInit in stm32h5xx_hal_msp.c .



Andrei (from the Great (not very) White North)


Here's the project. 

In HAL_SPI_MspInit (in spi.c with separate files for each peripheral or main.c without), the initialization of NodeConfig.Init looks correct, but there doesn't seem to be any code to transfer it from NodeConfig.Init into the Init member of the spiHandle passed into the function.


Associate II

Were you able to solve this issue? I have been struggling to do something similar on the STMU5 MCU

I suppose I did.

SPI set up as a full-duplex master. With DMA for SPI TX set up as a standard request rather than a linked-list request, with trigger on TIM15 TRGO. SPI RX pretty much out of the box, peripheral to memory, source address increment disabled, destination enabled.

Transfers started using:

halStatus = HAL_SPI_TransmitReceive_DMA(&hspi1, (uint8_t*) &forceData, (uint8_t*) rawADCCounts, 


And then call HAL_SPI_TransmitReceive_DMA again in HAL_SPI_TxRxCpltCallback, or else it will stop automatically after one request.

But I gave up on using linked-list mode. I seem to remember finding a YouTube video from the ST MOOC for the H5 that went over DMA and used standard mode. They never went into linked-list mode and I was more interested in getting ANYTHING working than chasing the linked-list bone.



Got it. Okay I was able to get something similar working in linked-list mode by using this function: __HAL_LINKDMA(&hspi1, hdmarx, handle_GPDMA1_Channel15);