After 1 days, the ADC has not come out and found that the value of the processing is always fixed value.
Go to 21IC for help stickers. [STM32F0] stm32f030 ADC1 sampling Questions to ask
It was a long time since no one replied, but someone reminded me that I needed to wait for DMA data to complete.
After comparing the code of others,
/* ADC DMA request in circular mode */
Adc_dmarequestmodeconfig (ADC1, adc_dmamode_circular);
Other people have this code, so I add this word, you can normally sample the data,
Therefore, you must add, otherwise you cannot get to the sampled value.
Then we find that the DMA transfer to the specified array data is out of order .....
Like someone else's help sticker: [STM32F0] stm32f030 multi-channel ADC DMA read problem
After the solution, according to the last post to resolve the way
"The F0 ADC needs to be calibrated before it can be used. This 7-bit calibration value is also placed in the ADC_DR, which also triggers the DMA request. You can refer to the ADC-DMA routine of the F0, do the ADC calibration first, then set the DMA, and then enable the DMA of the ADC. "
Insert the code directly, the correct initialization code:[CPP] View plain copy typedef enum { adc_porta0 = ADC_Channel_0, ADC_PORTA1 = adc_channel_1, ADC_PORTA2 = ADC_Channel_2, ADC_PORTA3 = ADC_Channel_3, adc_porta4 = ADC_Channel_4, ADC_PORTA5 = ADC_Channel_5, ADC_PORTA6 = ADC_Channel_6, adc_porta7 = ADC_Channel_7, ADC_PORTA8 = ADC_Channel_8, ADC_PORTA9 = ADC_Channel_9,     ADC_ porta10 = adc_channel_10, adc_porta11 = adc_channel_11, adc_porta12 = adc_channel_12, adc_porta13 = ADC_Channel_13, ADC_PORTA14 = ADC_Channel_14, ADC_PORTA15 = ADC_Channel_15, }ad_port; typedef enum { KEY_LINE_1, KEY_LINE_2, adc_key_line_max = key_line_2, BATTERY_AD, ADC_NUM_CNT, Total   //ADC }adc_num; volatile u16 g_uadc_ CONVAL[ADC_NUM_CNT] = {0};      // ADC Conversion Values u32 const g_uadnum[]= { //keyporta1, ADC_PORTA9, adc_porta8, ADC_PORTA2, // keyporta0, }; void adc_init (void) { adc_deinit (ADC1); rcc_ahbperiphclockcmd (rcc_ahbperiph_gpioa, enable); rcc_ahbperiphclockcmd (rcc_ahbperiph_gpiob, enable); //open DMA1 Clock rcc_ahbperiphclockcmd (rcc_ahbperiph_dma1, ENABLE); //open ADC1 clock rcc_ Apb2periphclockcmd (rcc_apb2periph_adc1,enable); rcc_ Adcclkconfig (rcc_adcclk_pcLK_DIV4); //Initialize IO port