2025-04-29 5:07 AM - last edited on 2025-05-02 3:37 AM by Amel NASRI
Hi,
I'm just struggling with the same problem. I use SPI with DMA non-circular mode and want a callback for receive complete.
I can set the callback function with HAL_DMA_RegisterCallback but in HAL_SPI_TransmitReceive_DMA it will be overwritten:
/* Set the SPI Tx/Rx DMA Half transfer complete callback */
hspi->hdmarx->XferHalfCpltCallback = SPI_DMAHalfTransmitReceiveCplt;
hspi->hdmarx->XferCpltCallback = SPI_DMATransmitReceiveCplt;
Edit: Post moved from original thread How to know the when the DMA transfer done?, to give a chance to be answered. Please precise if you are using U5 as original one.
2025-05-02 8:11 AM
Hello @STmine
Could you provide more details about the issue please.
What is the MCU you are using?
I can set the callback function with HAL_DMA_RegisterCallback but in HAL_SPI_TransmitReceive_DMA it will be overwritten:
/* Set the SPI Tx/Rx DMA Half transfer complete callback */ hspi->hdmarx->XferHalfCpltCallback = SPI_DMAHalfTransmitReceiveCplt; hspi->hdmarx->XferCpltCallback = SPI_DMATransmitReceiveCplt;
What you want to say by overwritten? How it is overriten?
2025-05-02 8:32 AM
Hi @STmine
This post has been escalated to the ST Online Support Team for additional assistance. We'll contact you directly.
Regards,
Billy
2025-05-02 8:35 AM
The DMA callbacks are used internall by SPI HAL and should not be changed.
You can override HAL_SPI_TxCpltCallback function and friends, or register your own callback function with HAL_SPI_RegisterCallback.
hth
KnarfB