Question

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

Was it helpful?

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?)

OTHER TIPS

DMA completion can be both polled or interrupt driven. The details are in the reference manual for your specific part - "STM32 Cortex-M3" is not specific enough to narrow it down to the document you need, but you can download it from ST's website.

The simplest way to implement DMA is to use the STM32 Stanadard Peripheral Library. It includes example projects for all peripherals including both DMA polling and DMA interrupt examples for the USART. Your tool-chain may already include the library, but possibly not all the examples. Even if you already have the library, it is a good idea to check that it is the latest revision.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top