15. Direct memory access controller (DMA)

15.1 DMA introduction

Direct memory access (DMA) is used to provide high-speed data transfer between peripherals and memory and between memory and memory. Data can be quickly moved by DMA without any CPU action. This keeps CPU resources free for other operations.

The DMA controller combines a powerful dual AHB master bus architecture with independent FIFO to optimize the bandwidth of the system, based on a complex bus matrix architecture.

The two DMA controllers (DMA1, DMA2) have 8 streams each, dedicated to managing memory access requests from one or more peripherals.

Each DMA stream is driven by one DMAMUX1 output channel (request). Any DMAMUX1 output request can be individually programmed in order to select the DMA request source signal, from any of the 115 available request input signals.

Refer to the Section 17.3: DMAMUX implementation for more information about the DMA requests and streams mapping.

Each DMA controller has an arbiter for handling the priority between DMA requests.

15.2 DMA main features

The main DMA features are:

15.3 DMA functional description

15.3.1 DMA block diagram

The figure below shows the block diagram of a DMA.

DMA block diagram showing internal components like DMA controller, Arbitrer, FIFOs, AHB master, and slave programming interface, with external connections to DMAMUX1, NVIC, MDMA, Memory port, Peripheral port, and AHB bus.

Figure 83. DMA block diagram

The diagram illustrates the internal architecture of the DMA. On the left, eight input signals labeled dma_str0 through dma_str7 (grouped as 'From DMAMUX1') enter an 'Arbitrer' block. The 'Arbitrer' is connected to a 'DMA controller' block. Below the controller, there are eight 'FIFO' blocks, each associated with a stream (STREAM 0 to STREAM 7). Arrows indicate data flow from the controller through the FIFOs to two 'AHB master' blocks. The top 'AHB master' connects to a 'Memory port', and the bottom 'AHB master' connects to a 'Peripheral port'. A 'dma_hclk' signal enters from the right. Below the FIFOs, an 'AHB slave programming interface' block is connected to the controller and receives dma_it[0:7] and dma_tcif[0:7] signals. This interface connects to a 'Programming port' on the right, which is part of the 'AHB' bus. At the bottom left, arrows point 'To NVIC' and 'To MDMA'.

DMA block diagram showing internal components like DMA controller, Arbitrer, FIFOs, AHB master, and slave programming interface, with external connections to DMAMUX1, NVIC, MDMA, Memory port, Peripheral port, and AHB bus.

15.3.2 DMA internal signals

The table below shows the internal DMA signals.

Table 87. DMA internal input/output signals

Signal nameSignal typeDescription
dma_hclkDigital inputDMA AHB clock
dma_it[0:7]Digital outputsDMA stream [0:7] global interrupts
dma_tcif[0:7]Digital outputsMDMA triggers
dma_str[0:7]Digital inputDMA stream [0:7] requests

15.3.3 DMA overview

The DMA controller performs direct memory transfer: as an AHB master, the DMA controller can take the control of the AHB bus matrix to initiate AHB transactions.

The DMA controller carries out the following transactions:

The DMA controller provides two AHB master ports: the AHB memory port, intended to be connected to memories and the AHB peripheral port, intended to be connected to peripherals. However, to allow memory-to-memory transfers, the AHB peripheral port must also have access to the memories.

The AHB slave port is used to program the DMA controller (it supports only 32-bit accesses).

15.3.4 DMA transactions

A DMA transaction consists of a sequence of a given number of data transfers. The number of data items to be transferred and their width (8-bit, 16-bit or 32-bit) are software-programmable.

Each DMA transfer consists of three operations:

After an event, the peripheral sends a request signal to the DMA controller. The DMA controller serves the request depending on the channel priorities. As soon as the DMA controller accesses the peripheral, an Acknowledge signal is sent to the peripheral by the DMA controller. The peripheral releases its request as soon as it gets the Acknowledge signal from the DMA controller. Once the request has been deasserted by the peripheral, the DMA controller releases the Acknowledge signal. If there are more requests, the peripheral can initiate the next transaction.

15.3.5 DMA request mapping

The DMA request mapping from peripherals to DMA streams is described in Section 17.3: DMAMUX implementation .

15.3.6 Arbiter

An arbiter manages the 8 DMA stream requests based on their priority for each of the two AHB master ports (memory and peripheral ports) and launches the peripheral/memory access sequences.

Priorities are managed in two stages:

15.3.7 DMA streams

Each of the eight DMA controller streams provides a unidirectional transfer link between a source and a destination.

Each stream can be configured to perform:

The amount of data to be transferred (up to 65535) is programmable and related to the source width of the peripheral that requests the DMA transfer connected to the peripheral AHB port. The register that contains the amount of data items to be transferred is decremented after each transaction.

15.3.8 Source, destination and transfer modes

Both source and destination transfers can address peripherals and memories in the entire 4-Gbyte area, at addresses comprised between 0x0000 0000 and 0xFFFF FFFF.

The direction is configured using the DIR[1:0] bits in the DMA_SxCR register and offers three possibilities: memory-to-peripheral, peripheral-to-memory or memory-to-memory transfers.

The table below describes the corresponding source and destination addresses.

Table 88. Source and destination address

Bits DIR[1:0] of the DMA_SxCR registerDirectionSource addressDestination address
00Peripheral-to-memoryDMA_SxPARDMA_SxM0AR
01Memory-to-peripheralDMA_SxM0ARDMA_SxPAR

Table 88. Source and destination address (continued)

Bits DIR[1:0] of the DMA_SxCR registerDirectionSource addressDestination address
10Memory-to-memoryDMA_SxPARDMA_SxM0AR
11Reserved--

When the data width (programmed in the PSIZE or MSIZE bits in the DMA_SxCR register) is a half-word or a word, respectively, the peripheral or memory address written into the DMA_SxPAR or DMA_SxM0AR/M1AR registers has to be aligned on a word or half-word address boundary, respectively.

Peripheral-to-memory mode

Figure 84 describes this mode.

When this mode is enabled (by setting the bit EN in the DMA_SxCR register), each time a peripheral request occurs, the stream initiates a transfer from the source to fill the FIFO.

When the threshold level of the FIFO is reached, the contents of the FIFO are drained and stored into the destination.

The transfer stops once the DMA_SxNDTR register reaches zero, when the peripheral requests the end of transfers (in case of a peripheral flow controller) or when the EN bit in the DMA_SxCR register is cleared by software.

In direct mode (when the DMDIS value in the DMA_SxFCR register is 0), the threshold level of the FIFO is not used: after each single data transfer from the peripheral to the FIFO, the corresponding data are immediately drained and stored into the destination.

The stream has access to the AHB source or destination port only if the arbitration of the corresponding stream is won. This arbitration is performed using the priority defined for each stream using the PL[1:0] bits in the DMA_SxCR register.

Figure 84. Peripheral-to-memory mode

Figure 84. Peripheral-to-memory mode diagram. The diagram shows a DMA controller with an AHB memory port and an AHB peripheral port. Data flows from a peripheral source through a FIFO to the memory destination. The DMA controller includes registers DMA_SxM0AR, DMA_SxM1AR(1), and DMA_SxPAR. A peripheral DMA request is connected to the DMA stream x via the programmed DMAMUX. The diagram is labeled MSV41971V1.

The diagram illustrates the internal architecture of a DMA stream in peripheral-to-memory mode. A 'Peripheral source' on the right is connected to a 'Peripheral bus', which in turn connects to the 'AHB peripheral port' of the 'DMA controller'. Data from the peripheral source is transferred into a 'FIFO' (First In, First Out) buffer. The 'FIFO' has a 'FIFO level' indicator. Data from the FIFO is then transferred to the 'AHB memory port' of the 'DMA controller', which is connected to a 'Memory bus' and a 'Memory destination'. The 'DMA controller' also contains an 'Arbiter' block. A 'dma_strx' signal is input to the arbiter. The arbiter is connected to the 'FIFO' and the 'AHB memory port'. The 'DMA controller' also includes registers 'DMA_SxM0AR', 'DMA_SxM1AR (1) ', and 'DMA_SxPAR'. A 'Peripheral DMA request connected to the DMA stream x via the programmed DMAMUX' is shown at the bottom. The diagram is labeled 'MSV41971V1' in the bottom right corner.

