当前位置:网站首页>STM32 ADC acquisition via DMA (HAL Library)
STM32 ADC acquisition via DMA (HAL Library)
2022-06-22 16:45:00 【Wax gourd~】

List of articles
One . Preface

ADC Refers to analog-to-digital conversion , That is, converting analog signals into digital signals . The signal essence of the world is analog signal , Such as speed 、 temperature 、 voice , In essence, they are simulated . However, the electronic devices running on microcontrollers and microprocessors cannot directly read or interpret these analog values , Because they are only in 0 and 1 Up operation . So we need to convert these analog values into 0 and 1, So that microcontrollers and microprocessors can understand them . This is what we call the conversion of analog signals into digital signals . And ADC The corresponding is DAC, That is, to convert digital signals into analog signals .
Two . CubeMX To configure
development environment :Keil 、 CubeMX
Software version :5.31 、6.2.1
Using chips :STM32F103C8T6
development language :C
CubeMX The configuration is very simple :Analog->ADCx->INx .

Select multi-channel acquisition here , choice ADC1 , Check IN1 、IN2 . The configuration is as follows :
- Because it is a multi-channel acquisition , To be opened
Scan Conversion Mode Scanning mode. - Multiple reads are required , So it turns on
Continuous Conversion Mode Continuous conversion mode. - Optional
Rank, to IN1、IN2 Select the appropriate sampling channel and sampling period .

add to DMA passageway , Change the mode to Circular Circulation patterns , So every time DMA After successful transmission, the next transmission will be started .

3、 ... and . ADC Read
Start the function :
HAL_ADC_Start_DMA(ADC_HandleTypeDef* hadc, uint32_t* pData, uint32_t Length)
take ADC Used for reading the remote lever : The essence of the remote lever is a potentiometer , adopt ADC The remote pole can be obtained by collecting the changed voltage X、Y Remote lever value of axis . Follow the above configuration , In the generated Keil Add the following code to the project to get the collected remote rod value .
uint16_t Joystick_ADC[2];
HAL_ADC_Start_DMA(&hadc1,(uint32_t*)&Joystick_ADC,2);

Be careful : If open ADC Of DMA It is possible that the main function cannot continue to run after receiving because the set sampling period is too short , Trigger frequently DMA Accept the interruption . Can be in CubeMX Zhongba Rank Middle channel Sampling period Samplink Time Make it longer , Close test effectively .
边栏推荐
- VHEDT业务发展框架
- Interface (optimization type annotation)
- Interview knowledge points
- 从Application提交角度审视Executor
- SAP script tutorial: se71, se78, SCC1, vf03, so10-013
- 浙江创投圈的“半壁江山”,还得是国资
- Unable to connect after win10 WiFi is disconnected
- 招行23型号UKey在win7上无法识别
- Parts beyond the text are indicated by ellipsis
- nio文件和文件夹操作例子
猜你喜欢

对ABAP程序调优的学习(四)LOOP WHERE KEY

What is SAP ABAP? Type, ABAP full form and meaning

洞见科技牵头的全球「首个」IEEE隐私计算「互联互通」国际标准正式启动

CUMT学习日记——数字图像处理考试速成笔记

What is restful and what rules should be followed when designing rest APIs?

【C语言】深度剖析整型和浮点型在内存中的存储

User exit and customer exit in SAP ABAP -015

SAP web service cannot log in to SOA management page with soamanager

In case of default import failure
![[wechat applet custom bottom tabbar]](/img/04/2ea4ab3fd8571499190a9b3c9990b2.png)
[wechat applet custom bottom tabbar]
随机推荐
How to use IDM to accelerate Baidu cloud
【小程序项目开发-- 京东商城】uni-app开发之配置tabBar & 窗口样式
Summary of JS methods for obtaining data types
机器学习笔记 - HaGRID—手势识别图像数据集简介
Implementation classes with similar execution logic use the template pattern
In case of default import failure
variable
win10的wifi断线后无法连接
SAP ABAP dialog programming tutorial: module pool in -09
高可用性的ResourceManager
Make the code elegant (learn debugging + code style)
MYSQL_ERRNO : 1292 Truncated incorrect date value At add_num :1
迭代器与生成器
What is restful and what rules should be followed when designing rest APIs?
大话局部性原理
Iterators and generators
nio服务多线程版本
IO模型的5中模式
NiO programming service
jsp学习之(三)--------- jsp隐式对象