Getting started with DMA

Revision as of 13:06, 19 December 2022 by Registered User (→‎Create the project in STM32CubeIde)
Under construction.png Coming soon

This article explains what is DMA and how to use it through examples

1. What is DMA?

DMA stands for Direct Memory Access controller. It is a bus master and system peripheral. The DMA is is used in order to provide high-speed data transfer between peripherals and memory as well as memory to memory. Data can be quickly moved by DMA without any CPU actions. This keeps CPU resources free for other operations.
During this article, we will be using the STM32L476 Nucleo board.
This device embeds 2 DMAs: DMA1 and DMA2. Each channel is dedicated to managing memory access requests from one or more peripherals.
The two DMA controllers have 14 channels in total, each dedicated to managing memory access requests from one or more peripherals. Each has an arbiter for handling the priority between DMA requests.

File:Capture.png

1.1. Objective

  • Learn how to setup DMA transfer in STM32CubeIDE
  • Create simple DMA memory to memory transfer from RAM to RAM, Peripheral to RAM and transfer with Interrupt

1.2. How to

  • Use CubeIDE and Generate Code with DMA
  • Learn how to setup the DMA in HAL
  • Verify the correct functionality by comparing transferred buffers

2. Create the project in STM32CubeIde

'File > New > STM32 Project in main panel.
create STM32CubeIDE project.png

This example uses the NUCLEO-L476RG board.
Start by selecting the NUCLEO-L476RG board using the Board Selector as shown in the figure below:
Select NUCLEO-L476RG board.png

In case you haven't downloaded the STM32L476 Cube library, it will be downloaded automatically. This however may take some time.

3. Peripheral to Memory Transfer

4. Memory to Memory Transfer

5. Data Transfer over DMA with Interrupt


[[category:Getting_started_with_STM32_system_peripherals | 30]]