9. Direct memory access controller (DMA)

9.1 DMA introduction

Direct memory access (DMA) is used in order 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 stream can have up to 16 channels (requests) in total.

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

9.2 DMA main features

The main DMA features are:

9.3 DMA functional description

9.3.1 DMA block diagram

The figure below shows the block diagram of a DMA.

Figure 23. DMA block diagram

Figure 23. DMA block diagram. The diagram shows the internal architecture of a DMA controller. On the left, there are multiple channel request lines (REQ_STR0_CH0 to REQ_STR0_CH15, REQ_STR1_CH0 to REQ_STR1_CH15, ..., REQ_STR7_CH0 to REQ_STR7_CH15) entering a 'Channel selection' block. This block outputs to an 'Arbiter' block, which generates eight stream request lines (REQ_STREAM0 to REQ_STREAM7). These lines enter a 'FIFO' block containing eight FIFOs (STREAM 0 to STREAM 7). Above each FIFO is a corresponding stream line (STREAM 0 to STREAM 7) that connects to an 'AHB master' block. The 'AHB master' block is connected to a 'Memory port' and a 'Peripheral port'. Below the FIFOs, another 'AHB master' block is connected to the same stream lines (STREAM 0 to STREAM 7). At the bottom, an 'AHB slave programming interface' block is connected to a 'Programming port'. The diagram is labeled MSv42604V1 in the bottom right corner.
Figure 23. DMA block diagram. The diagram shows the internal architecture of a DMA controller. On the left, there are multiple channel request lines (REQ_STR0_CH0 to REQ_STR0_CH15, REQ_STR1_CH0 to REQ_STR1_CH15, ..., REQ_STR7_CH0 to REQ_STR7_CH15) entering a 'Channel selection' block. This block outputs to an 'Arbiter' block, which generates eight stream request lines (REQ_STREAM0 to REQ_STREAM7). These lines enter a 'FIFO' block containing eight FIFOs (STREAM 0 to STREAM 7). Above each FIFO is a corresponding stream line (STREAM 0 to STREAM 7) that connects to an 'AHB master' block. The 'AHB master' block is connected to a 'Memory port' and a 'Peripheral port'. Below the FIFOs, another 'AHB master' block is connected to the same stream lines (STREAM 0 to STREAM 7). At the bottom, an 'AHB slave programming interface' block is connected to a 'Programming port'. The diagram is labeled MSv42604V1 in the bottom right corner.

9.3.2 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).

9.3.3 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.

9.3.4 Channel selection

Each stream is associated with a DMA request that can be selected out of 16 possible channel requests. The selection is controlled by the CHSEL[3:0] bits in the DMA_SxCR register.

Caution: A same peripheral request can be assigned to two different channels only if the application ensures that these channels are not requested to be served at the same time. In other words, if two different channels receive a same asserted peripheral request at the same time, an unpredictable DMA hardware behavior occurs.

Figure 24. Channel selection

Diagram of channel selection logic. On the left, multiple channel request lines (REQ_STRx_CH15, REQ_STRx_CH3, REQ_STRx_CH2, REQ_STRx_CH1, REQ_STRx_CH0) are shown as inputs to a multiplexer. The multiplexer selects one of these based on the CHSEL[3:0] bits from the DMA_SxCR register. The output of the multiplexer is REQ_STREAMx. The DMA_SxCR register is shown as a 32-bit register with bits 31, 28, 25, and 0 marked, and the CHSEL[3:0] field highlighted.

The diagram illustrates the channel selection mechanism. On the left, several channel request lines are shown as inputs to a multiplexer. These include REQ_STRx_CH15, REQ_STRx_CH3, REQ_STRx_CH2, REQ_STRx_CH1, and REQ_STRx_CH0, with vertical ellipses indicating other possible channels. The multiplexer selects one of these inputs based on the CHSEL[3:0] bits from the DMA_SxCR register. The output of the multiplexer is REQ_STREAMx. Below the multiplexer, the DMA_SxCR register is shown as a 32-bit register with bits 31, 28, 25, and 0 marked. The CHSEL[3:0] field is highlighted, indicating its position within the register. The diagram is labeled MSv39629V1 in the bottom right corner.