Figure 84. Peripheral-to-memory mode diagram. The diagram shows a DMA controller with an AHB memory port and an AHB peripheral port. Data flows from a peripheral source through a FIFO to the memory destination. The DMA controller includes registers DMA_SxM0AR, DMA_SxM1AR(1), and DMA_SxPAR. A peripheral DMA request is connected to the DMA stream x via the programmed DMAMUX. The diagram is labeled MSV41971V1.

1. For double-buffer mode.

Memory-to-peripheral mode

Figure 85 describes this mode.

When this mode is enabled (by setting the EN bit in the DMA_SxCR register), the stream immediately initiates transfers from the source to entirely fill the FIFO.

Each time a peripheral request occurs, the contents of the FIFO are drained and stored into the destination. When the level of the FIFO is lower than or equal to the predefined threshold level, the FIFO is fully reloaded with data from the memory.

The transfer stops once the DMA_SxNDTR register reaches zero, when the peripheral requests the end of transfers (in case of a peripheral flow controller) or when the EN bit in the DMA_SxCR register is cleared by software.

In direct mode (when the DMDIS value in the DMA_SxFCR register is 0), the threshold level of the FIFO is not used. Once the stream is enabled, the DMA preloads the first data to transfer into an internal FIFO. As soon as the peripheral requests a data transfer, the DMA transfers the preloaded value into the configured destination. It then reloads again the empty internal FIFO with the next data to be transfer. The preloaded data size corresponds to the value of the PSIZE bitfield in the DMA_SxCR register.

The stream has access to the AHB source or destination port only if the arbitration of the corresponding stream is won. This arbitration is performed using the priority defined for each stream using the PL[1:0] bits in the DMA_SxCR register.

Figure 85. Memory-to-peripheral mode

Figure 85. Memory-to-peripheral mode diagram. The diagram shows a DMA controller connected to a memory source and a peripheral source. The DMA controller contains an Arbiter, a FIFO, and an AHB memory port. The Arbiter receives a 'dma_strx' signal and is connected to the FIFO. The FIFO is connected to the AHB memory port and the AHB peripheral port. The AHB memory port is connected to the Memory bus and the Memory source. The AHB peripheral port is connected to the Peripheral bus and the Peripheral source. The DMA controller also contains registers DMA_SxM0AR and DMA_SxM1AR(1) connected to the AHB memory port, and DMA_SxPAR connected to the AHB peripheral port. A note at the bottom indicates that the Peripheral DMA request is connected to the DMA stream x via the programmed DMAMUX. The diagram is labeled MSv41972V1.
Figure 85. Memory-to-peripheral mode diagram. The diagram shows a DMA controller connected to a memory source and a peripheral source. The DMA controller contains an Arbiter, a FIFO, and an AHB memory port. The Arbiter receives a 'dma_strx' signal and is connected to the FIFO. The FIFO is connected to the AHB memory port and the AHB peripheral port. The AHB memory port is connected to the Memory bus and the Memory source. The AHB peripheral port is connected to the Peripheral bus and the Peripheral source. The DMA controller also contains registers DMA_SxM0AR and DMA_SxM1AR(1) connected to the AHB memory port, and DMA_SxPAR connected to the AHB peripheral port. A note at the bottom indicates that the Peripheral DMA request is connected to the DMA stream x via the programmed DMAMUX. The diagram is labeled MSv41972V1.
  1. 1. For double-buffer mode.

Memory-to-memory mode

The DMA channels can also work without being triggered by a request from a peripheral. This is the memory-to-memory mode, described in Figure 86 .

When the stream is enabled by setting the Enable bit (EN) in the DMA_SxCR register, the stream immediately starts to fill the FIFO up to the threshold level. When the threshold level is reached, the FIFO contents are drained and stored into the destination.

The transfer stops once the DMA_SxNDTR register reaches zero or when the EN bit in the DMA_SxCR register is cleared by software.

The stream has access to the AHB source or destination port only if the arbitration of the corresponding stream is won. This arbitration is performed using the priority defined for each stream using the PL[1:0] bits in the DMA_SxCR register.

Note: When memory-to-memory mode is used, the circular and direct modes are not allowed.

Figure 86. Memory-to-memory mode

Figure 86. Memory-to-memory mode. A block diagram of the DMA controller in memory-to-memory mode. The DMA controller contains an Arbiter, a FIFO, and two AHB ports: an AHB memory port and an AHB peripheral port. The AHB memory port is connected to a Memory bus, which leads to Memory 2 destination. The AHB peripheral port is connected to a Peripheral bus, which leads to Memory 1 source. The FIFO is connected to both AHB ports. The Arbiter is connected to the FIFO and receives a Stream enable signal. The DMA controller also contains registers DMA_SxM0AR and DMA_SxM1AR(1) connected to the AHB memory port, and DMA_SxPAR connected to the AHB peripheral port. The diagram is labeled ai15950.
Figure 86. Memory-to-memory mode. A block diagram of the DMA controller in memory-to-memory mode. The DMA controller contains an Arbiter, a FIFO, and two AHB ports: an AHB memory port and an AHB peripheral port. The AHB memory port is connected to a Memory bus, which leads to Memory 2 destination. The AHB peripheral port is connected to a Peripheral bus, which leads to Memory 1 source. The FIFO is connected to both AHB ports. The Arbiter is connected to the FIFO and receives a Stream enable signal. The DMA controller also contains registers DMA_SxM0AR and DMA_SxM1AR(1) connected to the AHB memory port, and DMA_SxPAR connected to the AHB peripheral port. The diagram is labeled ai15950.

1. For double-buffer mode.

15.3.9 Pointer incrementation

Peripheral and memory pointers can optionally be automatically post-incremented or kept constant after each transfer depending on the PINC and MINC bits in the DMA_SxCR register.

Disabling the increment mode is useful when the peripheral source or destination data is accessed through a single register.

If the increment mode is enabled, the address of the next transfer is the address of the previous one incremented by 1 (for bytes), 2 (for half-words) or 4 (for words) depending on the data width programmed in the PSIZE or MSIZE bits in the DMA_SxCR register.

In order to optimize the packing operation, it is possible to fix the increment offset size for the peripheral address whatever the size of the data transferred on the AHB peripheral port. The PINCOS bit in the DMA_SxCR register is used to align the increment offset size with the data size on the peripheral AHB port, or on a 32-bit address (the address is then incremented by 4). The PINCOS bit has an impact on the AHB peripheral port only.

If the PINCOS bit is set, the address of the following transfer is the address of the previous one incremented by 4 (automatically aligned on a 32-bit address), whatever the PSIZE value. The AHB memory port, however, is not impacted by this operation.

15.3.10 Circular mode

The circular mode is available to handle circular buffers and continuous data flows (e.g. ADC scan mode). This feature can be enabled using the CIRC bit in the DMA_SxCR register.

When the circular mode is activated, the number of data items to be transferred is automatically reloaded with the initial value programmed during the stream configuration phase, and the DMA requests continue to be served.

Note: In the circular mode, it is mandatory to respect the following rule in case of a burst mode configured for memory:

\( DMA\_SxNDTR = \text{Multiple of } ((Mburst\ beat) \times (Msize)/(Psize)) \) , where:

For example: \( Mburst\ beat = 8 \) (INCR8), \( MSIZE = 00 \) (byte) and \( PSIZE = 01 \) (half-word), in this case: \( DMA\_SxNDTR \) must be a multiple of \( (8 \times 1/2 = 4) \) .

If this formula is not respected, the DMA behavior and data integrity are not guaranteed.

NDTR must also be a multiple of the Peripheral burst size multiplied by the peripheral data size, otherwise this could result in a bad DMA behavior.

