This is an old revision of the document!


Direct Memory Access

The two DMA controller can be used to quickly transfer data between two peripherals (or memory) without any CPU interaction.




  • 8 streams for each DMA controller, up to 8 channels per stream.
  • 4 (32 bit wide) FIFO buffer per stream.
  • Programmable priority.


The code snippet bellow shows how to configure and use the DMA controller.

#include "reg_stm32f4xx.h"
 
RCC->AHBENR[0] |= (0x1 << 22u);      /* Enable DMA2 clock */
 
/* Configure DMA2 controller. */
DMA2->STREAM[0].CR |= (2u << 25u);   /* Setup channel. */
DMA2->STREAM[0].CR |= (0x0 << 6u);   /* Setup direction. */
DMA2->STREAM[0].CR |= (0x1 << 8u);   /* Setup circular mode. */
DMA2->STREAM[0].NDTR |= 1u;          /* Setup nr of transfers. */
 
/* Setup source and destination. */
DMA2->STREAM[0].PAR |= (uint32_t) &(ADC3->DR);
DMA2->STREAM[0].M0AR |= (uint32_t) &(TIM3->CCR[0]);
 
/* Setup buffer size. */
DMA2->STREAM[0].CR |= (0x1 << 11u);  /* PSIZE */
DMA2->STREAM[0].CR |= (0x1 << 13u);  /* MSIZE */
 
/* Start DMA transfer. */
DMA2->STREAM[0].CR |= (0x1 << 0u);


Hardware Abstraction Layer
Registry Types
InES DMA HAL Interface


CR1

Configuration register 1
(not used in I²S mode)




MSTR0Slave mode (reset state)
1Master mode
BR000BR ⇒ fPCLK2 / 2 (reset state)100BR ⇒ fPCLK2 / 32
001BR ⇒ fPCLK2 / 4101BR ⇒ fPCLK2 / 64
010BR ⇒ fPCLK2 / 8110BR ⇒ fPCLK2 / 128
011BR ⇒ fPCLK2 / 16111BR ⇒ fPCLK2 / 256
SPE0SPI disabled (reset state)
1SPI enabled
LSBFIRST0MSB transmitted first (reset state)
1LSB transmitted first
SSM0Slave management by hw (reset state)
1Slave management by sw
DFF0Data frame: 8 bit (reset state)
1Data frame: 16 bit
  • stm32/peripherals/dma.1474530047.txt.gz
  • Last modified: 2016/09/22 07:40
  • by feur