cancel
Showing results for 
Search instead for 
Did you mean: 

STM32Cube - ADC + DMA issue

jfernandez
Associate
Posted on February 05, 2016 at 23:28

Hello!

I'm trying to use a generated code by the STM32Cube software (for a STM32F205 device) to read a sequence of ADC channels using the DMA in circular mode, and I'm facing some annoying problems:

  1. The code is setting the DMA and the ADC modules, but there isn't the ''Start'' function. So I have added this line after the initialization of the ADC and DMA:
    1. HAL_ADC_Start_DMA(&ADCConfig, this->ADCBuffer, sizeof(uint32_t)*NUMBER_OF_ADC_CHANNELS);
  2. After adding this instruction, the DMA interrupt is reached, but is blocking the whole program.
  3. Looking for the problem, I have detected that inside the HAL_ADC_Start_DMA function the DMA instance (pointer) is lost when the ADC is enabled. Just after this instruction:
    1.   {  

          /* Enable the Peripheral */

          __HAL_ADC_ENABLE(hadc);
  4. Then the interrupts flags are not checked correctly and are not cleared, blocking the program.

Has anyone faced this problem? What is the correct sequence for the ADC and DMA initialization? I can fix this issue checking directly the DMA registers, but I would like to know if I'm doing something wrong.

Thanks!

#adc #dma #!stm32
0 REPLIES 0