Posted on February 05, 2016 at 23:28Hello!
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:
- 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:
- HAL_ADC_Start_DMA(&ADCConfig, this->ADCBuffer, sizeof(uint32_t)*NUMBER_OF_ADC_CHANNELS);
- After adding this instruction, the DMA interrupt is reached, but is blocking the whole program.
- 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:
- { /* Enable the Peripheral */ __HAL_ADC_ENABLE(hadc);
- 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