2021-11-09 04:52 AM
Hi,
I have seen this some time ago in another thread:
I am kind of repeating the questions in that last thread, because I did not see any final answer.
Still in FW H7 v1.9.0 the problem persists. In stm32h7xx_hal_spi.c using the DMA the TxCpltCallback is never called if not in circular mode.
static void SPI_DMATransmitCplt(DMA_HandleTypeDef *hdma)
{
SPI_HandleTypeDef *hspi = (SPI_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
if (hspi->State != HAL_SPI_STATE_ABORT)
{
if (hspi->hdmatx->Init.Mode == DMA_CIRCULAR)
{
#if (USE_HAL_SPI_REGISTER_CALLBACKS == 1UL)
hspi->TxCpltCallback(hspi);
#else
HAL_SPI_TxCpltCallback(hspi);
#endif /* USE_HAL_SPI_REGISTER_CALLBACKS */
}
else
{
/* Enable EOT interrupt */
__HAL_SPI_ENABLE_IT(hspi, SPI_IT_EOT);
}
}
}
What is the reason for hiding that TxCpltCallback?
Solved! Go to Solution.
2021-11-09 05:52 AM
It should be triggered at the end of transfer in HAL_SPI_IRQHandler, here:
It is called when the EOT bit is set:
If that's not happening, you could look into why EOT isn't being set or isn't being handled properly.
2021-11-09 05:52 AM
It should be triggered at the end of transfer in HAL_SPI_IRQHandler, here:
It is called when the EOT bit is set:
If that's not happening, you could look into why EOT isn't being set or isn't being handled properly.
2021-11-09 11:27 PM
Hi TDK,
you are right about the EOT IRQ calling the callback. I concede, that if I enable the global SPI Interrupt (in addition to the DMA Interrupt) the callback is called and works well.
But why is it not called directly from the DMA Interrupt? It seems like a waste of cycles to call another interrupt from there, although there is some flag handling and the closing of the transfer that would otherwise be needed in the dma irq.
Anyway to summarize: For callback to work in DMA the DMA Stream interrupt and also the SPI global Interrupt is needed.