我要用stm8l152读6路AD值,所以用DMA方式,用的是例程,但发现有移位现象,就是第一个AD值会到第二 第三 第四个的现象,代码如下,求大家帮我看看什么原因
/* Enable ADC1 clock */
CLK_PeripheralClockConfig(CLK_Peripheral_ADC1, ENABLE);
/* Enable DMA1 clock */
CLK_PeripheralClockConfig(CLK_Peripheral_DMA1, ENABLE);
ADC_DeInit(ADC1);
// DMA_GlobalDeInit();
// DMA_DeInit(DMA1_Channel0);
ADC_Init(ADC1, ADC_ConversionMode_Con
tinuous, ADC_Resolution_10Bit, ADC_Prescaler_1);
ADC_SamplingTimeConfig(ADC1, ADC_Group_SlowChannels, ADC_SamplingTime_384Cycles);
ADC_SamplingTimeConfig(ADC1, ADC_Group_FastChannels, ADC_SamplingTime_384Cycles);
/* Enable ADC1 */
ADC_Cmd(ADC1, ENABLE);
/* Enable ADC1 Channels 3 */
ADC_ChannelCmd(ADC1, ADC_Channel_3, ENABLE); /* 大电流1 */
/* Enable ADC1 Channels 4 */
ADC_ChannelCmd(ADC1, ADC_Channel_4, ENABLE); /* 大电流2 */
/* Enable ADC1 Channels 5 */
ADC_ChannelCmd(ADC1, ADC_Channel_5, ENABLE); /* 2灯电流 */
/* Enable ADC1 Channels 11 */
ADC_ChannelCmd(ADC1, ADC_Channel_11, ENABLE); /* 1灯电流 */
/* Enable ADC1 Channels 12 */
ADC_ChannelCmd(ADC1, ADC_Channel_12, ENABLE); /* USB电流 */
/* Enable ADC1 Channels 13 */
ADC_ChannelCmd(ADC1, ADC_Channel_13, ENABLE); /* 电池电压 */
/* Connect ADC to DMA channel 0 */
SYSCFG_REMAPDMAChannelConfig(REMAP_DMA1Channel_ADC1ToChannel0);
DMA_Init(DMA1_Channel0, AD_BUFFER_ADDRESS,
ADC1_DR_ADDRESS,
AD_BUFFER_SIZE,
DMA_DIR_PeripheralToMemory,
DMA_Mode_Circular,
DMA_MemoryIncMode_Inc,
DMA_Priority_High,
DMA_MemoryDataSize_HalfWord);
/* DMA Channel0 enable */
DMA_Cmd(DMA1_Channel0, ENABLE);
/* Enable DMA1 channel0 Transfer complete interrupt */
DMA_ITConfig(DMA1_Channel0, DMA_ITx_TC, ENABLE);
/* DMA enable */
DMA_GlobalCmd(ENABLE);
/* Enable ADC1 DMA requests*/
ADC_DMACmd(ADC1, ENABLE);
/* Start ADC1 Conversion using TIM1 TRGO*/
ADC_SoftwareStartConv(ADC1);