官方例程:ADC1配置如下:
// ADC1 初始化
ADC_InitTypeDef ADC_InitStruct;
ADCx_1_APBxClock_FUN( ADCx_1_CLK, ENABLE );
ADC_InitStruct.ADC_Mode = ADC_Mode_RegSimult;
ADC_InitStruct.ADC_ScanConvMode = DISABLE;
ADC_InitStruct.ADC_ContinuousConvMode = ENABLE;
ADC_InitStruct.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
ADC_InitStruct.ADC_DataAlign = ADC_DataAlign_Right;
ADC_InitStruct.ADC_NbrOfChannel = NOFCHANEL;
ADC_Init(ADCx_1, &ADC_InitStruct);
RCC_ADCCLKConfig(RCC_PCLK2_Div8);
ADC_RegularChannelConfig(ADCx_1, ADCx_1_CHANNEL, 1, ADC_SampleTime_55Cycles5);
ADC2配置如下:
// ADC2 初始化
ADCx_1_APBxClock_FUN( ADCx_2_CLK, ENABLE );
ADC_InitStruct.ADC_Mode = ADC_Mode_RegSimult;
ADC_InitStruct.ADC_ScanConvMode = DISABLE;
ADC_InitStruct.ADC_ContinuousConvMode = ENABLE;
ADC_InitStruct.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
ADC_InitStruct.ADC_DataAlign = ADC_DataAlign_Right;
ADC_InitStruct.ADC_NbrOfChannel = NOFCHANEL;
ADC_Init(ADCx_2, &ADC_InitStruct);
RCC_ADCCLKConfig(RCC_PCLK2_Div8);
ADC_RegularChannelConfig(ADCx_2, ADCx_2_CHANNEL, 1, ADC_SampleTime_55Cycles5);
ADC1使能函数:ADC_SoftwareStartConvCmd(ADCx_1, ENABLE);
ADC2使能函数:ADC_ExternalTrigConvCmd(ADC2, ENABLE);
/*------------------------------------------------------------------------------------------------------------------------------*/
本例程的前提是双ADC规则同步。
ADC1和ADC2的配置都一模一样,外部触发转换都选择的是关闭,为什么在使能的时候,ADC1采用软件触发转换,而ADC2却采用外部触发转换,ADC1采用软件触发转换可以 理解,ADC2在配置的时候明明选择的是ADC_InitStruct.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None, 为什么在使能ADC2的时候却用ADC_ExternalTrigConvCmd(ADC2, ENABLE)这个函数使能,脑洞转不过来,有人能帮助解释一下吗? |