void ADC1_Config(void)
{
adc_deinit();
rcu_adc_clock_config(RCU_ADCCK_APB2_DIV2);
rcu_periph_clock_enable(RCU_ADC);
adc_discontinuous_mode_config(ADC_REGULAR_CHANNEL,1);//
adc_special_function_config(ADC_SCAN_MODE,DISABLE);//
adc_special_function_config(ADC_INSERTED_CHANNEL_AUTO,DISABLE);
adc_special_function_config(ADC_CONTINUOUS_MODE,DISABLE);//
adc_data_alignment_config(ADC_DATAALIGN_RIGHT);//
adc_channel_length_config(ADC_REGULAR_CHANNEL,1);//
adc_external_trigger_config(ADC_REGULAR_CHANNEL,DISABLE);//
adc_dma_mode_disable();
}
uint16_t Get_ADC(uint8_t ADC_CH)
{
uint16_t Result;
adc_regular_channel_config(1,ADC_CH,ADC_SAMPLETIME_1POINT5);//
adc_flag_clear(ADC_FLAG_EOC);
adc_enable();//
adc_calibration_enable();
adc_software_trigger_enable(ADC_REGULAR_CHANNEL);
while(!adc_flag_get(ADC_FLAG_EOC));
Result = adc_regular_data_read();
adc_disable();
return Result;
}
main
{
BatVoltage_Data = Get_ADC(ADC_CHANNEL_9);
}
请问配置哪有问题?while(!adc_flag_get(ADC_FLAG_EOC));处一直死循环 |