2017-01-31 08:00 AM
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
Solved! Go to Solution.
2017-01-31 11:41 AM
>>
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.
2017-01-31 11:41 AM
>>
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.
2017-01-31 01:28 PM
+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