Skip to main content
Explorer
December 9, 2024
Solved

How to cancel HAL_SPI_TransmitReceive_DMA

  • December 9, 2024
  • 1 reply
  • 889 views

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?

    This topic has been closed for replies.
    Best answer by NEdom.1

    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.

     

    1 reply

    NEdom.1Answer
    Graduate
    December 9, 2024

    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.

     

    Super User
    December 9, 2024

    @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 ...