14 ADC——多通道(间断模式)
这里面的代码貌似不对
// 配置ADC通道转换时间
/* ADC1 regular channels configuration */
ADC_ChannelConfig(ADCx, ADC_CHANNEL1 , ADC_SampleTime_239_5Cycles);
ADC_ChannelConfig(ADCx, ADC_CHANNEL3 , ADC_SampleTime_239_5Cycles);
ADC_ChannelConfig(ADCx, ADC_CHANNEL4 , ADC_SampleTime_239_5Cycles);
如果按这样写, 只有最后一句是生效的, 因为 ADC_ChannelConfig 这个方法里面是这样的
void ADC_ChannelConfig(ADC_TypeDef* ADCx, uint32_t ADC_Channel, uint32_t ADC_SampleTime)
{
uint32_t tmpreg = 0;
/* Check the parameters */
assert_param(IS_ADC_ALL_PERIPH(ADCx));
assert_param(IS_ADC_CHANNEL(ADC_Channel));
assert_param(IS_ADC_SAMPLE_TIME(ADC_SampleTime));
/* Configure the ADC Channel */
ADCx->CHSELR = (uint32_t)ADC_Channel;
/* Clear the Sampling time Selection bits */
tmpreg &= ~ADC_SMPR1_SMPR;
/* Set the ADC Sampling Time register */
tmpreg |= (uint32_t)ADC_SampleTime;
/* Configure the ADC Sample time register */
ADCx->SMPR = tmpreg ;
}
这一句
ADCx->CHSELR = (uint32_t)ADC_Channel;
直接就把前两句的设置覆盖了.
谁有正确能用的, 基于中断的多通道连续采集的例子?
|