AnsweredAssumed Answered

STM32Cube - ADC + DMA issue

Question asked by fernandez.javier.001 on Feb 5, 2016

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);
  3. After adding this instruction, the DMA interrupt is reached, but is blocking the whole program.
  5. 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 */
  7. 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.