15.3.11 Double-buffer mode

This mode is available for all the DMA1 and DMA2 streams.

The double-buffer mode is enabled by setting the DBM bit in the DMA_SxCR register.

A double-buffer stream works as a regular (single buffer) stream with the difference that it has two memory pointers. When the double-buffer mode is enabled, the circular mode is automatically enabled (CIRC bit in DMA_SxCR is not relevant) and at each end of transaction, the memory pointers are swapped.

In this mode, the DMA controller swaps from one memory target to another at each end of transaction. This allows the software to process one memory area while the second memory area is being filled/used by the DMA transfer. The double-buffer stream can work in both directions (the memory can be either the source or the destination) as described in Table 89 .

Note: In double-buffer mode, it is possible to update the base address for the AHB memory port on-the-fly (DMA_SxM0AR or DMA_SxM1AR) when the stream is enabled, by respecting the following conditions:

To avoid any error condition, it is advised to change the base address as soon as the TCIF flag is asserted because, at this point, the targeted memory must have changed from

memory 0 to 1 (or from 1 to 0) depending on the value of CT in the DMA_SxCR register in accordance with one of the two above conditions.

For all the other modes (except the double-buffer mode), the memory address registers are write-protected as soon as the stream is enabled.

Table 89. Source and destination address registers in double-buffer mode (DBM = 1)

Bits DIR[1:0] of the DMA_SxCR registerDirectionSource addressDestination address
00Peripheral-to-memoryDMA_SxPARDMA_SxM0AR / DMA_SxM1AR
01Memory-to-peripheralDMA_SxM0AR / DMA_SxM1ARDMA_SxPAR
10Not allowed (1)
11Reserved--
  1. 1. When the double-buffer mode is enabled, the circular mode is automatically enabled. Since the memory-to-memory mode is not compatible with the circular mode, when the double-buffer mode is enabled, it is not allowed to configure the memory-to-memory mode.

15.3.12 Programmable data width, packing/unpacking, endianness

The number of data items to be transferred has to be programmed into DMA_SxNDTR (number of data items to transfer bit, NDT) before enabling the stream (except when the flow controller is the peripheral, PFCTRL bit in DMA_SxCR is set).

When using the internal FIFO, the data widths of the source and destination data are programmable through the PSIZE and MSIZE bits in the DMA_SxCR register (can be 8-, 16- or 32-bit).

When PSIZE and MSIZE are not equal:

This packing/unpacking procedure may present a risk of data corruption when the operation is interrupted before the data are completely packed/unpacked. So, to ensure data coherence, the stream may be configured to generate burst transfers: in this case, each group of transfers belonging to a burst are indivisible (refer to Section 15.3.13 ).

In direct mode (DMDIS = 0 in the DMA_SxFCR register), the packing/unpacking of data is not possible. In this case, it is not allowed to have different source and destination transfer data widths: both are equal and defined by the PSIZE bits in the DMA_SxCR register. MSIZE bits are not relevant.

Table 90. Packing/unpacking and endian behavior (bit PINC = MINC = 1)

AHB memory port widthAHB peripheral port widthNumber of data items to transfer (NDT)Memory transfer numberMemory port address / byte lanePeripheral transfer numberPeripheral port address / byte lane
PINCOS = 1PINCOS = 0
88410x0 / B0[7:0]10x0 / B0[7:0]0x0 / B0[7:0]
20x1 / B1[7:0]20x4 / B1[7:0]0x1 / B1[7:0]
30x2 / B2[7:0]30x8 / B2[7:0]0x2 / B2[7:0]
40x3 / B3[7:0]40xC / B3[7:0]0x3 / B3[7:0]
816210x0 / B0[7:0]10x0 / B1B0[15:0]0x0 / B1B0[15:0]
20x1 / B1[7:0]20x4 / B3B2[15:0]0x2 / B3B2[15:0]
30x2 / B2[7:0]
40x3 / B3[7:0]
832110x0 / B0[7:0]10x0 / B3B2B1B0[31:0]0x0 / B3B2B1B0[31:0]
20x1 / B1[7:0]
30x2 / B2[7:0]
40x3 / B3[7:0]
168410x0 / B1B0[15:0]10x0 / B0[7:0]0x0 / B0[7:0]
20x2 / B3B2[15:0]20x4 / B1[7:0]0x1 / B1[7:0]
330x8 / B2[7:0]0x2 / B2[7:0]
440xC / B3[7:0]0x3 / B3[7:0]
1616210x0 / B1B0[15:0]10x0 / B1B0[15:0]0x0 / B1B0[15:0]
20x2 / B1B0[15:0]20x4 / B3B2[15:0]0x2 / B3B2[15:0]
1632110x0 / B1B0[15:0]10x0 / B3B2B1B0[31:0]0x0 / B3B2B1B0[31:0]
20x2 / B3B2[15:0]
328410x0 / B3B2B1B0[31:0]10x0 / B0[7:0]0x0 / B0[7:0]
220x4 / B1[7:0]0x1 / B1[7:0]
330x8 / B2[7:0]0x2 / B2[7:0]
440xC / B3[7:0]0x3 / B3[7:0]
3216210x0 / B3B2B1B0[31:0]10x0 / B1B0[15:0]0x0 / B1B0[15:0]
220x4 / B3B2[15:0]0x2 / B3B2[15:0]
3232110x0 / B3B2B1B0[31:0]10x0 / B3B2B1B0[31:0]0x0 / B3B2B1B0[31:0]

Note: Peripheral port may be the source or the destination (it can also be the memory source in the case of memory-to-memory transfer).

PSIZE, MSIZE and NDT[15:0] must be configured so as to ensure that the last transfer is not incomplete. This can occur when the data width of the peripheral port (PSIZE bits) is lower than the data width of the memory port (MSIZE bits). This constraint is summarized in the table below.

Table 91. Restriction on NDT versus PSIZE and MSIZE

PSIZE[1:0] of DMA_SxCRMSIZE[1:0] of DMA_SxCRNDT[15:0] of DMA_SxNDTR
00 (8-bit)01 (16-bit)Must be a multiple of 2
00 (8-bit)10 (32-bit)Must be a multiple of 4
01 (16-bit)10 (32-bit)Must be a multiple of 2

15.3.13 Single and burst transfers

The DMA controller can generate single transfers or incremental burst transfers of 4, 8, or 16 beats.

The size of the burst is configured by software independently for the two AHB ports by using the MBURST[1:0] and PBURST[1:0] bits in the DMA_SxCR register.

The burst size indicates the number of beats in the burst, not the number of bytes transferred.

To ensure data coherence, each group of transfers that form a burst are indivisible: AHB transfers are locked and the arbiter of the AHB bus matrix does not degrade the DMA master during the sequence of the burst transfer.

Depending on the single or burst configuration, each DMA request initiates a different number of transfers on the AHB peripheral port:

The same as above has to be considered for the AHB memory port considering the MBURST and MSIZE bits.

In direct mode, the stream can only generate single transfers and the MBURST[1:0] and PBURST[1:0] bits are forced by hardware.

The address pointers (DMA_SxPAR or DMA_SxM0AR registers) must be chosen so as to ensure that all transfers within a burst block are aligned on the address boundary equal to the size of the transfer.

The burst configuration has to be selected in order to respect the AHB protocol, where bursts must not cross the 1 Kbyte address boundary because the minimum address space that can be allocated to a single slave is 1 Kbyte. This means that the 1-Kbyte address boundary must not be crossed by a burst block transfer, otherwise an AHB error is generated, that is not reported by the DMA registers.

15.3.14 FIFO

FIFO structure

The FIFO is used to temporarily store data coming from the source before transmitting them to the destination.

Each stream has an independent 4-word FIFO and the threshold level is software-configurable between 1/4, 1/2, 3/4 or full.

To enable the use of the FIFO threshold level, the direct mode must be disabled by setting the DMDIS bit in the DMA_SxFCR register.

The structure of the FIFO differs depending on the source and destination data widths, and is described in the figure below.

