当前位置:网站首页>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 .
边栏推荐
- 调用cmd 进程通信
- [deep anatomy of C language] keywords if & else & bool type
- 如何为政企移动办公加上一道“安全锁”?
- MYSQL_ERRNO : 1205 MESSAGE :Lock wait timeout exceeded; try restarting transacti
- Interface (optimization type annotation)
- Spark Streaming-Receiver启动和数据接收
- 对ABAP程序调优的学习(四)LOOP WHERE KEY
- Jsp Learning (2) - - jsp script Elements and instructions
- Shell learning
- spark-cache的源码分析
猜你喜欢

Idea installation summary

SAP ABAP data types, operators and editors-02

Lecture 6 of slam Lecture 14 -- nonlinear optimization

【微信小程序封装底部弹出框】一

让代码优雅起来(学会调试+代码风格)

In the era of video explosion, who is supporting the high-speed operation of video ecological network?
![Consumption monitoring of Prometheus monitoring [consult exporter]](/img/9e/8547b2c38143ab0e051c1cf0b04986.png)
Consumption monitoring of Prometheus monitoring [consult exporter]

浙江创投圈的“半壁江山”,还得是国资

SAP ABAP sub screen tutorial: call sub screen -010 in SAP

【微信小程序获取自定义tabbar的高度】绝对可用!!!
随机推荐
Machine learning notes - Hagrid - Introduction to gesture recognition image data set
What is SAP ABAP? Type, ABAP full form and meaning
让代码优雅起来(学会调试+代码风格)
JSP learning (2) -- JSP script elements and instructions
spark常用 算子小总结
jsp學習之(二)---------jsp脚本元素和指令
[pop up box 2 at the bottom of wechat applet package]
接口(优化类型注解)
高可用性的ResourceManager
JSP学习之开发模式
【C语言】深度剖析指针和数组的关系
购买指南丨如何购买一台高质量会议平板,这几个方面一定要对比
Oracle database and table
调用cmd 进程通信
CUMT study diary - quick notes of digital image processing examination
Idea installation summary
面对默认导入失败的情况
In case of default import failure
联合主键引发的思考
Test for API