当前位置:网站首页>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 .
边栏推荐
- [wechat applet to obtain the height of custom tabbar] is absolutely available!!!
- Test for API
- SAP ABAP BAPI-016
- Iterators and generators
- 【微信小程序封装底部弹出框二】
- Task scheduling design of collection system
- Jsp Learning (2) - - jsp script Elements and instructions
- Special research on Intelligent upgrading of heavy trucks in China in 2022
- 浙江创投圈的“半壁江山”,还得是国资
- SAP ABAP dialog programming tutorial: module pool in -09
猜你喜欢

6.gui (graphics, filling)
![[C language] deeply analyze the storage of integer and floating-point types in memory](/img/8b/12a4dc7a0c0e34e2add007592971dd.jpg)
[C language] deeply analyze the storage of integer and floating-point types in memory

【小程序项目开发-- 京东商城】uni-app开发之轮播图

高可用性的ResourceManager

Shell learning

首个赛博格人陨落背后:科技与渐冻症的极限赛跑

Vhedt business development framework

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

SAP ABAP table control and example-07

JSP learning (2) -- JSP script elements and instructions
随机推荐
过气剧本杀,被露营“复活”
JSP learning (2) -- JSP script elements and instructions
The world's "first" IEEE privacy computing "connectivity" international standard led by insight technology was officially launched
vs2017 在调试状态不显示QString值的解决方法
让代码优雅起来(学会调试+代码风格)
Uniapp wechat applet obtains page QR code (with parameters)
Unable to connect after win10 WiFi is disconnected
SAP ABAP internal tables: create, read, populate, copy and delete-06
SAP ABAP BAPI-016
视频会议时听不到声音该如何处理?
User exit and customer exit in SAP ABAP -015
同花顺怎么开户?网上开户安全么?
JS method for judging data type of interview questions
Test for API
【C语言】库函数qsort的使用
[pop up box 2 at the bottom of wechat applet package]
SAP ABAP report programming-08
Learning about ABAP program tuning (IV) loop where key
【微信小程序封装底部弹出框二】
sql语法检测