Figure 87. FIFO structure

Figure 87. FIFO structure. Four diagrams showing FIFO organization for different source and destination data widths: byte-to-word, byte-to-half-word, half-word-to-word, and half-word-to-byte.

The figure illustrates four different FIFO structures based on source and destination data widths. Each structure is shown as a grid with 4 columns representing the fill level: Empty, 1/4, 1/2, 3/4, and Full. The rows represent byte lanes (0 to 3). Data is shown being shifted from left to right as the FIFO fills.

Source: byte, Destination: word

Empty1/41/23/4Full
byte lane 3B 15B 11B 7B 3Destination: word
W3, W2, W1, W0
byte lane 2B 14B 10B 6B 2
byte lane 1B 13B 9B 5B 1
byte lane 0W3B 12W2B 8W1

Source: byte, Destination: half-word

Empty1/41/23/4Full
byte lane 3B 15B 11B 7B 3Destination: half-word
H7, H6, H5, H4, H3, H2, H1, H0
byte lane 2H7B 14H5B 10H3
byte lane 1B 13B 9
byte lane 0H6B 12H4B 8H2

Source: half-word, Destination: word

Empty1/41/23/4Full
byte lane 3H7H5Destination: word
W3, W2, W1, W0
byte lane 2
byte lane 1H6H4
byte lane 0W3W2W1

Source: half-word, Destination: byte

Empty1/41/23/4Full
byte lane 3B 15B 11Destination: byte
B15 B14 B13 B12 B11 B10 B9 B8
B7 B6 B5 B4 B3 B2 B1 B0
byte lane 2H7B 14H5B 10H3
byte lane 1B 13B 9
byte lane 0H6B 12H4B 8H2

ai15951

Figure 87. FIFO structure. Four diagrams showing FIFO organization for different source and destination data widths: byte-to-word, byte-to-half-word, half-word-to-word, and half-word-to-byte.

FIFO threshold and burst configuration

Caution is required when choosing the FIFO threshold (bits FTH[1:0] of the DMA_SxFCR register) and the size of the memory burst (MBURST[1:0] of the DMA_SxCR register). The content pointed by the FIFO threshold must exactly match an integer number of memory burst transfers. If this is not in the case, a FIFO error (flag FEIFx of the DMA_HISR or DMA_LISR register) is generated when the stream is enabled, then the stream is automatically disabled. The allowed and forbidden configurations are described in the table below. The forbidden configurations are highlighted in gray in the table.

Table 92. FIFO threshold configurations

MSIZEFIFO levelMBURST = INCR4MBURST = INCR8MBURST = INCR16
Byte1/41 burst of 4 beatsForbiddenForbidden
1/22 bursts of 4 beats1 burst of 8 beats
3/43 bursts of 4 beatsForbidden
Full4 bursts of 4 beats2 bursts of 8 beats1 burst of 16 beats
Half-word1/4ForbiddenForbiddenForbidden
1/21 burst of 4 beats
3/4Forbidden
Full2 bursts of 4 beats1 burst of 8 beats
Word1/4ForbiddenForbiddenForbidden
1/2
3/4
Full1 burst of 4 beats

In all cases, the burst size multiplied by the data size must not exceed the FIFO size (data size can be: 1 (byte), 2 (half-word) or 4 (word)).

Incomplete burst transfer at the end of a DMA transfer may happen if one of the following conditions occurs:

In such cases, the remaining data to be transferred is managed in single mode by the DMA, even if a burst transaction is requested during the DMA stream configuration.

Note: When burst transfers are requested on the peripheral AHB port and the FIFO is used (DMDIS = 1 in the DMA_SxCR register), it is mandatory to respect the following rule to avoid permanent underrun or overrun conditions, depending on the DMA stream direction:

If \( (PBURST imes PSIZE) = FIFO\_SIZE \) (4 words), \( FIFO\_Threshold = 3/4 \) is forbidden with \( PSIZE = 1, 2 \) or \( 4 \) and \( PBURST = 4, 8 \) or \( 16 \) .

This rule ensures that enough FIFO space at a time is free to serve the request from the peripheral.

FIFO flush

The FIFO can be flushed when the stream is disabled by resetting the EN bit in the DMA_SxCR register and when the stream is configured to manage peripheral-to-memory or memory-to-memory transfers. If some data are still present in the FIFO when the stream is disabled, the DMA controller continues transferring the remaining data to the destination (even though stream is effectively disabled). When this flush is completed, the transfer complete status bit (TCIFx) in the DMA_LISR or DMA_HISR register is set.

The remaining data counter DMA_SxNDTR keeps the value in this case to indicate how many data items are currently available in the destination memory.

Note that during the FIFO flush operation, if the number of remaining data items in the FIFO to be transferred to memory (in bytes) is less than the memory data width (for example 2 bytes in FIFO while MSIZE is configured to word), data is sent with the data width set in the MSIZE bit in the DMA_SxCR register. This means that memory is written with an undesired value. The software may read the DMA_SxNDTR register to determine the memory area that contains the good data (start address and last address).

If the number of remaining data items in the FIFO is lower than a burst size (if the MBURST bits in DMA_SxCR register are set to configure the stream to manage burst on the AHB memory port), single transactions are generated to complete the FIFO flush.

Direct mode

By default, the FIFO operates in direct mode (DMDIS bit in the DMA_SxFCR is reset) and the FIFO threshold level is not used. This mode is useful when the system requires an immediate and single transfer to or from the memory after each DMA request.

When the DMA is configured in direct mode (FIFO disabled), to transfer data in memory-to-peripheral mode, the DMA preloads one data from the memory to the internal FIFO to ensure an immediate data transfer as soon as a DMA request is triggered by a peripheral.

To avoid saturating the FIFO, it is recommended to configure the corresponding stream with a high priority.

This mode is restricted to transfers where:

Direct mode must not be used when implementing memory-to-memory transfers.

15.3.15 DMA transfer completion

Different events can generate an end of transfer by setting the TCIFx bit in the DMA_LISR or DMA_HISR status register:

to-memory) all the remaining data have been flushed from the FIFO into the memory.

Note: The transfer completion is dependent on the remaining data in FIFO to be transferred into memory only in the case of peripheral-to-memory mode. This condition is not applicable in memory-to-peripheral mode.

If the stream is configured in non-circular mode, after the end of the transfer (that is when the number of data to be transferred reaches zero), the DMA is stopped (EN bit in DMA_SxCR register is cleared by Hardware) and no DMA request is served unless the software reprograms the stream and re-enables it (by setting the EN bit in the DMA_SxCR register).

15.3.16 DMA transfer suspension

At any time, a DMA transfer can be suspended to be restarted later on or to be definitively disabled before the end of the DMA transfer.

There are two cases:

Note: A transfer complete interrupt flag (TCIF in DMA_LISR or DMA_HISR) is set to indicate the end of transfer due to the stream interruption.

15.3.17 Flow controller

The entity that controls the number of data to be transferred is known as the flow controller. This flow controller is configured independently for each stream using the PFCTRL bit in the DMA_SxCR register.

The flow controller can be:

When the peripheral flow controller is used for a given stream, the value written into the DMA_SxNDTR has no effect on the DMA transfer. Actually, whatever the value written, it is forced by hardware to 0xFFFF as soon as the stream is enabled, to respect the following schemes:

Note: When configured in memory-to-memory mode, the DMA is always the flow controller and the PFCTRL bit is forced to 0 by hardware.

The circular mode is forbidden in the peripheral flow controller mode.

15.3.18 Summary of the possible DMA configurations

The table below summarizes the different possible DMA configurations. The forbidden configurations are highlighted in gray in the table.

Table 93. Possible DMA configurations

