AnsweredAssumed Answered

STM32F0 ADC->DMA touble

Question asked by blesener.daniel on Mar 26, 2014
Latest reply on Jun 22, 2016 by Clive One
I have looked over the following code many times. Not sure what the problem is. Any incite? The raw_dma_adc[] array has no values in it during debug.
The code is for a STM32F051K6U6. End goal is to have 5 channels running. GPIO clock for port A has been enabled.

    ///////////////////////ADC
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2| GPIO_Pin_3 | GPIO_Pin_4;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
    GPIO_Init(GPIOA, &GPIO_InitStructure);

    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1 , ENABLE);
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);

    ADC_DeInit(ADC1);
    DMA_DeInit(DMA1);

    ADC_InitTypeDef Impac_ADC;
    Impac_ADC.ADC_Resolution = ADC_Resolution_12b;
    Impac_ADC.ADC_ContinuousConvMode = ENABLE;
    Impac_ADC.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None;
    Impac_ADC.ADC_ExternalTrigConv = ADC_ExternalTrigConv_T1_TRGO; //not used
    Impac_ADC.ADC_DataAlign = ADC_DataAlign_Right;
    Impac_ADC.ADC_ScanDirection = ADC_ScanDirection_Backward;
    ADC_Init(ADC1, &Impac_ADC);

    ADC_ChannelConfig(ADC1, ADC_Channel_0, ADC_SampleTime_239_5Cycles);

    ADC_ChannelConfig(ADC1, ADC_Channel_1, ADC_SampleTime_239_5Cycles);

    //Calibrate ADC. This must be done before enabling the ADC. The function has a delay built in to allow for wait for calibration.
    ADC_GetCalibrationFactor(ADC1);

    ADC_DMARequestModeConfig(ADC1, ADC_DMAMode_Circular);

    DMA_InitTypeDef Impac_DMA;
    Impac_DMA.DMA_PeripheralBaseAddr = (uint32_t)&ADC1->DR;
    Impac_DMA.DMA_MemoryBaseAddr = (uint32_t)&raw_dma_adc[0];
    Impac_DMA.DMA_DIR = DMA_DIR_PeripheralSRC;//? //DMA_DIR_PeripheralSRC;
    Impac_DMA.DMA_BufferSize = 2;
    Impac_DMA.DMA_PeripheralInc = DMA_PeripheralInc_Enable;         //Keep incrimenting pointer to ADC buffer as tranfering.
    Impac_DMA.DMA_MemoryInc = DMA_MemoryInc_Enable;                 //Keep incrimenting pointer to DMA mem
    Impac_DMA.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word;
    Impac_DMA.DMA_MemoryDataSize = DMA_MemoryDataSize_Word;
    Impac_DMA.DMA_Mode = DMA_Mode_Circular;
    Impac_DMA.DMA_Priority = DMA_Priority_High;
    Impac_DMA.DMA_M2M = DMA_M2M_Disable;
    DMA_Init(DMA1, &Impac_DMA);
   
    ADC_DMACmd(ADC1, ENABLE);
   
    ADC_Cmd(ADC1, ENABLE);
   
    DMA_Cmd(DMA1_Channel1, ENABLE);

    ADC_StartOfConversion(ADC1);

Outcomes