怎样才能不间断采样呢?
我现在的方法:ADC12采样AB相的电压和电流,ADC3采样C相电压和电流,用TIM1的CC2和CC3作为触发,DMA传输采样数据,半传输完成后计算一次,计算期间进行下一个采样,整传输完成后,重新给DMA采样数据个数。
问题是:每相的电压会串扰到电流通道中,即不加电流,只加电压,也能采样到电流!
下面是ADC配置程序:
/* ADC1 configuration ------------------------------------------------------*/
ADC_InitStructure.ADC_Mode = ADC_Mode_RegSimult;
ADC_InitStructure.ADC_ScanConvMode = ENABLE;
ADC_InitStructure.ADC_ContinuousConvMode = DISABLE;
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_T1_CC2;
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
ADC_InitStructure.ADC_NbrOfChannel = 2;
ADC_Init(ADC1, &ADC_InitStructure);
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
ADC_Init(ADC2, &ADC_InitStructure);
ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_T1_CC3;
ADC_Init(ADC3, &ADC_InitStructure);
/* ADC3 regular channel3 configuration,measure current in C*/
ADC_RegularChannelConfig(ADC3, ADC_Channel_1, 1, ADC_SampleTime_7Cycles5);
/* ADC3 regular channel10 Configuration, measure voltage in C*/
ADC_RegularChannelConfig(ADC3, ADC_Channel_10, 2, ADC_SampleTime_7Cycles5);
/* ADC2 regular channel6 configuration,measure current in B*/
ADC_RegularChannelConfig(ADC2, ADC_Channel_0, 1, ADC_SampleTime_7Cycles5);
/* ADC2 regular channel11 Configuration, measure voltage in B*/
ADC_RegularChannelConfig(ADC2, ADC_Channel_11, 2, ADC_SampleTime_7Cycles5);
/* ADC1 regular channel7 configuration,measure current in A*/
ADC_RegularChannelConfig(ADC1, ADC_Channel_13, 1, ADC_SampleTime_7Cycles5);
/* ADC1 regular channel12 Configuration, measure voltage in A*/
ADC_RegularChannelConfig(ADC1, ADC_Channel_12, 2, ADC_SampleTime_7Cycles5); |