Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
stm32:peripherals:dma [2016/09/22 08:43] – feur | stm32:peripherals:dma [2022/12/28 07:50] (current) – ruan | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Direct Memory Access ====== | ====== Direct Memory Access ====== | ||
- | The two DMA controller | + | The two DMA controllers |
+ | Not all combinations of peripherals are possible: available [[dma_connection|DMA connections]]. \\ | ||
\\ {{dma_complete.svg? | \\ {{dma_complete.svg? | ||
Line 8: | Line 9: | ||
* 8 streams for each DMA controller, up to 8 channels per stream. | * 8 streams for each DMA controller, up to 8 channels per stream. | ||
- | * 4 (32 bit wide) FIFO buffer | + | * 4 (32 bit wide) FIFO buffers |
* Programmable priority. | * Programmable priority. | ||
- | \\ | ||
- | |||
- | ===== Programming Example ===== | ||
- | |||
- | The code snippet bellow shows how to configure and use the DMA controller. | ||
- | |||
- | <code c> | ||
- | #include " | ||
- | |||
- | RCC-> | ||
- | |||
- | /* Configure DMA2 controller. */ | ||
- | DMA2-> | ||
- | DMA2-> | ||
- | DMA2-> | ||
- | DMA2-> | ||
- | |||
- | /* Setup source and destination. */ | ||
- | DMA2-> | ||
- | DMA2-> | ||
- | |||
- | /* Setup buffer size. */ | ||
- | DMA2-> | ||
- | DMA2-> | ||
- | |||
- | /* Start DMA transfer. */ | ||
- | DMA2-> | ||
- | |||
- | </ | ||
- | \\ | ||
- | |||
- | > {{logo_hal.svg? | ||
- | > [[https:// | ||
- | > [[https:// | ||
\\ | \\ | ||
===== Configuration Registers ===== | ===== Configuration Registers ===== | ||
- | ==== SxCR ==== | + | ==== DMA_SxCR - Stream X configuration register |
- | + | ||
- | Stream X configuration register | + | |
\\ {{dma_reg_sxcr.svg}} \\ \\ | \\ {{dma_reg_sxcr.svg}} \\ \\ | ||
Line 60: | Line 25: | ||
|CIR|0|Circular mode disabled (reset state)|| | |CIR|0|Circular mode disabled (reset state)|| | ||
|::: | |::: | ||
- | |DIR|00|Direction peripheral to memory (reset state)|10|Direction memory to memory| | + | |DIR|00|Direction peripheral to memory (reset state)|| |
- | |:::|01|Direction memory to peripheral|11|reserved| | + | |:::|01|Direction memory to peripheral|| |
- | |PSIZE*|00|Peripheral size 8 bit (reset state)|10|Peripheral size 32 bit| | + | |:::|10|Direction memory to memory|| |
- | |:::|01|Peripheral size 16 bit|11|reserved| | + | |:::|11|reserved|| |
- | |MSIZE*|00|Memory size 8 bit (reset state)|10|Memory | + | |PSIZE*|00|Peripheral size 8 bit (reset state)|| |
- | |:::|01|Memory size 16 bit|11|reserved| | + | |:::|01|Peripheral size 16 bit|| |
+ | |:::|10|Peripheral size 32 bit|| | ||
+ | |:::|11|reserved|| | ||
+ | |MSIZE*|00|Memory size 8 bit (reset state)|| | ||
+ | |:::|01|Memory size 16 bit|| | ||
+ | |:::|10|Memory | ||
+ | |:::|11|reserved|| | ||
* Only writeable if EN = ' | * Only writeable if EN = ' | ||
- | ==== SxPAR ==== | + | ==== DMA_SxPAR - Stream X peripheral address register |
- | + | ||
- | Stream X peripheral address register | + | |
\\ {{dma_reg_sxpar.svg}} \\ \\ | \\ {{dma_reg_sxpar.svg}} \\ \\ | ||
Line 78: | Line 47: | ||
|NDT|xxx|Number of data items to be transfered.| | |NDT|xxx|Number of data items to be transfered.| | ||
- | ==== SxM0AR ==== | + | ==== DMA_SxM0AR - Stream X memory 0 address register==== |
- | + | ||
- | Stream X memory 0 address register | + | |
\\ {{dma_reg_sxm0ar.svg}} \\ \\ | \\ {{dma_reg_sxm0ar.svg}} \\ \\ | ||
Line 87: | Line 54: | ||
|M0A|xxx|Base address of memory 0.| | |M0A|xxx|Base address of memory 0.| | ||
- | ==== SxM1AR ==== | + | ==== DMA_SxM1AR - Stream X memory 1 address register |
- | + | ||
- | Stream X memory 1 address register | + | |
\\ {{dma_reg_sxm1ar.svg}} \\ \\ | \\ {{dma_reg_sxm1ar.svg}} \\ \\ | ||
Line 96: | Line 61: | ||
|M1A|xxx|Base address of memory 1.| | |M1A|xxx|Base address of memory 1.| | ||
- | ==== SxNDTR ==== | + | ==== DMA_SxNDTR - Stream X number of data register |
- | + | ||
- | Stream X number of data register | + | |
\\ {{dma_reg_sxndtr.svg}} \\ \\ | \\ {{dma_reg_sxndtr.svg}} \\ \\ | ||
Line 104: | Line 67: | ||
|< 100% 5em >| | |< 100% 5em >| | ||
|NDT|xxx|Number of data items to be transfered.| | |NDT|xxx|Number of data items to be transfered.| | ||
+ | |||
+ | ===== Programming Example ===== | ||
+ | |||
+ | The code snippet below shows how to configure and use the DMA controller. | ||
+ | |||
+ | <code c> | ||
+ | #include " | ||
+ | |||
+ | RCC-> | ||
+ | |||
+ | /* Configure DMA2 controller. */ | ||
+ | DMA2-> | ||
+ | DMA2-> | ||
+ | DMA2-> | ||
+ | DMA2-> | ||
+ | |||
+ | /* Setup source and destination. */ | ||
+ | DMA2-> | ||
+ | DMA2-> | ||
+ | |||
+ | /* Setup buffer size. */ | ||
+ | DMA2-> | ||
+ | DMA2-> | ||
+ | |||
+ | /* Start DMA transfer. */ | ||
+ | DMA2-> | ||
+ | |||
+ | </ | ||
+ | \\ |