cancel
Showing results for 
Search instead for 
Did you mean: 

How to use two preipherals with the same DMAxStreamY

Hjalmar NIlsson
Associate
Posted on January 31, 2017 at 17:00

Hi,

I'm having no problem using the DMA in basic functionality,  but I've run into something I can't figure out by my self.

I'm having a STM32F207 processor and try to use SPI2 at the same time as UART4.

the TX interrupts of these peripherals are on the same DMA1Stream4 but different channels (0 and 4).

Obviously I need to share the interrupt of these two DMA TXCI (tx complete interrupt) but HOW on earth do I distinguage between the two? Also, CAN I use both channels at the same time on the same stream or do I in software need a mutex to know if the stream is free to use? (the ref man claims there's an arbitrator between different channels).

I don't see how I can, while for instance a long DMA to UART 4 is running, configure the same DMA but different channel to start a transfer to the SPI2 port since I can't write to the DMA1S4PAR register if the DMA1S4CR EN bit is set, and it will be set since I've started the UART4 transfer.

What am I missing?

kind regards

Hjalmar

1 ACCEPTED SOLUTION

Accepted Solutions
Posted on January 31, 2017 at 20:41

>>

What am I missing?

You can't do that. You can select one channel from each stream.

Each stream is a singular resources, there may be other Streams that support the same peripheral and you'll have to juggle the ones you want to use with the options provided.

You could use a mutex to manage the resource, but you may need to reconfigure the DMA and/or peripheral to achieve the switch-over.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

2 REPLIES 2
Posted on January 31, 2017 at 20:41

>>

What am I missing?

You can't do that. You can select one channel from each stream.

Each stream is a singular resources, there may be other Streams that support the same peripheral and you'll have to juggle the ones you want to use with the options provided.

You could use a mutex to manage the resource, but you may need to reconfigure the DMA and/or peripheral to achieve the switch-over.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on January 31, 2017 at 21:28

+1

In particular, SPI2_TX nor UART4_TX has an alternative stream to use, so you can't use DMA triggered by these resources simultaneously. However, workarounds may be possible - for example, timing for UART TX can be well calculated so the UART DR can be fed from a timer-triggered DMA.

JW