DMA transfer modeSourceDestinationFlow controllerCircular modeTransfer typeDirect modeDouble-buffer mode
Peripheral-to-memoryAHB peripheral portAHB memory portDMAPossiblesinglePossiblePossible
burstForbidden
PeripheralForbiddensinglePossibleForbidden
burstForbidden
Memory-to-peripheralAHB memory portAHB peripheral portDMAPossiblesinglePossiblePossible
burstForbidden
PeripheralForbiddensinglePossibleForbidden
burstForbidden
Memory-to-memoryAHB peripheral portAHB memory portDMA onlyForbiddensingleForbiddenForbidden
burst

15.3.19 Stream configuration procedure

The following sequence must be followed to configure a DMA stream x (where x is the stream number):

  1. 1. If the stream is enabled, disable it by resetting the EN bit in the DMA_SxCR register, then read this bit in order to confirm that there is no ongoing stream operation. Writing this bit to 0 is not immediately effective since it is actually written to 0 once all the current transfers are finished. When the EN bit is read as 0, this means that the stream is ready to be configured. It is therefore necessary to wait for the EN bit to be cleared before starting any stream configuration. All the stream dedicated bits set in the status register (DMA_LISR and DMA_HISR) from the previous data block DMA transfer must be cleared before the stream can be re-enabled.
  2. 2. Set the peripheral port register address in the DMA_SxPAR register. The data is moved from/ to this address to/ from the peripheral port after the peripheral event.
  3. 3. Set the memory address in the DMA_SxMA0R register (and in the DMA_SxMA1R register in the case of a double-buffer mode). The data is written to or read from this memory after the peripheral event.
  4. 4. Configure the total number of data items to be transferred in the DMA_SxNDTR register. After each peripheral event or each beat of the burst, this value is decremented.
  5. 5. Use DMAMUX1 to route a DMA request line to the DMA channel.
  6. 6. If the peripheral is intended to be the flow controller and if it supports this feature, set the PFCTRL bit in the DMA_SxCR register.
  7. 7. Configure the stream priority using the PL[1:0] bits in the DMA_SxCR register.
  8. 8. Configure the FIFO usage (enable or disable, threshold in transmission and reception)
  1. 9. Configure the data transfer direction, peripheral and memory incremented/fixed mode, single or burst transactions, peripheral and memory data widths, circular mode, double-buffer mode and interrupts after half and/or full transfer, and/or errors in the DMA_SxCR register.
  2. 10. Activate the stream by setting the EN bit in the DMA_SxCR register.

As soon as the stream is enabled, it can serve any DMA request from the peripheral connected to the stream.

Once half the data have been transferred on the AHB destination port, the half-transfer flag (HTIF) is set and an interrupt is generated if the half-transfer interrupt enable bit (HTIE) is set. At the end of the transfer, the transfer complete flag (TCIF) is set and an interrupt is generated if the transfer complete interrupt enable bit (TCIE) is set.


Warning: To switch off a peripheral connected to a DMA stream request, it is mandatory to, first, switch off the DMA stream to which the peripheral is connected, then to wait for EN bit = 0. Only then can the peripheral be safely disabled.


15.3.20 Error management

The DMA controller can detect the following errors:

In direct mode, the FIFO error flag can also be set under the following conditions:

If the TEIFx or the FEIFx flag is set due to incompatibility between burst size and FIFO threshold level, the faulty stream is automatically disabled through a hardware clear of its EN bit in the corresponding stream configuration register (DMA_SxCR).

If the DMEIFx or the FEIFx flag is set due to an overrun or underrun condition, the faulty stream is not automatically disabled and it is up to the software to disable or not the stream by resetting the EN bit in the DMA_SxCR register. This is because there is no data loss when this kind of errors occur.

When the stream's error interrupt flag (TEIF, FEIF, DMEIF) in the DMA_LISR or DMA_HISR register is set, an interrupt is generated if the corresponding interrupt enable bit (TEIE, FEIE, DMEIE) in the DMA_SxCR or DMA_SxFCR register is set.

Note: When a FIFO overrun or underrun condition occurs, the data is not lost because the peripheral request is not acknowledged by the stream until the overrun or underrun condition is cleared. If this acknowledge takes too much time, the peripheral itself may detect an overrun or underrun condition of its internal buffer and data might be lost.

15.4 DMA interrupts

For each DMA stream, an interrupt can be produced on the following events:

Separate interrupt enable control bits are available for flexibility as shown in the table below.

Table 94. DMA interrupt requests

Interrupt eventEvent flagEnable control bit
Half-transferHTIFHTIE
Transfer completeTCIFTCIE
Transfer errorTEIFTEIE
FIFO overrun/underrunFEIFFEIE
Direct mode errorDMEIFDMEIE

Note: Before setting an enable control bit EN = 1, the corresponding event flag must be cleared, otherwise an interrupt is immediately generated.

15.5 DMA registers

The DMA registers have to be accessed by words (32 bits).

15.5.1 DMA low interrupt status register (DMA_LISR)

Address offset: 0x000

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.TCIF3HTIF3TEIF3DMEIF3Res.FEIF3TCIF2HTIF2TEIF2DMEIF2Res.FEIF2
rrrrrrrrrr

1514131211109876543210
Res.Res.Res.Res.TCIF1HTIF1TEIF1DMEIF1Res.FEIF1TCIF0HTIF0TEIF0DMEIF0Res.FEIF0
rrrrrrrrrr

Bits 31:28, 15:12 Reserved, must be kept at reset value.

Bits 27, 21, 11, 5 TCIF[3:0] : Stream x transfer complete interrupt flag (x = 3 to 0)

This bit is set by hardware. It is cleared by software writing 1 to the corresponding bit in DMA_LIFCR register.

0: No transfer complete event on stream x

1: A transfer complete event occurred on stream x.

Bits 26, 20, 10, 4 HTIF[3:0] : Stream x half transfer interrupt flag (x = 3 to 0)

This bit is set by hardware. It is cleared by software writing 1 to the corresponding bit in DMA_LIFCR register.

0: No half transfer event on stream x

1: An half transfer event occurred on stream x.

Bits 25, 19, 9, 3 TEIF[3:0] : Stream x transfer error interrupt flag (x = 3 to 0)

This bit is set by hardware. It is cleared by software writing 1 to the corresponding bit in DMA_LIFCR register.

0: No transfer error on stream x

1: A transfer error occurred on stream x.

Bits 24, 18, 8, 2 DMEIF[3:0] : Stream x direct mode error interrupt flag (x = 3 to 0)

This bit is set by hardware. It is cleared by software writing 1 to the corresponding bit in DMA_LIFCR register.

0: No direct mode error on stream x

1: A direct mode error occurred on stream x.

Bits 23, 17, 7, 1 Reserved, must be kept at reset value.

Bits 22, 16, 6, 0 FEIF[3:0] : Stream x FIFO error interrupt flag (x = 3 to 0)

This bit is set by hardware. It is cleared by software writing 1 to the corresponding bit in DMA_LIFCR register.

0: No FIFO error event on stream x

1: A FIFO error event occurred on stream x.

15.5.2 DMA high interrupt status register (DMA_HISR)

Address offset: 0x004

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.TCIF7HTIF7TEIF7DMEIF7Res.FEIF7TCIF6HTIF6TEIF6DMEIF6Res.FEIF6
rrrrrrrrrr
1514131211109876543210
Res.Res.Res.Res.TCIF5HTIF5TEIF5DMEIF5Res.FEIF5TCIF4HTIF4TEIF4DMEIF4Res.FEIF4
rrrrrrrrrr

Bits 31:28, 15:12 Reserved, must be kept at reset value.

Bits 27, 21, 11, 5 TCIF[7:4] : Stream x transfer complete interrupt flag (x = 7 to 4)

This bit is set by hardware. It is cleared by software writing 1 to the corresponding bit in DMA_HIFCR register.

0: No transfer complete event on stream x

1: A transfer complete event occurred on stream x.

Bits 26, 20, 10, 4 HTIF[7:4] : Stream x half transfer interrupt flag (x = 7 to 4)

This bit is set by hardware. It is cleared by software writing 1 to the corresponding bit in DMA_HIFCR register.

0: No half transfer event on stream x

