当前位置:网站首页>STM32 - DMA
STM32 - DMA
2022-07-31 04:55:00 【Mountain,】
DMA(Direct Memory Access)That is, direct storage access.
简单理解,DMA就是不占用CPUThe data transfer mode of the resource.DMA 传输将数据从AThe address space is copied toB地址空间,这个过程由 DMA 控制器来完成,CPU只需要把DMAJust do the initial setup,在数据传输时不需要CPU参与.
使用DMA可以大大减轻CPU工作量,尤其是数据量非常大的时候.
比如从ADCOr the serial port is coming3000个数据,CPUCopying data is required3000次操作:
for(int i = 0;i < 3000;i++)
{
buf[i] = data;
}
虽然目前的CPU主频很高,3000data can be transferred immediately,But in some cases this doesn't work.during this period of data transmission,CPU只负责传输数据,十分浪费CPU资源.So for large-capacity data transmission this situation is not actually neededCPU一直参与,只需在A、B之间创建个通道,让它们自己传输即可.这就是DMA,Generally used for large data transfersDMA进行数据传输.
使用DMA,Only need to provide two addresses and a data length on it,Destination address and data source address,启动DMA后,DMAAutomatically move data from the data source address to the destination address.This is liberatingCPU,使得CPUcan do other more important things.
DMAThere are the following three data transfer modes:
1、内存到外设
2、外设到内存
3、内存到内存
DMA控制器:
从上图可以看到,DMAThere are eight data streams,Each data stream has 8个通道.
流:数据传输的链路,One maximum transfer256KB数据.
通道:Every data stream has it8个通道选择,每个通道对应不同的DMA请求,比如ADC、DAC、串口等.
DMA请求映射:
DMA_SxCR设置DMA通道、数据流、优先级等设置
当多个DMAWhen the request comes at the same time,DMA会通过DMAThe arbiter decides who to deal with first.
软件:DMA_SxCR的PL位决定.
硬件:Data stream numbers with smaller numbers have higher priority.
同一个数据流只能使用一个通道,同一个DMA控制器可以使用多个数据流.
DMA控制器中的FIFOIt can be simply thought of as a buffer,Provide a data transfer space between the data source and the target.
DMAThere is a direct mode for data movement、FIFO模式等.
Direct mode is where the data arrivesFIFOSend out directly.
FIFOIt can be set to pass in a few bytes before passing out,if it comes in4、8、12、16start out after bytes
FIFO突发模式:Look at your data and send it several times,一次发送、Send twice and so on.
DMARelated structures and initialization functions(基于标准库):
DMA初始化结构体DMA_ InitTypeDef
:
typedef struct
{
uint32_t
uint32_t DMA_PeripheralBaseAddr; // 外设地址
uint32_t DMA_MemoryBaseAddr; // 存储器地址
uint32_t DMA_DIR; // 传输方向:内存到外设、外设到内存、内存到内存
uint32_t DMA_BufferSize; // 传输数目:传输数据的个数
uint32_t DMA_PeripheralInc; // 外设地址是否递增
uint32_t DMA_MemoryInc; // 存储器地址是否递增
uint32_t DMA_PeripheralDataSize; // 外设数据宽度
uint32_t DMA_MemoryDataSize; // 存储器数据宽度
uint32_t DMA_Mode; // 模式选择
uint32_t DMA_Priority; // 通道优先级
uint32_t DMA_M2M; // 存储器到存储器模式
} DMA_InitTypeDef;
The data width of the source and destination is the same,数据不会丢失
The source is smaller than the destination width,数据不会丢失,But it will waste target memory
The source is larger than the destination width,数据会丢失,Receive data only at the target width
库函数:
初始化DMA的寄存器到复位状态:
DMA_DeInit(DMA_Stream_TypeDef* DMAy_Streamx);
DMA初始化:
void DMA_Init(DMA_Stream_TypeDef* DMAy_Streamx,DMA_InitTypeDef* DMA_InitStruct);
DMA使能函数:
MDA_Cmd(DMA_Stream_TypeDef* DMAy_Streamx,FunctionalState NewState);
边栏推荐
- MySQL transaction isolation level, rounding
- ERROR 1064 (42000) You have an error in your SQL syntax; check the manual that corresponds to your
- [C language] Detailed explanation of operators
- 开源社区三十年 | 2022开放原子全球开源峰会开源社区三十年专题活动圆满召开
- 简易网络文件拷贝的C实现
- MySQL模糊查询可以使用INSTR替代LIKE
- STM32——DMA
- input输入框展示两位小数之precision
- ABC D - Distinct Trio(k元组的个数
- 城市内涝及桥洞隧道积水在线监测系统
猜你喜欢
Hand in hand to realize the picture preview plug-in (3)
Centos7 install mysql5.7 steps (graphical version)
SQL injection of DVWA
[C language] Detailed explanation of operators
Solved (the latest version of selenium framework element positioning error) NameError: name 'By' is not defined
马斯克对话“虚拟版”马斯克,脑机交互技术离我们有多远
VScode+ESP32快速安装ESP-IDF插件
npm、nrm两种方式查看源和切换镜像
CentOS7 install MySQL graphic detailed tutorial
【云原生】DevOps(五):集成Harbor
随机推荐
马斯克对话“虚拟版”马斯克,脑机交互技术离我们有多远
The third is the code to achieve
The MySQL database installed configuration nanny level tutorial for 8.0.29 (for example) have hands
Vue项目通过node连接MySQL数据库并实现增删改查操作
sql statement - how to query data in another table based on the data in one table
.NET-9.乱七八糟的理论笔记(概念,思想)
MySQL开窗函数
mysql数据库安装(详细)
【线性神经网络】softmax回归
1. 获取数据-requests.get()
HCIP Day 10_BGP Route Summary Experiment
Unity Tutorial: URP Rendering Pipeline Practical Tutorial Series [1]
[py script] batch binarization processing images
VScode+ESP32 quickly install ESP-IDF plugin
Unity手机游戏性能优化系列:针对CPU端的性能调优
MySQL数据库安装配置保姆级教程(以8.0.29为例)有手就行
Lua,ILRuntime, HybridCLR(wolong)/huatuo hot update comparative analysis
VScode+ESP32快速安装ESP-IDF插件
ERROR 2003 (HY000) Can‘t connect to MySQL server on ‘localhost3306‘ (10061)
XSS shooting range (3) prompt to win