本帖最后由 雨辰073 于 2011-11-29 09:03 编辑
我碰到这样的一个问题,单独使用ADC3的ADC_Channel_5调试,可以在Memory看到相应的数据,再单独调试ADC3的ADC_Channel_9同样可以得到正常的数据。问题来了,当我把2路(电压数值不一样)采样放在一起工作进行测试的时候,我只能在memory看到第一路通道的数据,求解!附上程序:
ADC_InitTypeDef ADC_InitStructure;
ADC_CommonInitTypeDef ADC_CommonInitStructure; //*DMA初始化结构变量
DMA_InitTypeDef DMA_InitStructure; //*DMA初始化结构变量
/* Enable DMA clock */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC3, ENABLE);
/* DMA2 Stream4 Configuration --------------------------------------------*/
DMA_DeInit(DMA2_Stream0);
DMA_InitStructure.DMA_Channel = DMA_Channel_2;
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)ADC3_DR_ADDRESS;
DMA_InitStructure.DMA_Memory0BaseAddr = (INT32U)&ADBUF;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory;
DMA_InitStructure.DMA_BufferSize = 4;
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_FIFOMode = DMA_FIFOMode_Disable;
DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_HalfFull;
DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;
DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
DMA_Init(DMA2_Stream0, &DMA_InitStructure);
DMA_Cmd(DMA2_Stream0, ENABLE);
//* ADC Common Init
ADC_CommonInitStructure.ADC_Mode = ADC_Mode_Independent; //*工作在独立转换模式下
ADC_CommonInitStructure.ADC_Prescaler = ADC_Prescaler_Div2;
ADC_CommonInitStructure.ADC_DMAAccessMode = ADC_DMAAccessMode_Disabled;//*DMA的模式
ADC_CommonInitStructure.ADC_TwoSamplingDelay = ADC_TwoSamplingDelay_20Cycles;//*2个采样之间的时间间隔
ADC_CommonInit(&ADC_CommonInitStructure);
//*ADC3configuration
ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b; //*12位的逼近采样精度
ADC_InitStructure.ADC_ScanConvMode = ENABLE; //*多通道扫描
ADC_InitStructure.ADC_ContinuousConvMode = ENABLE; //*持续循环模式*/
ADC_InitStructure.ADC_ExternalTrigConvEdge=ADC_ExternalTrigConvEdge_Falling;//下降沿转换
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_T4_CC4; //*T4_CH4触发转换
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; //*转换数据向右对齐
ADC_InitStructure.ADC_NbrOfConversion = 2;
ADC_Init(ADC3, &ADC_InitStructure);
//*ADC3 regular channels configuration
ADC_RegularChannelConfig(ADC3, ADC_Channel_5, 1, ADC_SampleTime_480Cycles);
ADC_RegularChannelConfig(ADC3, ADC_Channel_9, 2, ADC_SampleTime_480Cycles);
ADC_DMARequestAfterLastTransferCmd(ADC3, ENABLE);
//* 多通道DMA传输完成标志
ADC_DMACmd(ADC3,ENABLE);
ADC_Cmd(ADC3, ENABLE); |