1: An half transfer event occurred on stream x.

Bits 25, 19, 9, 3 TEIF[7:4] : Stream x transfer error interrupt flag (x = 7 to 4)

This bit is set by hardware. It is cleared by software writing 1 to the corresponding bit in DMA_HIFCR register.

0: No transfer error on stream x

1: A transfer error occurred on stream x.

Bits 24, 18, 8, 2 DMEIF[7:4] : Stream x direct mode error interrupt flag (x = 7 to 4)

This bit is set by hardware. It is cleared by software writing 1 to the corresponding bit in DMA_HIFCR register.

0: No direct mode error on stream x

1: A direct mode error occurred on stream x.

Bits 23, 17, 7, 1 Reserved, must be kept at reset value.

Bits 22, 16, 6, 0 FEIF[7:4] : Stream x FIFO error interrupt flag (x = 7 to 4)

This bit is set by hardware. It is cleared by software writing 1 to the corresponding bit in DMA_HIFCR register.

0: No FIFO error event on stream x

1: A FIFO error event occurred on stream x.

15.5.3 DMA low interrupt flag clear register (DMA_LIFCR)

Address offset: 0x008

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.CTCIF3CHTIF3CTEIF3CDMEIF3Res.CFEIF3CTCIF2CHTIF2CTEIF2CDMEIF2Res.CFEIF2
wwwwwwwwww
1514131211109876543210
Res.Res.Res.Res.CTCIF1CHTIF1CTEIF1CDMEIF1Res.CFEIF1CTCIF0CHTIF0CTEIF0CDMEIF0Res.CFEIF0
wwwwwwwwww

Bits 31:28, 15:12 Reserved, must be kept at reset value.

Bits 27, 21, 11, 5 CTCIF[3:0] : Stream x clear transfer complete interrupt flag (x = 3 to 0)

Writing 1 to this bit clears the corresponding TCIFx flag in the DMA_LISR register.

Bits 26, 20, 10, 4 CHTIF[3:0] : Stream x clear half transfer interrupt flag (x = 3 to 0)

Writing 1 to this bit clears the corresponding HTIFx flag in the DMA_LISR register

Bits 25, 19, 9, 3 CTEIF[3:0] : Stream x clear transfer error interrupt flag (x = 3 to 0)

Writing 1 to this bit clears the corresponding TEIFx flag in the DMA_LISR register.

Bits 24, 18, 8, 2 CDMEIF[3:0] : Stream x clear direct mode error interrupt flag (x = 3 to 0)

Writing 1 to this bit clears the corresponding DMEIFx flag in the DMA_LISR register.

Bits 23, 17, 7, 1 Reserved, must be kept at reset value.

Bits 22, 16, 6, 0 CFEIF[3:0] : Stream x clear FIFO error interrupt flag (x = 3 to 0)

Writing 1 to this bit clears the corresponding CFEIFx flag in the DMA_LISR register.

15.5.4 DMA high interrupt flag clear register (DMA_HIFCR)

Address offset: 0x00C

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.CTCIF7CHTIF7CTEIF7CDMEIF7Res.CFEIF7CTCIF6CHTIF6CTEIF6CDMEIF6Res.CFEIF6
wwwwwwwwww
1514131211109876543210
Res.Res.Res.Res.CTCIF5CHTIF5CTEIF5CDMEIF5Res.CFEIF5CTCIF4CHTIF4CTEIF4CDMEIF4Res.CFEIF4
wwwwwwwwww

Bits 31:28, 15:12 Reserved, must be kept at reset value.

Bits 27, 21, 11, 5 CTCIF[7:4] : Stream x clear transfer complete interrupt flag (x = 7 to 4)

Writing 1 to this bit clears the corresponding TCIFx flag in the DMA_HISR register.

Bits 26, 20, 10, 4 CHTIF[7:4] : Stream x clear half transfer interrupt flag (x = 7 to 4)

Writing 1 to this bit clears the corresponding HTIFx flag in the DMA_HISR register.

Bits 25, 19, 9, 3 CTEIF[7:4] : Stream x clear transfer error interrupt flag (x = 7 to 4)

Writing 1 to this bit clears the corresponding TEIFx flag in the DMA_HISR register.

Bits 24, 18, 8, 2 CDMEIF[7:4] : Stream x clear direct mode error interrupt flag (x = 7 to 4)

Writing 1 to this bit clears the corresponding DMEIFx flag in the DMA_HISR register.

Bits 23, 17, 7, 1 Reserved, must be kept at reset value.

Bits 22, 16, 6, 0 CFEIF[7:4] : Stream x clear FIFO error interrupt flag (x = 7 to 4)

Writing 1 to this bit clears the corresponding CFEIFx flag in the DMA_HISR register.

15.5.5 DMA stream x configuration register (DMA_SxCR)

This register is used to configure the concerned stream.

Address offset: 0x010 + 0x18 * x, (x = 0 to 7)

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.MBURST[1:0]PBURST[1:0]TRBUF
F
CTDBMPL[1:0]
1514131211109876543210
PINC
OS
MSIZE[1:0]PSIZE[1:0]MINCPINCCIRCDIR[1:0]PF
CTRL
TCIEHTIETEIEDMEIEEN
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:25 Reserved, must be kept at reset value.

Bits 24:23 MBURST[1:0] : Memory burst transfer configuration

These bits are set and cleared by software.

00: Single transfer

01: INCR4 (incremental burst of 4 beats)

10: INCR8 (incremental burst of 8 beats)

11: INCR16 (incremental burst of 16 beats)

These bits are protected and can be written only if EN = 0.

In direct mode, these bits are forced to 0x0 by hardware as soon as bit EN = 1.

Bits 22:21 PBURST[1:0] : Peripheral burst transfer configuration

These bits are set and cleared by software.

00: Single transfer

01: INCR4 (incremental burst of 4 beats)

10: INCR8 (incremental burst of 8 beats)

11: INCR16 (incremental burst of 16 beats)

These bits are protected and can be written only if EN = 0.

In direct mode, these bits are forced to 0x0 by hardware.

Bit 20 TRBUFF : Enable the DMA to handle bufferable transfers

0: Bufferable transfers not enabled

1: Bufferable transfers enabled

Note: This bit must be set to 1 if the DMA stream manages UART/USART/LPUART transfers.

Bit 19 CT : Current target (only in double-buffer mode)

This bit is set and cleared by hardware. It can also be written by software.

0: Current target memory is memory 0 (addressed by the DMA_SxM0AR pointer).

1: Current target memory is memory 1 (addressed by the DMA_SxM1AR pointer).

This bit can be written only if EN = 0 to indicate the target memory area of the first transfer.

Once the stream is enabled, this bit operates as a status flag indicating which memory area is the current target.

Bit 18 DBM: Double-buffer mode

This bit is set and cleared by software.

0: No buffer switching at the end of transfer

1: Memory target switched at the end of the DMA transfer

This bit is protected and can be written only if EN = 0.

Bits 17:16 PL[1:0]: priority level

These bits are set and cleared by software.

00: Low

01: Medium

10: High

11: Very high

These bits are protected and can be written only if EN = 0.

Bit 15 PINCOS: Peripheral increment offset size

This bit is set and cleared by software

0: The offset size for the peripheral address calculation is linked to the PSIZE.

1: The offset size for the peripheral address calculation is fixed to 4 (32-bit alignment).

This bit has no meaning if bit PINC = 0.

This bit is protected and can be written only if EN = 0.

This bit is forced low by hardware when the stream is enabled (EN = 1) if the direct mode is selected or if PBURST are different from 00.

Bits 14:13 MSIZE[1:0]: Memory data size

These bits are set and cleared by software.

00: Byte (8-bit)

01: Half-word (16-bit)

10: Word (32-bit)

11: Reserved

These bits are protected and can be written only if EN = 0.

In direct mode, MSIZE is forced by hardware to the same value as PSIZE as soon as EN = 1.

Bits 12:11 PSIZE[1:0]: Peripheral data size

