当前位置:网站首页>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; }
边栏推荐
- Parallélisation de l'entraînement accéléré TF. Données. Générateur de données
- LabVIEW about TDMS and Binary Storage Speed
- Some problems of Qinglong panel
- Harris corner detection principle-
- How to count the total length of roads in the region and draw data histogram
- How to deploy dolphin scheduler 1.3.1 on cdh5
- MySQL5.7.21 Build For ARM
- Layer sublayer assigns values to the page elements of the parent layer to achieve the effect of transferring values to the page of the parent layer
- Ten trends of Internet Security in 2022 industry released
- Some problems of silly girl solved
猜你喜欢

cellular automaton
![[GIS tutorial] ArcGIS for sunshine analysis (with exercise data download)](/img/60/baebffb2024ddf5f2cb070f222b257.jpg)
[GIS tutorial] ArcGIS for sunshine analysis (with exercise data download)

When the build When gradle does not load the dependencies, and you need to add a download path in libraries, the path in gradle is not a direct downloadable path

JWT学习与使用

Interview must ask: summary of ten classic sorting algorithms
![[cjson] precautions for root node](/img/6c/4462bc8126935f00a5c64f18de13ea.png)
[cjson] precautions for root node

2022 "college entrance examination memory" has been packaged, please check!

How to deploy dolphin scheduler Apache dolphin scheduler 1.2.0 in cdh5.16.2

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

How to deploy PostgreSQL as a docker container
随机推荐
加速训练之并行化 tf.data.Dataset 生成器
Object class not ended
Longest palindrome string
CentOS compiling and installing mysql8.0
JS how to get the date
How Bi makes SaaS products have a "sense of security" and "sensitivity" (Part I)
Rv1109 lvgl UI development
Codec of ASoC framework driven by alsa
Interview must ask: summary of ten classic sorting algorithms
Operation of simulated examination platform for theoretical question bank of G2 utility boiler stoker in 2022
Uview customer management JS
Pupanvr- an open source embedded NVR system (1)
Introduction to audio alsa architecture
Ubunt 20.04 uses CDROM or ISO as the installation source
Design of a simple embedded web service application
Some problems of silly girl solved
Interview must ask: summary of ten classic sorting algorithms
1008 color classification
Transpiration and evapotranspiration (ET) data, potential evapotranspiration, actual evapotranspiration data, temperature data, rainfall data
[backtracking method] backtracking method to solve the problem of Full Permutation