Diagram of channel selection logic. On the left, multiple channel request lines (REQ_STRx_CH15, REQ_STRx_CH3, REQ_STRx_CH2, REQ_STRx_CH1, REQ_STRx_CH0) are shown as inputs to a multiplexer. The multiplexer selects one of these based on the CHSEL[3:0] bits from the DMA_SxCR register. The output of the multiplexer is REQ_STREAMx. The DMA_SxCR register is shown as a 32-bit register with bits 31, 28, 25, and 0 marked, and the CHSEL[3:0] field highlighted.

The 16 requests from the peripherals (such as TIM, ADC, SPI, I2C) are independently connected to each channel and their connection depends on the product implementation.

Table 30 and Table 31 give examples of DMA request mappings.

Table 30. DMA1 request mapping

Peripheral requestsStream 0Stream 1Stream 2Stream 3Stream 4Stream 5Stream 6Stream 7
Channel 0SPI3_RXI2C1_TXSPI3_RXSPI2_RXSPI2_TXSPI3_TX-SPI3_TX
Channel 1I2C1_RXI2C3_RXTIM7_UPI2CFMP1_RXTIM7_UPI2C1_RXI2C1_TXI2C1_TX
Channel 2TIM4_CH1I2CFMP1_TXI2S3_EXT_RXTIM4_CH2I2S2_EXT_TXI2S3_EXT_TXTIM4_UPTIM4_CH3
Channel 3I2S3_EXT_RXTIM2_UP
TIM2_CH3
I2C3_RXI2S2_EXT_RXI2C3_TXTIM2_CH1TIM2_CH2
TIM2_CH4
TIM2_UP
TIM2_CH4
Channel 4UART5_RXUSART3_RXUART4_RXUSART3_TXUART4_TXUSART2_RXUSART2_TXI2CFMP1_TX
Channel 5UART8_TXUART7_TXTIM3_UP
TIM3_CH4
UART7_RXTIM3_CH1
TIM3_TRIG
TIM3_CH2UART8_RXTIM3_CH3
Channel 6TIM5_CH3
TIM5_UP
TIM5_CH4
TIM5_TRIG
TIM5_CH1TIM5_CH4
TIM5_TRIG
TIM5_CH2I2C3_TXTIM5_UPUSART2_RX
Channel 7I2CFMP1_RXTIM6_UPI2C2_RXI2C2_RXUSART3_TXDAC1DAC2I2C2_TX
Channel 8-------UART5_TX

Table 31. DMA2 request mapping

Peripheral requestsStream 0Stream 1Stream 2Stream 3Stream 4Stream 5Stream 6Stream 7
Channel 0ADC1SAI1_ATIM8_CH1
TIM8_CH2
TIM8_CH3
SAI1_AADC1SAI1_BTIM1_CH1
TIM1_CH2
TIM1_CH3
UART9_RX
Channel 1UART9_TX---SAI1B---
Channel 2--SPI1_TXSPI5_RXSPI5_TXAES_OUT (1)AES_IN (1)-
Channel 3SPI1_RXDFSDM1_FLT1SPI1_RXSPI1_TXDFSDM1_FLT1SPI1_TXDFSDM1_FLT0QUADSPI
Channel 4SPI4_RXSPI4_TXUSART1_RXSDIOSPI4_RXUSART1_RXSDIOUSART1_TX
Channel 5UART10_RXUSART6_RXUSART6_RXSPI4_RXSPI4_TXSPI5_TXUSART6_TXUSART6_TX
Channel 6TIM1_TRIGTIM1_CH1TIM1_CH2TIM1_CH1TIM1_CH4
TIM1_TRIG
TIM1_COM
TIM1_UPTIM1_CH3UART10_TX
Channel 7DFSDM1_FLT0TIM8_UPTIM8_CH1TIM8_CH2TIM8_CH3SPI5_RXSPI5_TXTIM8_CH4
TIM8_TRIG
TIM8_COM
Channel 8DFSDM2_FLT0DFSDM2_FLT1DFSDM2_FLT2DFSDM2_FLT3DFSDM2_FLT0DFSDM2_FLT1DFSDM2_FLT2DFSDM2_FLT3
Channel 9---UART10_RX-UART10_TX--

1. Only available for STM32F423xx.

9.3.5 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:

9.3.6 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.

9.3.7 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 32. 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 32. 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 25 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_SxFCCR 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 25. Peripheral-to-memory mode

