最近购买了stm32 f407 EXPLORER 探索者开发板,使用附带的ADC例程做测试,文件路径“探索者F4 资料盘(A盘)探索者F4 资料盘(A盘)4,程序源码2,标准例程-库函数版本实验18 ADC实验”。
开发板上的环境准备:PA5默认通过跳线帽连接TPAD,读取到的电压值约为3V左右,请拔了P12跳线帽,然后给PA5提供测试电压.
ADC配置程序如下:
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);
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);
RCC_APB2PeriphResetCmd(RCC_APB2Periph_ADC1,ENABLE);
RCC_APB2PeriphResetCmd(RCC_APB2Periph_ADC1,DISABLE);
ADC_CommonInitStructure.ADC_Mode = ADC_Mode_Independent;
ADC_CommonInitStructure.ADC_TwoSamplingDelay = ADC_TwoSamplingDelay_5Cycles;
ADC_CommonInitStructure.ADC_DMAAccessMode = ADC_DMAAccessMode_Disabled;
ADC_CommonInitStructure.ADC_Prescaler = ADC_Prescaler_Div4;//ADCCLK=PCLK2/4=84/4=21Mhz,
ADC_CommonInit(&ADC_CommonInitStructure);
ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b;
ADC_InitStructure.ADC_ScanConvMode = DISABLE;
ADC_InitStructure.ADC_ContinuousConvMode = DISABLE;
ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None;
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
ADC_InitStructure.ADC_NbrOfConversion = 1;
ADC_Init(ADC1, &ADC_InitStructure);ˉ
ADC_Cmd(ADC1, ENABLE);
我做了两次测试,
第一次是将ADC输入管脚与TPAD管脚短接,连续读取20个数据:
3631,3840,3847,3825,3824,3847,3828,3828,3832,3847,3815,3824,3841,3829,3834,3847,3847,3828,3841,3852
第一次是将ADC输入管脚与P12上GND管脚短接,连续读取20个数据:
0, 0, 1, 31, 0, 35, 12, 0, 30, 0, 37, 0, 0, 0, 0, 33, 0, 34, 33, 0
出现了最大30度的数值波动,请问这在F407的adc上算正常性能范围内吗?(个人感觉是波动太大了)
一周热门 更多>