当前位置:网站首页>Stm32f4 ll library multi-channel ADC
Stm32f4 ll library multi-channel ADC
2022-06-12 05:10:00 【Cocoa core】
One 、 Reference resources
- Refer to this big man :https://blog.csdn.net/qq_45100839/article/details/114399506
Two 、 step
contrast STM32F0,ADC We need to add Number Of Conversion Configuration of , Then some other configurations are rarely different
ADC To configure , I am here 2 Channels


DMA To configure

I don't use interrupts here , Direct query waiting , You can refer to the link reference above to add an interrupt
Add code
void adc_dma_init() { /* Set DMA transfer addresses of source and destination */ LL_DMA_ConfigAddresses(DMA2, LL_DMA_STREAM_0, LL_ADC_DMA_GetRegAddr(ADC1, LL_ADC_DMA_REG_REGULAR_DATA), (uint32_t)&adcBuf, LL_DMA_DIRECTION_PERIPH_TO_MEMORY);// To configure DMA, take DMA And ADC1 Link together /* Set DMA transfer size */ LL_DMA_SetDataLength(DMA2,LL_DMA_STREAM_0,ADC_DMA_BUF_SIZE);// Set up DMA The length of , With storage ADC The value array is equal in length /* Enable the DMA transfer */ LL_DMA_EnableStream(DMA2,LL_DMA_STREAM_0);// Can make DMA transmission LL_ADC_Enable(ADC1);// open ADC /* Start ADC group regular conversion */ LL_ADC_REG_StartConversionSWStart(ADC1);// start-up ADC Group general conversion ,SWStart And cubmx Configuration in progress ADCs_Regular_ConversionMode Of External Trigger Conversion Source ADC Corresponding LL_ADC_REG_SetDMATransfer(ADC1,LL_ADC_REG_DMA_TRANSFER_UNLIMITED);// Start conversion } ///> adc Some macro definitions #define ADC_DMA_BUF_CH 2 /* altogether 2 Channels */ #define ADC_DMA_BUF_LEN 8 /* Every channel 8 A data cache */ #define ADC_DMA_BUF_SIZE (ADC_DMA_BUF_LEN*ADC_DMA_BUF_CH) /* total BUF size */ uint8_t adc_get( uint16_t *adc_data_buf) { if ( LL_DMA_IsActiveFlag_TC0(DMA2) ) { uint16_t i,j; uint16_t * tadBuf; tadBuf = & adcBuf[0]; for(i = 0; i < ADC_DMA_BUF_CH; i++) { tAD[i] = 0; } for(i = 0; i < ADC_DMA_BUF_CH; i++) { for(j = 0; j < ADC_DMA_BUF_LEN; j++) { tAD[i] = tAD[i] + tadBuf[j*ADC_DMA_BUF_CH + i]; } tAD[i] = tAD[i] / ADC_DMA_BUF_LEN; } memcpy(adc_data_buf,tAD,ADC_DMA_BUF_CH*2); /* Be careful memcpy Or in accordance with 8 position copy So we need to *2 Conduct copy */ return 1; } return 0; }
边栏推荐
- leetcode 263. Ugly number
- LabVIEW about TDMS and Binary Storage Speed
- CCF access control system
- Set common methods
- One dragon and one knight accompanying programmers are 36 years old
- Ecosystem type distribution data, land use data, vegetation type distribution and nature reserve distribution data
- Common MySQL date query
- JS set the position of the current scroll bar
- [backtracking] backtracking to solve subset problems
- Some problems of silly girl solved
猜你喜欢

How Bi makes SaaS products have a "sense of security" and "sensitivity" (Part I)

Token based authentication

1008 color classification

National land use data of 30m precision secondary classification

How to deploy PostgreSQL as a docker container

Microsoft announces that it will discontinue support for older versions of visual studio

2022 examination questions and simulation examination for crane driver (limited to bridge crane)

Main business objects of pupanvr record (5)

How to count the total length of roads in the region and draw data histogram

A complete set of installation procedures (for learning and communication only)
随机推荐
IC验证中的force/release 学习整理(5)研究对 reg类型信号的影响
LabVIEW关于TDMS和Binary存储速度
How Bi makes SaaS products have a "sense of security" and "sensitivity" (Part I)
[backtracking method] queen n problem
Common MySQL date query
Servlet core technology
Can‘t find a suitable configuration file in this directory or any parent. Error reporting and resolution
Ubunt 20.04 uses CDROM or ISO as the installation source
LabVIEW about TDMS and Binary Storage Speed
A complete set of installation procedures (for learning and communication only)
What is reverse repurchase of treasury bonds? Is the reverse repurchase of treasury bonds safe?
February 19, 2022 [Nolan] Nolan resurrected? Change · Nolan [soul orchid] can be connected to XDD / silly girl
BI 如何让SaaS产品具有 “安全感”和“敏锐感”(上)
leetcode 263. Ugly number
Some problems of Qinglong panel
Rv1109 lvgl UI development
New year news of osdu open underground data space Forum
Chapter 1
Self implementation of a UI Library - UI core drawing layer management
How to clear floating, and how does it work?