使用STM32F070进行ADC多通道数据采集,DMA的方式,配置如下,但出现DMA数据错位情况void ADCInit(void) { ADC_InitTypeDef ADC_InitStructure; DMA_InitTypeDef DMA_InitStructure; /* ADC1 DeInit */ ADC_DeInit(ADC1); /* ADC1 Periph clock enable */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE); /* DMA1 clock enable */ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1 , ENABLE); /* DMA1 Channel1 Config */ DMA_DeInit(DMA1_Channel1); DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)ADC1_DR_Address; DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)AD_Value; DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC; DMA_InitStructure.DMA_BufferSize = 4*2; 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); /* DMA1 Channel1 enable */ DMA_Cmd(DMA1_Channel1, ENABLE); /* ADC DMA request in circular mode */ ADC_DMARequestModeConfig(ADC1, ADC_DMAMode_Circular); /* Enable ADC_DMA */ ADC_DMACmd(ADC1, ENABLE); /* Initialize ADC structure */ ADC_StructInit(&ADC_InitStructure); /* Configure the ADC1 in continous mode withe a resolutuion equal to 12 bits */ ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b; ADC_InitStructure.ADC_ContinuousConvMode = ENABLE; ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None; ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; ADC_InitStructure.ADC_ScanDirection = ADC_ScanDirection_Backward; ADC_Init(ADC1, &ADC_InitStructure); /* Convert the ADC1 temperature sensor with 55.5 Cycles as sampling time */ ADC_ChannelConfig(ADC1, ADC_Channel_11 , ADC_SampleTime_55_5Cycles); /* Convert the ADC1 Vref with 55.5 Cycles as sampling time */ ADC_ChannelConfig(ADC1, ADC_Channel_13 , ADC_SampleTime_55_5Cycles); /* ADC Calibration */ ADC_GetCalibrationFactor(ADC1); /* Enable ADC1 */ ADC_Cmd(ADC1, ENABLE); /* Wait the ADCEN falg */ while(!ADC_GetFlagStatus(ADC1, ADC_FLAG_ADEN)); /* ADC1 regular Software Start Conv */ ADC_StartOfConversion(ADC1); } 程序GPIO部分在初始化ADC之前已经初始化了 使用DMA进行数据传送,目标地址为AD_Value[4][2];本意是每通道采集4此后求平均的 理论上AD_Value[0][0],AD_Value[1][0],AD_Value[2][0],AD_Value[3][0],应该是通道11的数据; AD_Value[0][1],AD_Value[1][1],AD_Value[2][1],AD_Value[3][1],应该是通道13的数据,但是实际上数据对调了 求大神指点,谢谢! |
【STM32F0开发日志/评测/笔记】+互补PWM波的产生
STM32F030 PB14和PB15无法输出PWM求助
【STM32F030探索套件】序列之五 外部中断
【STM32F0开发日志---二】+ucosii.2.92移植在STM32F030
上传个STM32F0+5110+内部温度传感器的菜鸟实例
【STM32F030探索套件使用问题】STM32F030 SPI方式驱动ST7565LCD失败
求一份STM32F051 I2C驱动LCD 12864的例程
STM32F0 M0 向结构体赋值进入HardFault异常
STM32F0 ADC-DMA方式采集2路数据时出现问题
STM32F030C8T6,TIM16定时慢很多问题?
把上面这句的参数改为ADC_ScanDirection_Upward
评分
查看全部评分
评分
查看全部评分
谢谢回复,在STM32F0XX系列中是没有这样指定顺序的函数的
评分
查看全部评分