一、问题描述
1、配置AIN0~AIN6共7个通道为模拟输入通道,定时器TIM2定时20us周期性触发AD转换(规则转换顺序是AIN0~AIN6顺序转换),AIN0,AIN1,
AIN2,AIN3连接电位器, 这电位器的电压经过一阶滤波后连接到各个模拟输入引脚。现象是:假定AIN1的信号没有变化(电位器没有位置没有变
化),AIN0的电压信号的变化范围为0V~3.3V,会影响到AIN1的转换结果误差为30mV左右。但是其他通道电压变化不会影响AIN1的转换结果。
/* DMA1 Channel1 Configuration ----------------------------------------------*/
DMA_DeInit(DMA1_Channel1);
DMA_InitStructure.DMA_PeripheralBaseAddr = ADC1_DR_Address;
DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)ADC_Convert_Result;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
DMA_InitStructure.DMA_BufferSize = 7; /* ADC has seven AIN-Channel--------*/
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
DMA_Init(DMA1_Channel1, &DMA_InitStructure);
/* Enable DMA1_Channel1 Interrupt after transfering 7 AD_convert_data---*/
DMA_ITConfig(DMA1_Channel1,DMA_IT_TC, ENABLE);
/*Clears the DMAy Channel1's interrupt pending bits*/
DMA_ClearITPendingBit(DMA1_IT_TC1);
/* Enable DMA1 channel1 */
DMA_Cmd(DMA1_Channel1, ENABLE);
/* ADC1 configuration ------------------------------------------------------*/
ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
ADC_InitStructure.ADC_ScanConvMode = ENABLE;
ADC_InitStructure.ADC_ContinuousConvMode = DISABLE;
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_T1_CC3;
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
ADC_InitStructure.ADC_NbrOfChannel = 7;
ADC_Init(ADC1, &ADC_InitStructure);
/* Configures ADC1 regular channel_0 as: first converted channel with a 1.5 cycles sample time */
ADC_RegularChannelConfig(ADC1, ADC_Channel_0, 1, ADC_SampleTime_13Cycles5);
/* Configures ADC1 regular channel_1 as: first converted channel with a 1.5 cycles sample time */
ADC_RegularChannelConfig(ADC1, ADC_Channel_1, 2, ADC_SampleTime_13Cycles5);
/* Configures ADC1 regular channel_2 as: first converted channel with a 1.5 cycles sample time */
ADC_RegularChannelConfig(ADC1, ADC_Channel_2, 3, ADC_SampleTime_13Cycles5);
/* Configures ADC1 regular channel_3 as: first converted channel with a 1.5 cycles sample time */
ADC_RegularChannelConfig(ADC1, ADC_Channel_3, 4, ADC_SampleTime_13Cycles5);
/* Configures ADC1 regular channel_4 as: first converted channel with a 1.5 cycles sample time */
ADC_RegularChannelConfig(ADC1, ADC_Channel_4, 5, ADC_SampleTime_13Cycles5);
/* Configures ADC1 regular channel_5 as: first converted channel with a 1.5 cycles sample time */
ADC_RegularChannelConfig(ADC1, ADC_Channel_5, 6, ADC_SampleTime_13Cycles5);
/* Configures ADC1 regular channel_6 as: first converted channel with a 1.5 cycles sample time */
ADC_RegularChannelConfig(ADC1, ADC_Channel_6, 7, ADC_SampleTime_13Cycles5);
/* Enable ADC1 DMA */
ADC_DMACmd(ADC1, ENABLE);
/* Enable ADC1 external trigger */
ADC_ExternalTrigConvCmd(ADC1, ENABLE);
/* Enable ADC1 */
ADC_Cmd(ADC1, ENABLE);
/* Enable ADC1 reset calibration register */
ADC_ResetCalibration(ADC1);
/* Check the end of ADC1 reset calibration register */
while(ADC_GetResetCalibrationStatus(ADC1));
/* Start ADC1 calibration */
ADC_StartCalibration(ADC1);
/* Check the end of ADC1 calibration */
while(ADC_GetCalibrationStatus(ADC1)); |