Figure 25. Peripheral-to-memory mode diagram. The diagram shows a DMA controller connected to an AHB memory port and an AHB peripheral port. The AHB memory port is connected to a memory destination via a memory bus. The AHB peripheral port is connected to a peripheral source via a peripheral bus. The DMA controller contains an arbiter, a FIFO, and several registers: DMA_SxM0AR, DMA_SxM1AR(1), and DMA_SxPAR. The arbiter receives REQ_STREAMx signals and controls the FIFO. The FIFO is connected to the AHB memory port and the AHB peripheral port. The DMA_SxPAR register is connected to the AHB peripheral port. The peripheral source sends a peripheral DMA request to the DMA controller. The diagram is labeled ai15948.
Figure 25. Peripheral-to-memory mode diagram. The diagram shows a DMA controller connected to an AHB memory port and an AHB peripheral port. The AHB memory port is connected to a memory destination via a memory bus. The AHB peripheral port is connected to a peripheral source via a peripheral bus. The DMA controller contains an arbiter, a FIFO, and several registers: DMA_SxM0AR, DMA_SxM1AR(1), and DMA_SxPAR. The arbiter receives REQ_STREAMx signals and controls the FIFO. The FIFO is connected to the AHB memory port and the AHB peripheral port. The DMA_SxPAR register is connected to the AHB peripheral port. The peripheral source sends a peripheral DMA request to the DMA controller. The diagram is labeled ai15948.

1. For double-buffer mode.

Memory-to-peripheral mode

Figure 26 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_SxFCCR 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 26. Memory-to-peripheral mode

Figure 26. Memory-to-peripheral mode diagram. The diagram shows a DMA controller connected to a memory source and a peripheral destination. The DMA controller contains an Arbiter, a FIFO, and an AHB memory port. The Arbiter receives REQ_STREAMx signals and controls 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 destination. The DMA controller also contains registers DMA_SxM0AR, DMA_SxM1AR(1), and DMA_SxPAR. A Peripheral DMA request signal is shown entering the DMA controller from the bottom. The diagram is labeled ai15949.
Figure 26. Memory-to-peripheral mode diagram. The diagram shows a DMA controller connected to a memory source and a peripheral destination. The DMA controller contains an Arbiter, a FIFO, and an AHB memory port. The Arbiter receives REQ_STREAMx signals and controls 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 destination. The DMA controller also contains registers DMA_SxM0AR, DMA_SxM1AR(1), and DMA_SxPAR. A Peripheral DMA request signal is shown entering the DMA controller from the bottom. The diagram is labeled ai15949.
  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 27 .

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 27. Memory-to-memory mode

Figure 27. Memory-to-memory mode. A block diagram of the DMA controller showing internal components and external connections. The DMA controller contains an Arbiter, a FIFO, an AHB memory port, and an AHB peripheral port. The Arbiter receives a 'Stream enable' signal and is connected to the FIFO and the AHB memory port. The FIFO is connected to the AHB memory port and the 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 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 27. Memory-to-memory mode. A block diagram of the DMA controller showing internal components and external connections. The DMA controller contains an Arbiter, a FIFO, an AHB memory port, and an AHB peripheral port. The Arbiter receives a 'Stream enable' signal and is connected to the FIFO and the AHB memory port. The FIFO is connected to the AHB memory port and the 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 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.

9.3.8 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.

9.3.9 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.

9.3.10 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 33 .

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 33. 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.

9.3.11 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 9.3.12 ).

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 34. 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]
30x8 / B2[7:0]0x2 / B2[7:0]
40xC / 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]
20x4 / B1[7:0]0x1 / B1[7:0]
30x8 / B2[7:0]0x2 / B2[7:0]
40xC / B3[7:0]0x3 / B3[7:0]
3216210x0 / B3B2B1B0[31:0]10x0 / B1B0[15:0]0x0 / B1B0[15:0]
20x4 / 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 35. 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

9.3.12 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.

9.3.13 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 28. FIFO structure

Four diagrams illustrating FIFO structures for different source and destination data widths: byte-to-word, byte-to-half-word, half-word-to-word, and half-word-to-byte. Each diagram shows a 4-word deep FIFO with 4 byte lanes, with states ranging from Empty to Full.