These bits are set and cleared by software.

00: Byte (8-bit)

01: Half-word (16-bit)

10: Word (32-bit)

11: Reserved

These bits are protected and can be written only if EN = 0.

Bit 10 MINC: Memory increment mode

This bit is set and cleared by software.

0: Memory address pointer fixed

1: Memory address pointer incremented after each data transfer (increment is done according to MSIZE)

This bit is protected and can be written only if EN = 0.

Bit 9 PINC: Peripheral increment mode

This bit is set and cleared by software.

0: Peripheral address pointer fixed

1: Peripheral address pointer incremented after each data transfer (increment done according to PSIZE)

This bit is protected and can be written only if EN = 0.

Bit 8 CIRC: Circular mode

This bit is set and cleared by software and can be cleared by hardware.

0: Circular mode disabled

1: Circular mode enabled

When the peripheral is the flow controller (bit PFCTRL = 1), and the stream is enabled (EN = 1), then this bit is automatically forced by hardware to 0.

It is automatically forced by hardware to 1 if the DBM bit is set, as soon as the stream is enabled (EN = 1).

Bits 7:6 DIR[1:0]: Data transfer direction

These bits are set and cleared by software.

00: Peripheral-to-memory

01: Memory-to-peripheral

10: Memory-to-memory

11: Reserved

These bits are protected and can be written only if EN = 0.

Bit 5 PFCTRL: Peripheral flow controller

This bit is set and cleared by software.

0: DMA is the flow controller.

1: The peripheral is the flow controller.

This bit is protected and can be written only if EN = 0.

When the memory-to-memory mode is selected (bits DIR[1:0] = 10), then this bit is automatically forced to 0 by hardware.

Bit 4 TCIE: Transfer complete interrupt enable

This bit is set and cleared by software.

0: TC interrupt disabled

1: TC interrupt enabled

Bit 3 HTIE: Half transfer interrupt enable

This bit is set and cleared by software.

0: HT interrupt disabled

1: HT interrupt enabled

Bit 2 TEIE: Transfer error interrupt enable

This bit is set and cleared by software.

0: TE interrupt disabled

1: TE interrupt enabled

Bit 1 DMEIE: Direct mode error interrupt enable

This bit is set and cleared by software.

0: DME interrupt disabled

1: DME interrupt enabled

Bit 0 EN : Stream enable/flag stream ready when read low

This bit is set and cleared by software.

0: Stream disabled

1: Stream enabled

This bit is cleared by hardware:

When this bit is read as 0, the software is allowed to program the configuration and FIFO bits registers. It is forbidden to write these registers when the EN bit is read as 1.

Note: Before setting EN bit to 1 to start a new transfer, the event flags corresponding to the stream in DMA_LISR or DMA_HISR register must be cleared.

15.5.6 DMA stream x number of data register (DMA_SxNDTR)

