STM32的同步注入模式怎么用阿?怎么设置都只能使得ADC1可以转换,ADC2似乎没有反应。 /******************************************************************************* * Function Name : ADC_Config * Description : * Input : None * Output : None * Return : None *******************************************************************************/ void ADC_Config(void) { ADC_InitTypeDef ADC_InitStructure;
/* ADC1 Configuration ------------------------------------------------------*/ ADC_InitStructure.ADC_Mode = ADC_Mode_InjecSimult; ADC_InitStructure.ADC_ScanConvMode = DISABLE; ADC_InitStructure.ADC_ContinuousConvMode = DISABLE; ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None; ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; ADC_InitStructure.ADC_NbrOfChannel = 1; ADC_Init(ADC1, &ADC_InitStructure); /* ADC2 Configuration ------------------------------------------------------*/ ADC_InitStructure.ADC_Mode = ADC_Mode_InjecSimult; ADC_InitStructure.ADC_ScanConvMode = DISABLE; ADC_InitStructure.ADC_ContinuousConvMode = DISABLE; ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None; ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; ADC_InitStructure.ADC_NbrOfChannel = 1; ADC_Init(ADC2, &ADC_InitStructure); /* ADC1 Injected channels configuration */ ADC_InjectedChannelConfig(ADC1, ADC_Channel_10, 1, ADC_SampleTime_239Cycles5); /* ADC2 Injected channels configuration */ ADC_InjectedChannelConfig(ADC2, ADC_Channel_17, 1, ADC_SampleTime_239Cycles5); /* ADC1 injected external trigger configuration */ ADC_ExternalTrigInjectedConvConfig(ADC1, ADC_ExternalTrigInjecConv_None); /* Enable JEOC interupt */ ADC_ITConfig(ADC1, ADC_IT_JEOC, ENABLE); /* Enable ADC1 */ ADC_Cmd(ADC1, ENABLE); /* Enable Vrefint channel17 */ ADC_TempSensorVrefintCmd(ENABLE);
/* Enable ADC1 reset calibaration register */ ADC_ResetCalibration(ADC1); /* Check the end of ADC1 reset calibration register */ while(ADC_GetResetCalibrationStatus(ADC1));
/* Start ADC1 calibaration */ ADC_StartCalibration(ADC1); /* Check the end of ADC1 calibration */ while(ADC_GetCalibrationStatus(ADC1));
/* Enable ADC2 */ ADC_Cmd(ADC2, ENABLE);
/* Enable ADC2 reset calibaration register */ ADC_ResetCalibration(ADC2); /* Check the end of ADC2 reset calibration register */ while(ADC_GetResetCalibrationStatus(ADC2));
/* Start ADC2 calibaration */ ADC_StartCalibration(ADC2); /* Check the end of ADC2 calibration */ while(ADC_GetCalibrationStatus(ADC2));
/* Start ADC1 Software Conversion */ //ADC_SoftwareStartInjectedConvCmd(ADC1, ENABLE);
/* Start ADC1 Software Conversion */ ADC_SoftwareStartConvCmd(ADC1, ENABLE); } |