The figure illustrates four different FIFO structures based on source and destination data widths. Each structure is shown as a 4-word deep FIFO with 4 byte lanes (byte lane 0 to 3). The states of the FIFO are indicated by columns: Empty, 1/4, 1/2, 3/4, and Full.

Source: byte, Destination: word

Empty1/41/23/4Full
byte lane 3B15B11B7B3Destination: word
W3, W2, W1, W0
byte lane 2B14B10B6B2
byte lane 1B13B9B5B1
byte lane 0W3 B12W2 B8W1 B4W0 B0

Source: byte, Destination: half-word

Empty1/41/23/4Full
byte lane 3B15B11B7B3Destination: half-word
H7, H6, H5, H4, H3, H2, H1, H0
byte lane 2H7 B14H5 B10H3 B6H1 B2
byte lane 1B13B9B5B1
byte lane 0H6 B12H4 B8H2 B4H0 B0

Source: half-word, Destination: word

Empty1/41/23/4Full
byte lane 3H7H5H3H1Destination: word
W3, W2, W1, W0
byte lane 2
byte lane 1H6H4H2H0
byte lane 0W3W2W1W0

Source: half-word, Destination: byte

Empty1/41/23/4Full
byte lane 3B15B11B7B3Destination: byte
B15 B14 B13 B12 B11 B10 B9 B8
B7 B6 B5 B4 B3 B2 B1 B0
byte lane 2H7 B14H5 B10H3 B6H1 B2
byte lane 1B13B9B5B1
byte lane 0H6 B12H4 B8H2 B4H0 B0

ai15951

Four diagrams illustrating FIFO structures for different source and destination data widths: byte-to-word, byte-to-half-word, half-word-to-word, and half-word-to-byte. Each diagram shows a 4-word deep FIFO with 4 byte lanes, with states ranging from Empty to Full.

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 36. 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 × 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.

9.3.14 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).

9.3.15 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.

9.3.16 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.

9.3.17 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 37. 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

9.3.18 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. Select the DMA channel (request) using CHSEL[3:0] in the DMA_SxCR register.
  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.


9.3.19 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.

9.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 38. 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.

9.5 DMA registers

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

9.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 TCIFx : 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 HTIFx : 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 TEIFx : 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 DMEIFx : 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 FEIFx : 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.

9.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 TCIFx : 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 HTIFx : 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 TEIFx : 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 DMEIFx : 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 FEIFx : 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.

9.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 CTCIFx : 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 CHTIFx : 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 CTEIFx : 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 CDMEIFx : 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 CFEIFx : 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.

9.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 CTCIFx : 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 CHTIFx : 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 CTEIFx : 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 CDMEIFx : 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 CFEIFx : 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.

9.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.CHSEL[3:0]MBURST[1:0]PBURST[1:0]Res.CTDBMPL[1:0]
rwrwrwrwrwrwrwrwrwrwrwrw

1514131211109876543210
PINC
OS
MSIZE[1:0]PSIZE[1:0]MINCPINCCIRCDIR[1:0]PF
CTRL
TCIEHTIETEIEDMEIEEN
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

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

Bits 28:25 CHSEL[3:0] : Channel selection

These bits are set and cleared by software.

0000: channel 0 selected

0001: channel 1 selected

0010: channel 2 selected

0011: channel 3 selected

0100: channel 4 selected

0101: channel 5 selected

0110: channel 6 selected

0111: channel 7 selected

1000: channel 8 selected

1001: channel 9 selected

1010: channel 10 selected

1011: channel 11 selected

1100: channel 12 selected

1101: channel 13 selected

1110: channel 14 selected

1111: channel 15 selected

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

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 Reserved, must be kept at reset value.

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.

9.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.

9.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.

9.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:

9.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:

9.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.Res.Res.Res.Res.Res.Res.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 DMIS = 0.

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

9.5.11 DMA register map

Table 39. DMA register map and reset values