Address offset: 0x014 + 0x18 * x, (x = 0 to 7)

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
NDT[15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:16 Reserved, must be kept at reset value.

Bits 15:0 NDT[15:0] : Number of data items to transfer (0 up to 65535)

This bitfield can be written only when the stream is disabled. When the stream is enabled, this bitfield is read-only, indicating the remaining data items to be transmitted. This bitfield decrements after each DMA transfer.

Once the transfer is completed, this bitfield can either stay at zero (when the stream is in normal mode), or be reloaded automatically with the previously programmed value in the following cases:

If the value of this bitfield is zero, no transaction can be served even if the stream is enabled.

15.5.7 DMA stream x peripheral address register (DMA_SxPAR)

Address offset: 0x018 + 0x18 * x, (x = 0 to 7)

Reset value: 0x0000 0000

31302928272625242322212019181716
PAR[31:16]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
PAR[15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:0 PAR[31:0] : Peripheral address

Base address of the peripheral data register from/to which the data is read/written.

These bits are write-protected and can be written only when bit EN = 0 in DMA_SxCR.

15.5.8 DMA stream x memory 0 address register (DMA_SxM0AR)

Address offset: \( 0x01C + 0x18 * x \) , ( \( x = 0 \) to \( 7 \) )

Reset value: 0x0000 0000

31302928272625242322212019181716
M0A[31:16]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
M0A[15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:0 M0A[31:0] : Memory 0 address

Base address of memory area 0 from/to which the data is read/written.

These bits are write-protected. They can be written only if:

15.5.9 DMA stream x memory 1 address register (DMA_SxM1AR)

Address offset: \( 0x020 + 0x18 * x \) , ( \( x = 0 \) to \( 7 \) )

Reset value: 0x0000 0000

31302928272625242322212019181716
M1A[31:16]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
M1A[15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:0 M1A[31:0] : Memory 1 address (used in case of double-buffer mode)

Base address of memory area 1 from/to which the data is read/written.

This bitfield is used only for the double-buffer mode.

These bits are write-protected. They can be written only if:

15.5.10 DMA stream x FIFO control register (DMA_SxFCR)

Address offset: 0x024 + 0x18 * x, (x = 0 to 7)

Reset value: 0x0000 0021

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.FEIERes.FS[2:0]DMDISFTH[1:0]
rwrrrrwrwrw

Bits 31:8 Reserved, must be kept at reset value.

Bit 7 FEIE : FIFO error interrupt enable
This bit is set and cleared by software.
0: FE interrupt disabled
1: FE interrupt enabled

Bit 6 Reserved, must be kept at reset value.

Bits 5:3 FS[2:0] : FIFO status
These bits are read-only.
000: \( 0 < \text{fifo\_level} < 1/4 \)
001: \( 1/4 \leq \text{fifo\_level} < 1/2 \)
010: \( 1/2 \leq \text{fifo\_level} < 3/4 \)
011: \( 3/4 \leq \text{fifo\_level} < \text{full} \)
100: FIFO is empty.
101: FIFO is full.
Others: Reserved (no meaning)
These bits are not relevant in the direct mode (DMDIS = 0).

Bit 2 DMDIS : Direct mode disable
This bit is set and cleared by software. It can be set by hardware.
0: Direct mode enabled
1: Direct mode disabled
This bit is protected and can be written only if EN = 0.
This bit is set by hardware if the memory-to-memory mode is selected (DIR = 10 in DMA_SxCR), and EN = 1 in DMA_SxCR because the direct mode is not allowed in the memory-to-memory configuration.

Bits 1:0 FTH[1:0] : FIFO threshold selection
These bits are set and cleared by software.
00: 1/4 full FIFO
01: 1/2 full FIFO
10: 3/4 full FIFO
11: Full FIFO
These bits are not used in the direct mode when the DMDIS = 0.
These bits are protected and can be written only if EN = 0.

15.5.11 DMA register map

Table 95. DMA register map and reset values

OffsetRegister name313029282726252423222120191817161514131211109876543210
0x000DMA_LISRRes.Res.Res.Res.TCIF3HTIF3TEIF3DMEIF3Res.FEIF3TCIF2HTIF2TEIF2DMEIF2Res.FEIF2Res.Res.Res.Res.TCIF1HTIF1TEIF1DMEIF1Res.FEIF1TCIF0HTIF0TEIF0DMEIF0Res.FEIF0
Reset value00000000000000000000
0x004DMA_HISRRes.Res.Res.Res.TCIF7HTIF7TEIF7DMEIF7Res.FEIF7TCIF6HTIF6TEIF6DMEIF6Res.FEIF6Res.Res.Res.Res.TCIF5HTIF5TEIF5DMEIF5Res.FEIF5TCIF4HTIF4TEIF4DMEIF4Res.FEIF4
Reset value00000000000000000000
0x008DMA_LIFCRRes.Res.Res.Res.CTCIF3CHTIF3CTEIF3CDMEIF3Res.CFEIF3CTCIF2CHTIF2CTEIF2CDMEIF2Res.CFEIF2Res.Res.Res.Res.CTCIF1CHTIF1CTEIF1CDMEIF1Res.CFEIF1CTCIF0CHTIF0CTEIF0CDMEIF0Res.CFEIF0
Reset value00000000000000000000
0x00CDMA_HIFCRRes.Res.Res.Res.CTCIF7CHTIF7CTEIF7CDMEIF7Res.CFEIF7CTCIF6CHTIF6CTEIF6CDMEIF6Res.CFEIF6Res.Res.Res.Res.CTCIF5CHTIF5CTEIF5CDMEIF5Res.CFEIF5CTCIF4CHTIF4CTEIF4CDMEIF4Res.CFEIF4
Reset value00000000000000000000
0x010DMA_S0CRRes.Res.Res.Res.Res.Res.MBURST [1:0]Res.PBURST [1:0]Res.TRBUFFCTDBMPL[1:0]PINCOSMSIZE[1:0]Res.PSIZE[1:0]Res.MINCPINCCIRCDIR[1:0]Res.PFCTRLTCIEHTIETEIEDMEIEEN
Reset value0000000000000000000
0x014DMA_S0NDTRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.NDT[15:0]
Reset value0000000000000000
0x018DMA_S0PARPA[31:0]
Reset value00000000000000000000000000000000
0x01CDMA_S0M0ARMOA[31:0]
Reset value00000000000000000000000000000000
0x020DMA_S0M1ARM1A[31:0]
Reset value00000000000000000000000000000000
0x024DMA_S0FCRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.FEIERes.FS[2:0]DMDISFTH [1:0]
Reset value0100001
0x028DMA_S1CRRes.Res.Res.Res.Res.Res.MBURST[1:0]Res.PBURST[1:0]Res.TRBUFFCTDBMPL[1:0]PINCOSMSIZE[1:0]Res.PSIZE[1:0]Res.MINCPINCCIRCDIR[1:0]Res.PFCTRLTCIEHTIETEIEDMEIEEN
Reset value0000000000000000000
0x02CDMA_S1NDTRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.NDT[15:0]
Reset value0000000000000000
0x030DMA_S1PARPA[31:0]
Reset value00000000000000000000000000000000
0x034DMA_S1M0ARMOA[31:0]
Reset value00000000000000000000000000000000

Table 95. DMA register map and reset values (continued)

OffsetRegister name313029282726252423222120191817161514131211109876543210
0x038DMA_S1M1ARM1A[31:0]
Reset value00000000000000000000000000000000
0x03CDMA_S1FCRResResResResResResResResResResResResResResResResResResResResResResResResFEIEResFS[2:0]DMDISFTH[1:0]
Reset value0100001
0x040DMA_S2CRResResResResResResResMBURST[1:0]PBURST[1:0]TRBUFFCTDBMPL[1:0]PINCOSMSIZE[1:0]PSIZE[1:0]MINCPINCCIRCDIR[1:0]PFCTRLTCIEHTIETEIEDMEIEEN
Reset value000000000000000000000000
0x044DMA_S2NDTRResResResResResResResResResResResResResResResResNDT[15:0]
Reset value000000000000000
0x048DMA_S2PARPA[31:0]
Reset value00000000000000000000000000000000
0x04CDMA_S2M0ARMOA[31:0]
Reset value00000000000000000000000000000000
0x050DMA_S2M1ARM1A[31:0]
Reset value00000000000000000000000000000000
0x054DMA_S2FCRResResResResResResResResResResResResResResResResResResResResResResResResFEIEResFS[2:0]DMDISFTH[1:0]
Reset value0100001
0x058DMA_S3CRResResResResResResResMBURST[1:0]PBURST[1:0]TRBUFFCTDBMPL[1:0]PINCOSMSIZE[1:0]PSIZE[1:0]MINCPINCCIRCDIR[1:0]PFCTRLTCIEHTIETEIEDMEIEEN
Reset value000000000000000000000000
0x05CDMA_S3NDTRResResResResResResResResResResResResResResResResNDT[15:0]
Reset value000000000000000
0x060DMA_S3PARPA[31:0]
Reset value00000000000000000000000000000000
0x064DMA_S3M0ARMOA[31:0]
Reset value00000000000000000000000000000000
0x068DMA_S3M1ARM1A[31:0]
Reset value00000000000000000000000000000000
0x06CDMA_S3FCRResResResResResResResResResResResResResResResResResResResResResResResResFEIEResFS[2:0]DMDISFTH[1:0]
Reset value0100001

Table 95. DMA register map and reset values (continued)

OffsetRegister name313029282726252423222120191817161514131211109876543210
0x070DMA_S4CRRes.Res.Res.Res.Res.Res.Res.MBURST [1:0]Res.PBURST [1:0]Res.TRBUFFCTDBMPL[1:0]PINCOSMSIZE[1:0]PSIZE[1:0]MINCPINCCIRCDIR[1:0]PFCTRLTCIEHTIETEIEDMEIEEN
Reset value0000000000000000000000000
0x074DMA_S4NDTRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.NDT[15:0]
Reset value000000000000000
0x078DMA_S4PARPA[31:0]
Reset value00000000000000000000000000000000
0x07CDMA_S4M0ARM0A[31:0]
Reset value00000000000000000000000000000000
0x080DMA_S4M1ARM1A[31:0]
Reset value00000000000000000000000000000000
0x084DMA_S4FCRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.FEIERes.FS[2:0]DMDISFTH[1:0]
Reset value0100001
0x088DMA_S5CRRes.Res.Res.Res.Res.Res.Res.MBURST [1:0]Res.PBURST [1:0]Res.TRBUFFCTDBMPL[1:0]PINCOSMSIZE[1:0]PSIZE[1:0]MINCPINCCIRCDIR[1:0]PFCTRLTCIEHTIETEIEDMEIEEN
Reset value0000000000000000000000000
0x08CDMA_S5NDTRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.NDT[15:0]
Reset value000000000000000
0x090DMA_S5PARPA[31:0]
Reset value00000000000000000000000000000000
0x094DMA_S5M0ARM0A[31:0]
Reset value00000000000000000000000000000000
0x098DMA_S5M1ARM1A[31:0]
Reset value00000000000000000000000000000000
0x09CDMA_S5FCRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.FEIERes.FS[2:0]DMDISFTH[1:0]
Reset value0100001
0x0A0DMA_S6CRRes.Res.Res.Res.Res.Res.Res.MBURST [1:0]Res.PBURST [1:0]Res.TRBUFFCTDBMPL[1:0]PINCOSMSIZE[1:0]PSIZE[1:0]MINCPINCCIRCDIR[1:0]PFCTRLTCIEHTIETEIEDMEIEEN
Reset value0000000000000000000000000
0x0A4DMA_S6NDTRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.NDT[15:0]
Reset value000000000000000

Table 95. DMA register map and reset values (continued)

OffsetRegister name313029282726252423222120191817161514131211109876543210
0x0A8DMA_S6PARPA[31:0]
Reset value00000000000000000000000000000000
0x0ACDMA_S6M0ARM0A[31:0]
Reset value00000000000000000000000000000000
0x0B0DMA_S6M1ARM1A[31:0]
Reset value00000000000000000000000000000000
0x0B4DMA_S6FCRResResResResResResResResResResResResResResResResResResResResResResResResFEIEResFS[2:0]DMDISFTH[1:0]
Reset value0100001
0x0B8DMA_S7CRResResResResResResResResResResResResResResResResResResResResResResResResResResResResResResResRes
Reset value
0x0BCDMA_S7NDTRResResResResResResResResResResResResResResResResResResResResResResResResResResResResResResResRes
Reset value
0x0C0DMA_S7PARPA[31:0]
Reset value00000000000000000000000000000000
0x0C4DMA_S7M0ARM0A[31:0]
Reset value00000000000000000000000000000000
0x0C8DMA_S7M1ARM1A[31:0]
Reset value00000000000000000000000000000000
0x0CCDMA_S7FCRResResResResResResResResResResResResResResResResResResResResResResResResFEIEResFS[2:0]DMDISFTH[1:0]
Reset value0100001
Refer to Section 2.3 for the register boundary addresses.