HAL DMA Overview

Introducing DMA

group DMA_Introduction

In STM32 microcontrollers, the Direct Memory Access (DMA) controller enables data transfers between peripherals and memory or between memory regions. It supports multiple channels, programmable priority levels, and circular buffer management (circular mode). A transfer can be associated with a peripheral request.

Event generation and interrupt configuration are available per channel, based on various conditions.

Additional features can be activated, including triggered channels (where the trigger can be a peripheral event or a DMA channel event) and data-handling operations.

Support for privileged and unprivileged DMA transfers is available independently at the channel level.

For more information on linked list operations and queue management, refer to the Q Drivers.

Module and files

The following diagram illustrates the DMA module and its associated files.

Module and files diagram

Component diagram

The following diagram illustrates the software components involved in the DMA module. It shows the interactions between the user application, HAL drivers, low-level drivers, and the hardware components.


@startuml
<style>
componentDiagram {
   arrow {
      FontSize 8
   }
}
</style>

title DMA Software Component Diagram

package "HAL" {
    [HAL_SERVICE]
    [HAL_DMA]
    [HAL_Q]
}

package "Low Layer" {
    [LL_DMA]
    [CMSIS]
    [DMA Interrupt routine service]
}

package "HW" {
    [STM32_HW]
}

[Appli] --> [HAL_DMA] : HAL DMA API
[Appli] <-- [HAL_DMA] : DMA callback
[Appli] <-- [HAL_Q] : Status Q API
[Appli] --> [HAL_Q] : DMA transfer\nLinked-list Q\n API management
[HAL_DMA] --> [LL_DMA] : LL DMA API
[HAL_DMA] -l-> [HAL_SERVICE] : HAL_GetTick
[HAL_DMA] <-- [DMA Interrupt routine service]
[LL_DMA] --> [CMSIS]:DMA register def
[STM32_HW] -u--> [DMA Interrupt routine service] : DMA Channel Irq
[STM32_HW] <-u- [LL_DMA] : DMA registers R/W
[STM32_HW] <-u- [CMSIS]
@enduml

Configuration table

The following table lists the configuration defines for the HAL DMA module, specifying their locations, default values, and descriptions:

group DMA_Configuration_Table

Configuration inside the DMA driver

Config defines

Description

Default value

Note

PRODUCT

from IDE

NA

The selected device (eg STM32C5XXxx)

USE_HAL_DMA_MODULE

from hal_conf.h

1

Allows to use HAL DMA module.

USE_ASSERT_DBG_PARAM

from IDE

None

Allows to use the assert check parameters.

USE_ASSERT_DBG_STATE

from IDE

None

Allows to use the assert check states.

USE_HAL_CHECK_PARAM

from hal_conf.h

0

Allows to use the run-time checks parameters.

USE_HAL_CHECK_PROCESS_STATE

from hal_conf.h

0

Allows to use the load and store exclusive.

USE_HAL_DMA_CLK_ENABLE_MODEL

from hal_conf.h

HAL_CLK_ENABLE_NO

Allows to use the clock interface management for DMA.

USE_HAL_DMA_GET_LAST_ERRORS

from hal_conf.h

0

Allows to use error code mechanism.

USE_HAL_DMA_USER_DATA

from hal_conf.h

0

Allows to use user data.

USE_HAL_DMA_LINKEDLIST

from hal_conf.h

0

Allows to use linked list services.