本帖最后由 xd__kun 于 2014-7-8 20:08 编辑
最近刚接触STM32F103C8T6芯片,在adc转换时候单路实现了,不知道这么实现多路ADC转换
不知道哪位大侠能指点下,最好是能用上DMA
我的程序如下,求指点:
void Adc_GpioInit(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_2 ;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
GPIO_Init(GPIOA , &GPIO_InitStructure);
}
void Adc_Config1(void)
{
ADC_InitTypeDef ADC_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);
RCC_ADCCLKConfig(RCC_PCLK2_Div4); //配置ADC时钟分频
ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
ADC_InitStructure.ADC_ScanConvMode = ENABLE;
ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
ADC_InitStructure.ADC_NbrOfChannel = 1;
ADC_Init(ADC1,&ADC_InitStructure);
//ADC_RegularChannelConfig(ADC1,ADC_Channel_1,1, ADC_SampleTime_239Cycles5); //ADC_SampleTime_55Cycles5
ADC_RegularChannelConfig(ADC1,ADC_Channel_2,1, ADC_SampleTime_55Cycles5); //ADC_SampleTime_55Cycles5
ADC_Cmd(ADC1,ENABLE);
ADC_ResetCalibration(ADC1);
while(ADC_GetResetCalibrationStatus(ADC1));
ADC_StartCalibration(ADC1);
while(ADC_GetCalibrationStatus(ADC1));
ADC_SoftwareStartConvCmd(ADC1,ENABLE);
}
int main(void)
{
Main_InitSys(); //为了是main函数看起来更简洁些,我们将硬件初始化的代码封装到这个函数
while (1)
{
ADC_RegularConvertedValueTab[0] = ADC_GetConversionValue(ADC1) ;
}
}
|