OffsetRegister name313029282726252423222120191817161514131211109876543210
0x000DMA_LISRRes.Res.Res.Res.TCIF3HTIF3TEIF3DMEIF3Res.FEIF3TCIF2HTIF2TEIF2DMEIF2Res.FEIF2Res.Res.Res.Res.TCIF1HTIF1TEIF1DMEIF1Res.Res.FEIF1TCIF0HTIF0TEIF0DMEIF0Res.FEIF0
Reset value00000000000000000000
0x004DMA_HISRRes.Res.Res.Res.TCIF7HTIF7TEIF7DMEIF7Res.FEIF7TCIF6HTIF6TEIF6DMEIF6Res.FEIF6Res.Res.Res.Res.TCIF5HTIF5TEIF5DMEIF5Res.Res.FEIF5TCIF4HTIF4TEIF4DMEIF4Res.FEIF4
Reset value00000000000000000000
0x008DMA_LIFCRRes.Res.Res.Res.CTCIF3CHTIF3CTEIF3CDMEIF3Res.CFEIF3CTCIF2CHTIF2CTEIF2CDMEIF2Res.CFEIF2Res.Res.Res.Res.CTCIF1CHTIF1CTEIF1CDMEIF1Res.Res.CFEIF1CTCIF0CHTIF0CTEIF0CDMEIF0Res.CFEIF0
Reset value00000000000000000000
0x00CDMA_HIFCRRes.Res.Res.Res.CTCIF7CHTIF7CTEIF7CDMEIF7Res.CFEIF7CTCIF6CHTIF6CTEIF6CDMEIF6Res.CFEIF6Res.Res.Res.Res.CTCIF5CHTIF5CTEIF5CDMEIF5Res.Res.CFEIF5CTCIF4CHTIF4CTEIF4CDMEIF4Res.CFEIF4
Reset value00000000000000000000
0x010DMA_S0CRRes.Res.Res.CHSEL[3:0]MBURST[1:0]Res.PBURST[1:0]Res.CTDBMPL[1:0]PINCOSMSIZE[1:0]PSIZE[1:0]MINCPINCCIRCDIR[1:0]PFCTRLTCIEHTIETEIEDMEIEEN
Reset value000000000000000000000000000
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_S0M0ARM0A[31:0]
Reset value00000000000000000000000000000000

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

OffsetRegister name313029282726252423222120191817161514131211109876543210
0x020DMA_S0M1ARM1A[31:0]
Reset value00000000000000000000000000000000
0x024DMA_S0FCRResResResResResResResResResResResResResResResResResResResResResResResResFEIEResFS[2:0]DMDISFTH[1:0]
Reset value0100001
0x028DMA_S1CRResResResCHSEL[3:0]MBURST[1:0]PBURST[1:0]ResCTDBMPL[1:0]PINCOSMSIZE[1:0]PSIZE[1:0]ResMINCPINCCIRCDIR[1:0]ResPFCTRLTCIEHTIETEIEDMEIEEN
Reset value00000000
0x02CDMA_S1NDTRResResResResResResResResResResResResResResResResNDT[15:0]
Reset value000000000000000
0x030DMA_S1PARPA[31:0]
Reset value0000000000000000000000000000000
0x034DMA_S1M0ARM0A[31:0]
Reset value0000000000000000000000000000000
0x038DMA_S1M1ARM1A[31:0]
Reset value0000000000000000000000000000000
0x03CDMA_S1FCRResResResResResResResResResResResResResResResResResResResResResResResResFEIEResFS[2:0]DMDISFTH[1:0]
Reset value010001
0x040DMA_S2CRResResResCHSEL[3:0]MBURST[1:0]PBURST[1:0]ResCTDBMPL[1:0]PINCOSMSIZE[1:0]PSIZE[1:0]ResMINCPINCCIRCDIR[1:0]ResPFCTRLTCIEHTIETEIEDMEIEEN
Reset value00000000
0x044DMA_S2NDTRResResResResResResResResResResResResResResResResNDT[15:0]
Reset value000000000000000
0x048DMA_S2PARPA[31:0]
Reset value0000000000000000000000000000000
0x04CDMA_S2M0ARM0A[31:0]
Reset value0000000000000000000000000000000
0x050DMA_S2M1ARM1A[31:0]
Reset value0000000000000000000000000000000
0x054DMA_S2FCRResResResResResResResResResResResResResResResResResResResResResResResResFEIEResFS[2:0]DMDISFTH[1:0]
Reset value010001

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

