L342785896 发表于 2016-5-23 12:02:04

STM32F030 ADC采样问题

大家好:
我的ADC初始化如下:
voidAdc_Init(void)
{         
      ADC_InitTypeDef ADC_InitStructure;
      GPIO_InitTypeDef GPIO_InitStructure;

      RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1      , ENABLE );          //ʹÄÜADC1ͨµÀʱÖÓ
      RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA         , ENABLE );          //ʹÄÜHGPIOAͨµÀʱÖÓ


      RCC_ADCCLKConfig(RCC_ADCCLK_PCLK_Div4);   //ÉèÖÃADC·ÖƵÒò×Ó4 48M/4=12,ADC×î´óʱ¼ä²»Äܳ¬¹ý14M

      //PA5 ×÷ΪģÄâͨµÀÊäÈëÒý½Å                        
      GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;                //Ä£ÄâÊäÈëÒý½Å
      GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
      GPIO_Init(GPIOA, &GPIO_InitStructure);      

      ADC_DeInit(ADC1);//¸´Î»ADC1,½«ÍâÉè ADC1 µÄÈ«²¿¼Ä´æÆ÷ÖØÉèΪȱʡֵ
      ADC_StructInit(&ADC_InitStructure);
      
/* Configure the ADC1 in continous mode withe a resolutuion equal to 12 bits*/
ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b;
ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;
ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None;
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
ADC_InitStructure.ADC_ScanDirection = ADC_ScanDirection_Upward;
ADC_Init(ADC1, &ADC_InitStructure);         
      
//      ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b; //ת»»¾«¶È
//      ADC_InitStructure.ADC_ContinuousConvMode = DISABLE;      //µ¥´Îת»»Ä£Ê½
//      ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None; //ת»»ÓÉÈí¼þ¶ø²»ÊÇÍⲿ´¥·¢Æô¶¯
//      ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; //Êý¾ÝÓÒ¶ÔÆë
//      ADC_InitStructure.ADC_ScanDirection = ADC_ScanDirection_Upward;
//      ADC_Init(ADC1, &ADC_InitStructure);

      ADC_ChannelConfig(ADC1, ADC_Channel_5 , ADC_SampleTime_71_5Cycles);
      
      ADC_GetCalibrationFactor(ADC1);//ADCУ׼
      ADC_Cmd(ADC1, ENABLE);      //ʹÄÜÖ¸¶¨µÄADC1

/* µÈ´ýADRDY falg */
while(!ADC_GetFlagStatus(ADC1, ADC_FLAG_ADRDY));
      
/* ADC1 regular Software Start Conv */
ADC_StartOfConversion(ADC1);      //¿ªÆôÈí¼þת»»

}      


现在运行后发现,ADC脚输出3.7V电压,不知道为什么?

dsjsjf 发表于 2018-3-7 16:12:03

什么样的板子,应该是硬件问题
页: [1]
查看完整版本: STM32F030 ADC采样问题