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/21 12:13] – 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. | ||
+ | \\ | ||
+ | ===== Configuration Registers ===== | ||
+ | |||
+ | ==== DMA_SxCR - Stream X configuration register ==== | ||
+ | |||
+ | \\ {{dma_reg_sxcr.svg}} \\ \\ | ||
+ | |||
+ | |< 100% 5em 5em 15em 5em >| | ||
+ | |EN|0|Stream disabled (reset state)|| | ||
+ | |::: | ||
+ | |CHSEL|xxx|Channel nr selected (0..7)|| | ||
+ | |CIR|0|Circular mode disabled (reset state)|| | ||
+ | |::: | ||
+ | |DIR|00|Direction peripheral to memory (reset state)|| | ||
+ | |::: | ||
+ | |::: | ||
+ | |::: | ||
+ | |PSIZE*|00|Peripheral size 8 bit (reset state)|| | ||
+ | |::: | ||
+ | |::: | ||
+ | |::: | ||
+ | |MSIZE*|00|Memory size 8 bit (reset state)|| | ||
+ | |::: | ||
+ | |::: | ||
+ | |::: | ||
+ | |||
+ | * Only writeable if EN = ' | ||
+ | |||
+ | ==== DMA_SxPAR - Stream X peripheral address register ==== | ||
+ | |||
+ | \\ {{dma_reg_sxpar.svg}} \\ \\ | ||
+ | |||
+ | |< 100% 5em >| | ||
+ | |NDT|xxx|Number of data items to be transfered.| | ||
+ | |||
+ | ==== DMA_SxM0AR - Stream X memory 0 address register==== | ||
+ | |||
+ | \\ {{dma_reg_sxm0ar.svg}} \\ \\ | ||
+ | |||
+ | |< 100% 5em >| | ||
+ | |M0A|xxx|Base address of memory 0.| | ||
+ | |||
+ | ==== DMA_SxM1AR - Stream X memory 1 address register ==== | ||
+ | |||
+ | \\ {{dma_reg_sxm1ar.svg}} \\ \\ | ||
+ | |||
+ | |< 100% 5em >| | ||
+ | |M1A|xxx|Base address of memory 1.| | ||
+ | |||
+ | ==== DMA_SxNDTR - Stream X number of data register ==== | ||
+ | |||
+ | \\ {{dma_reg_sxndtr.svg}} \\ \\ | ||
+ | |||
+ | |< 100% 5em >| | ||
+ | |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-> | ||
+ | |||
+ | </ | ||
\\ | \\ |