2024-12-08 09:38 PM
How to cancel HAL_SPI_TransmitReceive_DMA
We are developing SPI communication devices using HAL_SPI_TransmitReceive_DMA.
We would like to cancel or stop HAL_SPI_TransmitReceive_DMA even in the middle of transmission by GPIO interrupt, but we do not know how to do it.
Is it possible to cancel in the middle of transmission?
Also, how should I program it?
Solved! Go to Solution.
2024-12-08 10:36 PM
If you are using SPI to access a large amount of data in SPI flash in a single operation, then you need to stop the DMA operation in some situation. I don't see any stopping DMA mechanism inside HAL_SPI_TransmitReceive_DMA API. I think you might implement your own SPI DMA functions in which you can inject the GPIO interrupt or polling this GPIO to determine whether or not to exit DMA mode. To do this, you need to dig into how the SPI DMA works, which is not in a quick kick.
In the same time you might need a strategy to process the available data transmitted or received.
2024-12-08 10:36 PM
If you are using SPI to access a large amount of data in SPI flash in a single operation, then you need to stop the DMA operation in some situation. I don't see any stopping DMA mechanism inside HAL_SPI_TransmitReceive_DMA API. I think you might implement your own SPI DMA functions in which you can inject the GPIO interrupt or polling this GPIO to determine whether or not to exit DMA mode. To do this, you need to dig into how the SPI DMA works, which is not in a quick kick.
In the same time you might need a strategy to process the available data transmitted or received.
2024-12-09 01:29 AM
@NEdom.1 wrote:you might need a strategy to process the available data transmitted or received.
also to ensure that the Slave is left in a "sensible" state ...