这是我写的代码,在RDATA寄存中始终没有数据传输过来,还请各位帮忙看一下,谢谢
static void ADC_GPIO_Config(void)
{
rcu_periph_clock_enable(RCU_GPIOA);
gpio_mode_set(GPIOA, GPIO_MODE_ANALOG, GPIO_PUPD_NONE, GPIO_PIN_3);
}
static void ADC_Mode_Config(void)
{
rcu_periph_clock_enable(RCU_ADC0);
adc_clock_config(ADC_ADCCK_PCLK2_DIV8);
adc_deinit();
adc_sync_mode_config(ADC_SYNC_MODE_INDEPENDENT);//
adc_special_function_config(ADC0, ADC_CONTINUOUS_MODE, ENABLE);
adc_special_function_config(ADC0, ADC_SCAN_MODE, ENABLE);
adc_data_alignment_config(ADC0, ADC_DATAALIGN_LEFT);
adc_resolution_config(ADC0,ADC_RESOLUTION_12B);
adc_channel_length_config(ADC0, ADC_REGULAR_CHANNEL, 1);
adc_regular_channel_config(ADC0, 1, ADC_CHANNEL_3, ADC_SAMPLETIME_112);
adc_external_trigger_config(ADC0, ADC_REGULAR_CHANNEL, EXTERNAL_TRIGGER_DISABLE);
adc_interrupt_enable(ADC0, ADC_INT_EOC);
nvic_irq_enable(ADC_IRQn,0,0);
adc_enable(ADC0);
ADC_Delay(0xffffff);
adc_calibration_enable(ADC0);
ADC_Delay(0xffff);
adc_software_trigger_enable(ADC0, ADC_REGULAR_CHANNEL);
ADC_Delay(0xffffff);
flag_value = adc_regular_software_startconv_flag_get(ADC0);
ADC_Delay(0xffffff);
}
void ADC_Config(void)
{
ADC_GPIO_Config();
ADC_Mode_Config();
}
void ADC_IRQHandler(void)
{
if(adc_interrupt_flag_get(ADC0,ADC_INT_FLAG_EOC)==SET)
{
adc_vaule = adc_regular_data_read(ADC0);
}
adc_interrupt_flag_clear(ADC0,ADC_INT_FLAG_EOC);
}
void ADC_Delay(__IO uint32_t nCount) //简单的延时函数
{
for(; nCount != 0; nCount--);
} |