OffsetRegister name313029282726252423222120191817161514131211109876543210
0x058DMA_S3CRResResResCHSEL[3:0]MBURST[1:0]PBURST[1:0]ResCTDBMPL[1:0]PINCOSMSIZE[1:0]PSIZE[1:0]MINCPINCCIRCDIR[1:0]PFCTRLTCIEHTIETEIEDMEIEEN
Reset value0000000000000000000000000000
0x05CDMA_S3NDTRResResResResResResResResResResResResResResResResNDT[15:0]
Reset value0000000000000000
0x060DMA_S3PARPA[31:0]
Reset value00000000000000000000000000000000
0x064DMA_S3M0ARM0A[31:0]
Reset value00000000000000000000000000000000
0x068DMA_S3M1ARM1A[31:0]
Reset value00000000000000000000000000000000
0x06CDMA_S3FCRResResResResResResResResResResResResResResResResResResResResResResResResFEIEResFS[2:0]DMDISFTH[1:0]
Reset value0100001
0x070DMA_S4CRResResResCHSEL[3:0]MBURST[1:0]PBURST[1:0]ResCTDBMPL[1:0]PINCOSMSIZE[1:0]PSIZE[1:0]MINCPINCCIRCDIR[1:0]PFCTRLTCIEHTIETEIEDMEIEEN
Reset value0000000000000000000000000000
0x074DMA_S4NDTRResResResResResResResResResResResResResResResResNDT[15:0]
Reset value0000000000000000
0x078DMA_S4PARPA[31:0]
Reset value00000000000000000000000000000000
0x07CDMA_S4M0ARM0A[31:0]
Reset value00000000000000000000000000000000
0x080DMA_S4M1ARM1A[31:0]
Reset value00000000000000000000000000000000
0x084DMA_S4FCRResResResResResResResResResResResResResResResResResResResResResResResResFEIEResFS[2:0]DMDISFTH[1:0]
Reset value0100001
0x088DMA_S5CRResResResCHSEL[3:0]MBURST[1:0]PBURST[1:0]ResCTDBMPL[1:0]PINCOSMSIZE[1:0]PSIZE[1:0]MINCPINCCIRCDIR[1:0]PFCTRLTCIEHTIETEIEDMEIEEN
Reset value0000000000000000000000000000
0x08CDMA_S5NDTRResResResResResResResResResResResResResResResResNDT[15:0]
Reset value0000000000000000

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

OffsetRegister name313029282726252423222120191817161514131211109876543210
0x090DMA_S5PARPA[31:0]
Reset value00000000000000000000000000000000
0x094DMA_S5M0ARM0A[31:0]
Reset value00000000000000000000000000000000
0x098DMA_S5M1ARM1A[31:0]
Reset value00000000000000000000000000000000
0x09CDMA_S5FCRResResResResResResResResResResResResResResResResResResResResResResResResFEIEResFS[2:0]DMDISFTH[1:0]
Reset value0100001
0x0A0DMA_S6CRResResResCHSEL[3:0]MBURST[1:0]PBURST[1:0]ResCTDBMPL[1:0]PINCOSMSIZE[1:0]PSIZE[1:0]MINCPINCCIRCDIR[1:0]PFCTRLTCIEHTIETEIEDMEIEEN
Reset value0000000000000000000000000000
0x0A4DMA_S6NDTRResResResResResResResResResResResResResResResResNDT[15:0]
Reset value0000000000000000
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_S7CRResResResCHSEL[3:0]MBURST[1:0]PBURST[1:0]ResCTDBMPL[1:0]PINCOSMSIZE[1:0]PSIZE[1:0]MINCPINCCIRCDIR[1:0]PFCTRLTCIEHTIETEIEDMEIEEN
Reset value0000000000000000000000000000
0x0BCDMA_S7NDTRResResResResResResResResResResResResResResResResNDT[15:0]
Reset value0000000000000000
0x0C0DMA_S7PARPA[31:0]
Reset value00000000000000000000000000000000
0x0C4DMA_S7M0ARM0A[31:0]
Reset value00000000000000000000000000000000

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

OffsetRegister name313029282726252423222120191817161514131211109876543210
0x0C8DMA_S7M1ARM1A[31:0]
Reset value0000000000000000000000000000000
0x0CCDMA_S7FCRResResResResResResResResResResResResResResResResResResResResResResResFEIEResFS[2:0]DMDISFTTH[1:0]
Reset value0100001

Refer to Section 2.2 for the register boundary addresses.