Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the method of selecting cyclic sampling in stm32f051 adc single software?

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "what is the method of selecting cyclic sampling for stm32f051 adc single software". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "stm32f051 adc single software selection cycle sampling method is what" it!

Void ADC1_Config (void) {ADC_InitTypeDef ADC_InitStruct; GPIO_InitTypeDef GPIO_InitStruct; / * Enable GPIOA clock * / RCC_AHBPeriphClockCmd (RCC_AHBPeriph_GPIOA, ENABLE); / / enable GPIOA clock / * ADC1 Periph clock enable * / RCC_APB2PeriphClockCmd (RCC_APB2Periph_ADC1, ENABLE); / / enable ADC1 clock / * Configure PA.0 as analog input * / GPIO_InitStruct.GPIO_Pin = GPIO_Pin_0; GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AN GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init (GPIOA, & GPIO_InitStruct); / / set PA0 as analog input. PA0 corresponds to channel 0 ADC with a total of 19 channels, 16 external channels, one temperature, one voltage, and one internal Vbat channel of its own. / * ADC1 DeInit * / ADC_DeInit (ADC1); / * Initialize ADC structure * / ADC_StructInit (& ADC_InitStruct); / * Configure the ADC1 in continous mode withe a resolutuion equal to 12 bits * / ADC_InitStruct.ADC_Resolution = ADC_Resolution_12b; / / 12-bit resolution ADC_InitStruct.ADC_ContinuousConvMode = ENABLE / / cyclic sampling, which means that the whole program can be converted many times, and the entire program life cycle can only be triggered once ADC_InitStruct.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None; software triggers ADC_InitStruct.ADC_DataAlign = ADC_DataAlign_Right; right alignment ADC_InitStruct.ADC_ScanDirection = ADC_ScanDirection_Upward; ADC_Init (ADC1, & ADC_InitStruct) ADC_ChannelConfig (ADC1, ADC_Channel_0, ADC_SampleTime_55_5Cycles); set the sampling channel, be sure to correspond the channel number to the pin string number / * ADC Calibration * / ADC_GetCalibrationFactor (ADC1); / / adc calibrate ADC_Cmd (ADC1, ENABLE); enable adc / * Wait the ADCEN falg * / while (! ADC_GetFlagStatus (ADC1, ADC_FLAG_ADEN)) / * ADC1 regular Software Start Conv * / ADC_StartOfConversion (ADC1); start ADC conversion} ADCData [Num] = ADC_GetConversionValue (ADC1) in the actual program can use this function for sampling, I believe that everyone on the "stm32f051 adc single software to choose cyclic sampling method is what" have a deeper understanding, might as well to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report