Search code examples
armembeddedcortex-mdma

Is it possible to detect when a DMA channel on a Cortex M3 goes idle?


I've just taken over a project developing C code for an STM32 Cortex M3 microcontroller.

An issue that I immediately have is that I have a free running DMA channel that transfers data between 2 USARTs, but on occasions data from another source needs to be sent to the destination USART.

Is there any way to detect when a DMA is busy transferring data or idle, or are there any interrupts triggered when a transfer is complete.

Many thanks for any responses,

Dave


Solution

  • Here is what I do to check if the DMA operation has completed:

    DMA_Cmd(DMA2_Channel5, ENABLE); // start
    while (!DMA_GetFlagStatus(DMA2_FLAG_TC5)); // wait to finish
    DMA_ClearFlag(DMA2_FLAG_TC5); // clear flag (needed?)