cancel
Showing results for 
Search instead for 
Did you mean: 

How to use DMAMUX on the STM32 microcontrollers

ST AME Support NF
ST Employee

How do I use DMAMUX on the STM32 microcontrollers?

1- Introduction

DMAMUX is included in the latest STM32 microcontrollers (STM32H7/G0/G4/L4+/L5/WB/MP1 Series) and is an enhancement over the previous DMA controller, providing more flexibility and fully dynamic peripheral request mapping over pseudo-dynamic mapping.

It offers fully configurable routing of any DMA request from a given peripheral to any DMA controller and/or controller DMA channel. This article will briefly explain the DMAMUX as well as how to use it.

2- Description of DMAMUX

The DMAMUX request multiplexer enables routing DMA request lines from the peripherals to the DMA controllers in the products. The routing function is ensured by a programmable multi-channel DMA request line multiplexer. Each channel selects a unique DMA request line to forward (unconditionally or synchronously) to the associated DMA controller channel. This allows DMA requests to be managed with a high flexibility, maximizing the number of DMA requests that run concurrently.
1904.png

3- DMAMUX features
1905.png

​​​​​​Features include:
  • Request routing and synchronization
  • Request generation
  • Request generation and synchronization

4- DMAMUX configuration example

The DMAMUX is easy to use and configure with STM32CubeMX and its flexibility will be shown in this section.
This example uses the STM32G071RBTx as the target device. The SPI peripheral will be configured to use DMAMUX for serial communication with another device. Using STM32CubeMX for the configuration will illustrate the ease of use and flexibility of DMAMUX.
The first step within STM32CubeMX is to enable the SPI peripheral that is going to be used for serial communication (see figure below):
1906.png
The next step is to click on DMA Settings to make those configurations:
1907.png
We are going to add two DMA Requests, one for SPI RX (reception) and one for SPI TX (transmission). To do this click on Add.
1908.png
Now click on Select in the drop-down box and then click on SPI1_RX.
1909.png
Because of DMAMUX's flexibility you can select any DMA channel for the peripheral you are using. In this example case, channel 3 is selected by clicking on the drop-down box and clicking on DMA1 Channel 3.
1910.png
The next step is to select the DMAMUX channel for SPI1_TX.  Again, due to the flexibility of DMAMUX, any channel is available and channel 7 is used in this example.
1911.png
As illustrated in this example, DMAMUX offers the flexibility to select any DMA channel to be used with the peripherals as opposed to being limited to a specific channel.
More details including the advanced features of DMAMUX are described in the associated application note mentioned in the Links section.

5- Links

For more details on DMAMUX please refer to the following Application Note:
STM32 DMAMUX: the DMA request router - Application note
For more information about STM32CubeMX, please refer to the webpage.
 

Comments

This (and AN5224) is completely incorrect, because

  • in single-port DMA channels are 1-indexed, i.e. DMAMUX channel 0 corresponds to DMA channel 1
  • in dual-port DMA, indexing is OK but the transfer elements are called Streams rather than Channels
  • in some STM32 one DMAMUX serves several DMA units (e.g. in higher-end 'G0), i.e. the mapping is offset

I've ranted about this for years, e.g. https://community.st.com/s/question/0D53W000006s8dISAQ/dmamux-to-dma-channelstream-numbering-discrepancy, and while RM0440 I mentioned specifically there has been subsequently fixed, RM0444 for example does not mention the mapping not even in the incorrect way. I of course won't check all RMs containing DMAMUX (hence needing this subchapter) for ST. By now, I am tired by repeating the same thing again and again, just because ST "fixes" one particular "complaint/ticket" but can't communicate a broader issue internally.

That you magically fix it up in various Cubes is entirely irrelevant.

Btw. AN5224 is an opportunity to give an overview of all instances of DMAMUX and all mappings.

JW

@ST AME Support NF​ 

@Imen DAHMEN​ 

MWagn.5
Associate

Thanks a lot. The fixed RM0440 saved me quite some time. Nether the less the DMAMUX chapter still is a mess. The difference between "unconditional request forwarding" and "conditional request forwarding" is not described. Without AN5224 it is really hard to understand the DMAMUX. Also Figure 32 of RM0440 is missing (page 428), which should be equal or similar to Figure 2 of AN5224 (or the second Figure on this page).

I'm referring to revision 7 of RM0440 and revision 5 of AN5224.

Version history
Last update:
‎2021-09-16 12:59 AM
Updated by: